Skip to content

Commit

Permalink
fix(interop): only write to cache if we have credentials
Browse files Browse the repository at this point in the history
For pull-requests coming from forks, we don't have access to the secrets. This is currently failing CI for all PRs from forks as docker cannot write the cache after running the tests.

Pull-Request: #4604.
  • Loading branch information
thomaseizinger authored Oct 9, 2023
1 parent 77149f0 commit 35b8308
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
11 changes: 2 additions & 9 deletions .github/workflows/interop-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,12 @@ jobs:

- uses: docker/setup-buildx-action@v3

# This uses the same S3 cache as all test-plans images. Because we use `cargo-chef` in the Dockerfile, we have a layer available with all dependencies built.
- name: Build ${{ matrix.flavour }} image
run: |
docker buildx build \
--load \
--cache-to type=s3,mode=max,bucket=libp2p-by-tf-aws-bootstrap,region=us-east-1,prefix=buildCache,name=${{ matrix.flavour }}-rust-libp2p-head \
--cache-from type=s3,mode=max,bucket=libp2p-by-tf-aws-bootstrap,region=us-east-1,prefix=buildCache,name=${{ matrix.flavour }}-rust-libp2p-head \
-t ${{ matrix.flavour }}-rust-libp2p-head \
. \
-f interop-tests/Dockerfile.${{ matrix.flavour }}
run: ./scripts/build-interop-image.sh
env:
AWS_ACCESS_KEY_ID: ${{ vars.TEST_PLANS_BUILD_CACHE_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.TEST_PLANS_BUILD_CACHE_KEY }}
FLAVOUR: ${{ matrix.flavour }}

- name: Run ${{ matrix.flavour }} tests
uses: libp2p/test-plans/.github/actions/run-interop-ping-test@master
Expand Down
18 changes: 18 additions & 0 deletions scripts/build-interop-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

# This uses the same S3 cache as all test-plans images. Because we use `cargo-chef` in the Dockerfile, we have a layer available with all dependencies built.

CACHE_TO=""

# If we have credentials, write to cache
if [[ -n "${AWS_SECRET_ACCESS_KEY}" ]]; then
CACHE_TO="--cache-to type=s3,mode=max,bucket=libp2p-by-tf-aws-bootstrap,region=us-east-1,prefix=buildCache,name=${FLAVOUR}-rust-libp2p-head"
fi

docker buildx build \
--load \
$CACHE_TO \
--cache-from type=s3,mode=max,bucket=libp2p-by-tf-aws-bootstrap,region=us-east-1,prefix=buildCache,name=${FLAVOUR}-rust-libp2p-head \
-t ${FLAVOUR}-rust-libp2p-head \
. \
-f interop-tests/Dockerfile.${FLAVOUR}

0 comments on commit 35b8308

Please sign in to comment.