From b381de25bb16381758223132329629705695da93 Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Wed, 6 Nov 2024 11:22:03 -0800 Subject: [PATCH 01/13] refactor(e2e): only build zetanode once add docker login back to reusable flow --- .github/workflows/e2e.yml | 76 +++++++++++++++++++++++++++++- .github/workflows/reusable-e2e.yml | 55 +++------------------ Makefile | 39 ++++++++++----- 3 files changed, 108 insertions(+), 62 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 773775e816..94bf0c53dc 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -28,7 +28,73 @@ concurrency: cancel-in-progress: true jobs: + build-zetanode: + runs-on: ubuntu-22.04 + env: + DOCKER_IMAGE: ghcr.io/${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name || github.repository }}/zetanode + DOCKER_TAG: ${{ github.ref == 'refs/heads/develop' && 'develop' || github.sha }} + outputs: + image: ${{ fromJson(steps.build.outputs.metadata)['image.name'] }} + steps: + - uses: actions/checkout@v4 + + # configure docker to use the containerd snapshotter + # so that we can use the buildkit cache + - uses: depot/use-containerd-snapshotter-action@v1 + + - name: Login to github docker registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Restore go cache + uses: actions/cache@v4 + id: restore-go-cache + with: + path: | + go-cache + key: cache-${{ hashFiles('go.sum') }} + + - name: Inject go cache into docker + uses: reproducible-containers/buildkit-cache-dance@v3.1.2 + with: + cache-map: | + { + "go-cache": "/root/.cache/go-build" + } + skip-extraction: ${{ steps.restore-go-cache.outputs.cache-hit || github.event_name != 'push' }} + + # this ensures that the version is consistent between cache build and make build + - name: Set version for cache + run: | + NODE_VERSION=$(./version.sh) + echo "NODE_VERSION=$NODE_VERSION" >> $GITHUB_ENV + NODE_COMMIT=$(git log -1 --format='%H') + echo "NODE_COMMIT=$NODE_COMMIT" >> $GITHUB_ENV + + # build zetanode with cache options + - name: Build zetanode for cache + id: build + uses: docker/build-push-action@v6 + env: + CACHE_FROM_CONFIG: "type=registry,ref=ghcr.io/${{ github.repository }}:buildcache" + CACHE_TO_CONFIG: "type=registry,ref=ghcr.io/${{ github.repository }}:buildcache,mode=max" + with: + context: . + file: ./Dockerfile-localnet + push: true + tags: ${{ env.DOCKER_IMAGE }}:${{ env.DOCKER_TAG }} + cache-from: ${{ env.CACHE_FROM_CONFIG }} + cache-to: ${{ github.event_name == 'push' && env.CACHE_TO_CONFIG || '' }} + target: latest-runtime + build-args: | + NODE_VERSION=${{ env.NODE_VERSION }} + NODE_COMMIT=${{ env.NODE_COMMIT }} + matrix-conditionals: + needs: build-zetanode runs-on: ubuntu-22.04 env: GH_TOKEN: ${{ github.token }} @@ -119,7 +185,9 @@ jobs: } e2e: - needs: matrix-conditionals + needs: + - build-zetanode + - matrix-conditionals strategy: fail-fast: false matrix: @@ -170,12 +238,14 @@ jobs: runs-on: ${{ matrix.runs-on}} run: ${{ matrix.run }} timeout-minutes: "${{ matrix.timeout-minutes || 25 }}" + zetanode-image: ${{ needs.zetanode-build.outputs.image }} enable-monitoring: ${{ needs.matrix-conditionals.outputs.ENABLE_MONITORING == 'true' }} secrets: inherit # this allows you to set a required status check e2e-ok: runs-on: ubuntu-22.04 needs: + - build-zetanode - matrix-conditionals - e2e if: always() @@ -224,6 +294,10 @@ jobs: - run: | + result="${{ needs.build-zetanode.result }}" + if [[ $result != "success" ]]; then + exit 1 + fi result="${{ needs.e2e.result }}" if [[ $result == "success" || $result == "skipped" ]]; then exit 0 diff --git a/.github/workflows/reusable-e2e.yml b/.github/workflows/reusable-e2e.yml index 88c42466a5..a4aa35c2ec 100644 --- a/.github/workflows/reusable-e2e.yml +++ b/.github/workflows/reusable-e2e.yml @@ -19,6 +19,10 @@ on: required: true type: string default: 'ubuntu-20.04' + zetanode-image: + description: 'docker image to use for zetanode' + required: true + type: string enable-monitoring: description: 'Enable the monitoring stack for this run' type: boolean @@ -31,12 +35,10 @@ jobs: timeout-minutes: ${{ inputs.timeout-minutes }} strategy: fail-fast: false + env: + ZETANODE_IMAGE: ${{ inputs.zetanode-image }} steps: - uses: actions/checkout@v4 - - # configure docker to use the containerd snapshotter - # so that we can use the buildkit cache - - uses: depot/use-containerd-snapshotter-action@v1 - name: Login to Docker Hub registry uses: docker/login-action@v3 @@ -51,50 +53,7 @@ jobs: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - - name: Restore go cache - uses: actions/cache@v4 - id: restore-go-cache - with: - path: | - go-cache - key: cache-${{ hashFiles('go.sum') }} - - - name: Inject go cache into docker - uses: reproducible-containers/buildkit-cache-dance@v3.1.2 - with: - cache-map: | - { - "go-cache": "/root/.cache/go-build" - } - skip-extraction: ${{ steps.restore-go-cache.outputs.cache-hit || github.event_name != 'push' }} - - # this ensures that the version is consistent between cache build and make build - - name: Set version for cache - run: | - NODE_VERSION=$(./version.sh) - echo "NODE_VERSION=$NODE_VERSION" >> $GITHUB_ENV - NODE_COMMIT=$(git log -1 --format='%H') - echo "NODE_COMMIT=$NODE_COMMIT" >> $GITHUB_ENV - - # build zetanode with cache options - - name: Build zetanode for cache - uses: docker/build-push-action@v6 - env: - CACHE_FROM_CONFIG: "type=registry,ref=ghcr.io/${{ github.repository }}:buildcache" - CACHE_TO_CONFIG: "type=registry,ref=ghcr.io/${{ github.repository }}:buildcache,mode=max" - with: - context: . - file: ./Dockerfile-localnet - push: false - tags: zetanode:latest - cache-from: ${{ env.CACHE_FROM_CONFIG }} - cache-to: ${{ github.event_name == 'push' && env.CACHE_TO_CONFIG || '' }} - target: latest-runtime - build-args: | - NODE_VERSION=${{ env.NODE_VERSION }} - NODE_COMMIT=${{ env.NODE_COMMIT }} - + - name: Enable monitoring if: inputs.enable-monitoring run: | diff --git a/Makefile b/Makefile index f39e4f27ff..4ecb211f09 100644 --- a/Makefile +++ b/Makefile @@ -227,7 +227,8 @@ generate: proto-gen openapi specs typescript docs-zetacored mocks precompiles fm ############################################################################### ### Localnet ### ############################################################################### -start-localnet: zetanode start-localnet-skip-build +e2e-images: zetanode orchestrator +start-localnet: e2e-images start-localnet-skip-build start-localnet-skip-build: @echo "--> Starting localnet" @@ -242,11 +243,23 @@ stop-localnet: ### E2E tests ### ############################################################################### +ifdef ZETANODE_IMAGE +zetanode: + @echo "Pulling zetanode image" + $(DOCKER) pull $(ZETANODE_IMAGE) + $(DOCKER) tag $(ZETANODE_IMAGE) zetanode +.PHONY: zetanode +else zetanode: @echo "Building zetanode" $(DOCKER) build -t zetanode --build-arg NODE_VERSION=$(NODE_VERSION) --build-arg NODE_COMMIT=$(NODE_COMMIT) --target latest-runtime -f ./Dockerfile-localnet . - $(DOCKER) build -t orchestrator -f contrib/localnet/orchestrator/Dockerfile.fastbuild . .PHONY: zetanode +endif + +orchestrator: + @echo "Building e2e orchestrator" + $(DOCKER) build -t orchestrator -f contrib/localnet/orchestrator/Dockerfile.fastbuild . +.PHONY: orchestrator install-zetae2e: go.sum @echo "--> Installing zetae2e" @@ -257,47 +270,47 @@ solana: @echo "Building solana docker image" $(DOCKER) build -t solana-local -f contrib/localnet/solana/Dockerfile contrib/localnet/solana/ -start-e2e-test: zetanode +start-e2e-test: e2e-images @echo "--> Starting e2e test" cd contrib/localnet/ && $(DOCKER_COMPOSE) up -d -start-e2e-admin-test: zetanode +start-e2e-admin-test: e2e-images @echo "--> Starting e2e admin test" export E2E_ARGS="--skip-regular --test-admin" && \ cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile eth2 up -d -start-e2e-performance-test: zetanode +start-e2e-performance-test: e2e-images @echo "--> Starting e2e performance test" export E2E_ARGS="--test-performance" && \ cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile stress up -d -start-e2e-import-mainnet-test: zetanode +start-e2e-import-mainnet-test: e2e-images @echo "--> Starting e2e import-data test" export ZETACORED_IMPORT_GENESIS_DATA=true && \ export ZETACORED_START_PERIOD=15m && \ cd contrib/localnet/ && ./scripts/import-data.sh mainnet && $(DOCKER_COMPOSE) up -d -start-stress-test: zetanode +start-stress-test: e2e-images @echo "--> Starting stress test" cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile stress up -d -start-tss-migration-test: zetanode +start-tss-migration-test: e2e-images @echo "--> Starting tss migration test" export LOCALNET_MODE=tss-migrate && \ export E2E_ARGS="--test-tss-migration" && \ cd contrib/localnet/ && $(DOCKER_COMPOSE) up -d -start-solana-test: zetanode solana +start-solana-test: e2e-images solana @echo "--> Starting solana test" export E2E_ARGS="--skip-regular --test-solana" && \ cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile solana up -d -start-ton-test: zetanode +start-ton-test: e2e-images @echo "--> Starting TON test" export E2E_ARGS="--skip-regular --test-ton" && \ cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile ton up -d -start-v2-test: zetanode +start-v2-test: e2e-images @echo "--> Starting e2e smart contracts v2 test" export E2E_ARGS="--skip-regular --test-v2" && \ cd contrib/localnet/ && $(DOCKER_COMPOSE) up -d @@ -309,7 +322,7 @@ start-v2-test: zetanode # build from source only if requested # NODE_VERSION and NODE_COMMIT must be set as old-runtime depends on lastest-runtime ifdef UPGRADE_TEST_FROM_SOURCE -zetanode-upgrade: zetanode +zetanode-upgrade: e2e-images @echo "Building zetanode-upgrade from source" $(DOCKER) build -t zetanode:old -f Dockerfile-localnet --target old-runtime-source \ --build-arg OLD_VERSION='release/v21' \ @@ -318,7 +331,7 @@ zetanode-upgrade: zetanode . .PHONY: zetanode-upgrade else -zetanode-upgrade: zetanode +zetanode-upgrade: e2e-images @echo "Building zetanode-upgrade from binaries" $(DOCKER) build -t zetanode:old -f Dockerfile-localnet --target old-runtime \ --build-arg OLD_VERSION='https://github.com/zeta-chain/node/releases/download/v21.0.0' \ From b220a79d7b8eb493c37d8d6ddb1d1291c5aa251c Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Wed, 6 Nov 2024 11:46:47 -0800 Subject: [PATCH 02/13] debug --- .github/workflows/e2e.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 94bf0c53dc..be4f185e4b 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -42,6 +42,13 @@ jobs: # so that we can use the buildkit cache - uses: depot/use-containerd-snapshotter-action@v1 + - name: Login to Docker Hub registry + uses: docker/login-action@v3 + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'zeta-chain/node' + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_READ_ONLY }} + - name: Login to github docker registry uses: docker/login-action@v3 with: @@ -92,6 +99,7 @@ jobs: build-args: | NODE_VERSION=${{ env.NODE_VERSION }} NODE_COMMIT=${{ env.NODE_COMMIT }} + - run: echo "${{ steps.build.outputs.metadata }}" matrix-conditionals: needs: build-zetanode From 39f1ad1ea9955acb9da0006e29a035c5ce23d934 Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Wed, 6 Nov 2024 11:51:33 -0800 Subject: [PATCH 03/13] fix --- .github/workflows/e2e.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index be4f185e4b..3716ef9c1c 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -99,7 +99,6 @@ jobs: build-args: | NODE_VERSION=${{ env.NODE_VERSION }} NODE_COMMIT=${{ env.NODE_COMMIT }} - - run: echo "${{ steps.build.outputs.metadata }}" matrix-conditionals: needs: build-zetanode @@ -246,7 +245,7 @@ jobs: runs-on: ${{ matrix.runs-on}} run: ${{ matrix.run }} timeout-minutes: "${{ matrix.timeout-minutes || 25 }}" - zetanode-image: ${{ needs.zetanode-build.outputs.image }} + zetanode-image: ${{ needs.build-zetanode.outputs.image }} enable-monitoring: ${{ needs.matrix-conditionals.outputs.ENABLE_MONITORING == 'true' }} secrets: inherit # this allows you to set a required status check From b4af99b3638802f1c6df1c229463c9baed510470 Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Wed, 6 Nov 2024 12:00:59 -0800 Subject: [PATCH 04/13] remove apt install from orchestrator build and just use zetanode as base --- contrib/localnet/orchestrator/Dockerfile.fastbuild | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/contrib/localnet/orchestrator/Dockerfile.fastbuild b/contrib/localnet/orchestrator/Dockerfile.fastbuild index cbab881a65..308e59a146 100644 --- a/contrib/localnet/orchestrator/Dockerfile.fastbuild +++ b/contrib/localnet/orchestrator/Dockerfile.fastbuild @@ -1,17 +1,11 @@ # syntax=ghcr.io/zeta-chain/docker-dockerfile:1.9-labs # check=error=true -FROM zetanode:latest AS zeta FROM ghcr.io/zeta-chain/ethereum-client-go:v1.10.26 AS geth FROM ghcr.io/zeta-chain/solana-docker:1.18.15 AS solana -FROM ghcr.io/zeta-chain/golang:1.22.7-bookworm AS orchestrator - -RUN apt update && \ - apt install -yq jq yq curl tmux python3 openssh-server iputils-ping iproute2 bind9-host && \ - rm -rf /var/lib/apt/lists/* +FROM zetanode:latest COPY --from=geth /usr/local/bin/geth /usr/local/bin/ COPY --from=solana /usr/bin/solana /usr/local/bin/ -COPY --from=zeta /usr/local/bin/zetacored /usr/local/bin/zetaclientd /usr/local/bin/zetae2e /usr/local/bin/ COPY contrib/localnet/orchestrator/start-zetae2e.sh /work/ COPY contrib/localnet/scripts/wait-for-ton.sh /work/ From dd3d3af6caa799965e73ae63a1f2916bfa8f19f0 Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Wed, 6 Nov 2024 12:44:25 -0800 Subject: [PATCH 05/13] use zetanode:latest --- Dockerfile-localnet | 8 ++++---- Makefile | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile-localnet b/Dockerfile-localnet index 49247d6be4..09e8c15a10 100644 --- a/Dockerfile-localnet +++ b/Dockerfile-localnet @@ -67,7 +67,8 @@ COPY --from=latest-build /go/bin/zetacored /go/bin/zetaclientd /go/bin/zetaclien # Optional old version build (from source). This old build is used as the genesis version in the upgrade tests. # Use --target latest-runtime to skip. -FROM base-build AS old-build-source +# you must have already built the latest image (which the Makefile does) +FROM zetanode:latest AS old-build-source ARG OLD_VERSION RUN git clone https://github.com/zeta-chain/node.git @@ -84,13 +85,12 @@ COPY --from=latest-build /go/bin/zetaclientd-supervisor /usr/local/bin # Optional old version build (from binary). # Use --target latest-runtime to skip. -FROM base-runtime AS old-runtime +# you must have already built the latest image (which the Makefile does) +FROM zetanode:latest AS old-runtime ARG OLD_VERSION ARG BUILDARCH -COPY --from=cosmovisor-build /go/bin/cosmovisor /usr/local/bin -COPY --from=latest-build /go/bin/zetaclientd-supervisor /usr/local/bin RUN curl -Lo /usr/local/bin/zetacored ${OLD_VERSION}/zetacored-linux-${BUILDARCH} && \ chmod 755 /usr/local/bin/zetacored && \ curl -Lo /usr/local/bin/zetaclientd ${OLD_VERSION}/zetaclientd-linux-${BUILDARCH} && \ diff --git a/Makefile b/Makefile index 4ecb211f09..470055d651 100644 --- a/Makefile +++ b/Makefile @@ -247,7 +247,7 @@ ifdef ZETANODE_IMAGE zetanode: @echo "Pulling zetanode image" $(DOCKER) pull $(ZETANODE_IMAGE) - $(DOCKER) tag $(ZETANODE_IMAGE) zetanode + $(DOCKER) tag $(ZETANODE_IMAGE) zetanode:latest .PHONY: zetanode else zetanode: From 3cbdb5039444b40e92893665d22d63f7de26116e Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Wed, 6 Nov 2024 13:43:19 -0800 Subject: [PATCH 06/13] fix fork build --- .github/workflows/e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 3716ef9c1c..b99453ae4e 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -31,7 +31,7 @@ jobs: build-zetanode: runs-on: ubuntu-22.04 env: - DOCKER_IMAGE: ghcr.io/${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name || github.repository }}/zetanode + DOCKER_IMAGE: ghcr.io/${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.owner.login || github.repository_owner }}/zetanode DOCKER_TAG: ${{ github.ref == 'refs/heads/develop' && 'develop' || github.sha }} outputs: image: ${{ fromJson(steps.build.outputs.metadata)['image.name'] }} From 0981808b5519712fbf812b935b953fcd625dfc05 Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Wed, 6 Nov 2024 13:58:00 -0800 Subject: [PATCH 07/13] ghcr_username --- .github/workflows/e2e.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index b99453ae4e..2b5d62bcd9 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -31,7 +31,8 @@ jobs: build-zetanode: runs-on: ubuntu-22.04 env: - DOCKER_IMAGE: ghcr.io/${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.owner.login || github.repository_owner }}/zetanode + GHCR_USERNAME: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.owner.login || github.repository_owner }} + DOCKER_IMAGE: ghcr.io/${{ env.GHCR_USERNAME }}/zetanode DOCKER_TAG: ${{ github.ref == 'refs/heads/develop' && 'develop' || github.sha }} outputs: image: ${{ fromJson(steps.build.outputs.metadata)['image.name'] }} @@ -53,7 +54,7 @@ jobs: uses: docker/login-action@v3 with: registry: ghcr.io - username: ${{ github.repository_owner }} + username: ${{ env.GHCR_USERNAME }} password: ${{ secrets.GITHUB_TOKEN }} - name: Restore go cache From 4b1bf8aaccf3728e8561fe52291765772884e379 Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Wed, 6 Nov 2024 14:00:23 -0800 Subject: [PATCH 08/13] cannot use env in env --- .github/workflows/e2e.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 2b5d62bcd9..322c276c04 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -31,8 +31,7 @@ jobs: build-zetanode: runs-on: ubuntu-22.04 env: - GHCR_USERNAME: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.owner.login || github.repository_owner }} - DOCKER_IMAGE: ghcr.io/${{ env.GHCR_USERNAME }}/zetanode + DOCKER_IMAGE: ghcr.io/${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.owner.login || github.repository_owner }}/zetanode DOCKER_TAG: ${{ github.ref == 'refs/heads/develop' && 'develop' || github.sha }} outputs: image: ${{ fromJson(steps.build.outputs.metadata)['image.name'] }} @@ -54,7 +53,7 @@ jobs: uses: docker/login-action@v3 with: registry: ghcr.io - username: ${{ env.GHCR_USERNAME }} + username: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.owner.login || github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Restore go cache From 9449c98780392eda44645a3c97b085b14091996f Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Wed, 6 Nov 2024 14:08:32 -0800 Subject: [PATCH 09/13] try packages write permission --- .github/workflows/e2e.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 322c276c04..8936018e97 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -30,6 +30,8 @@ concurrency: jobs: build-zetanode: runs-on: ubuntu-22.04 + permissions: + packages: write env: DOCKER_IMAGE: ghcr.io/${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.owner.login || github.repository_owner }}/zetanode DOCKER_TAG: ${{ github.ref == 'refs/heads/develop' && 'develop' || github.sha }} From cb1e83202b232e3a2aacb8d0a10a3d5810cda45c Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Wed, 6 Nov 2024 14:15:24 -0800 Subject: [PATCH 10/13] fall back to slow build on forks --- .github/workflows/e2e.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 8936018e97..85432dacb4 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -28,12 +28,13 @@ concurrency: cancel-in-progress: true jobs: + # this cannot run on forks as forks cannot push packages in pull request context + # forked pull request will fall back to slow build build-zetanode: runs-on: ubuntu-22.04 - permissions: - packages: write + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'zeta-chain/node' env: - DOCKER_IMAGE: ghcr.io/${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.owner.login || github.repository_owner }}/zetanode + DOCKER_IMAGE: ghcr.io/${{ github.repository_owner }}/zetanode DOCKER_TAG: ${{ github.ref == 'refs/heads/develop' && 'develop' || github.sha }} outputs: image: ${{ fromJson(steps.build.outputs.metadata)['image.name'] }} @@ -46,7 +47,6 @@ jobs: - name: Login to Docker Hub registry uses: docker/login-action@v3 - if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'zeta-chain/node' with: username: ${{ secrets.DOCKER_HUB_USERNAME }} password: ${{ secrets.DOCKER_HUB_READ_ONLY }} @@ -55,7 +55,7 @@ jobs: uses: docker/login-action@v3 with: registry: ghcr.io - username: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.owner.login || github.repository_owner }} + username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Restore go cache @@ -304,7 +304,7 @@ jobs: - run: | result="${{ needs.build-zetanode.result }}" - if [[ $result != "success" ]]; then + if [[ $result != "success" || $result == "skipped" ]]; then exit 1 fi result="${{ needs.e2e.result }}" From d13840f1a06b81165119b0dc4c11aa0cb89874d9 Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Wed, 6 Nov 2024 14:18:16 -0800 Subject: [PATCH 11/13] have to run matrix always() --- .github/workflows/e2e.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 85432dacb4..c1f33f13b6 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -104,6 +104,7 @@ jobs: matrix-conditionals: needs: build-zetanode + if: always() runs-on: ubuntu-22.04 env: GH_TOKEN: ${{ github.token }} From 68c82c77e88d010e7fcd8d02ac2b1db6f257610d Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Wed, 6 Nov 2024 14:19:57 -0800 Subject: [PATCH 12/13] more always() --- .github/workflows/e2e.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index c1f33f13b6..82271c3232 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -198,6 +198,7 @@ jobs: needs: - build-zetanode - matrix-conditionals + if: always() strategy: fail-fast: false matrix: From f2cdc8495528897505f890ff69f00384de9f8414 Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Wed, 6 Nov 2024 14:41:07 -0800 Subject: [PATCH 13/13] only check failed status (fork will be skipped) --- .github/workflows/e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 82271c3232..4aadf4900e 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -306,7 +306,7 @@ jobs: - run: | result="${{ needs.build-zetanode.result }}" - if [[ $result != "success" || $result == "skipped" ]]; then + if [[ $result == "failed" ]]; then exit 1 fi result="${{ needs.e2e.result }}"