From f177b2111836d28787dd4f1201e6531d883c07bf Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Thu, 16 Nov 2023 16:33:31 +0000 Subject: [PATCH] Run WASM E2E tests only when relevant changes are made (#5092) --- .github/workflows/e2e-fork.yml | 2 +- .github/workflows/e2e-test-workflow-call.yml | 19 ++++-- .github/workflows/e2e-wasm.yaml | 67 ++++++++++++++++++++ .github/workflows/e2e.yaml | 2 +- 4 files changed, 81 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/e2e-wasm.yaml diff --git a/.github/workflows/e2e-fork.yml b/.github/workflows/e2e-fork.yml index cfdd70ef277..9c87a6bb054 100644 --- a/.github/workflows/e2e-fork.yml +++ b/.github/workflows/e2e-fork.yml @@ -24,7 +24,7 @@ jobs: - id: set-matrix run: echo "matrix=$(go run cmd/build_test_matrix/main.go)" >> $GITHUB_OUTPUT env: - TEST_EXCLUSIONS: 'TestUpgradeTestSuite' + TEST_EXCLUSIONS: 'TestUpgradeTestSuite,TestGrandpaTestSuite' # e2e-fork runs the e2e tests directly by using a matrix strategy. e2e-fork: diff --git a/.github/workflows/e2e-test-workflow-call.yml b/.github/workflows/e2e-test-workflow-call.yml index 6dd35170fe1..c1ff1ad629d 100644 --- a/.github/workflows/e2e-test-workflow-call.yml +++ b/.github/workflows/e2e-test-workflow-call.yml @@ -67,6 +67,11 @@ on: required: false type: boolean default: false + build-and-push-docker-image-wasm: + description: 'Flag to specify if the wasm docker image should be built and pushed beforehand' + required: false + type: boolean + default: false upload-logs: description: 'Specify flag to indicate that logs should be uploaded on failure' required: false @@ -134,26 +139,26 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - if: ${{ inputs.build-and-push-docker-image }} + if: ${{ inputs.build-and-push-docker-image-wasm }} - uses: actions/setup-python@v4 - if: ${{ inputs.build-and-push-docker-image }} + if: ${{ inputs.build-and-push-docker-image-wasm }} with: python-version: '3.10' - name: Install dependencies - if: ${{ inputs.build-and-push-docker-image }} + if: ${{ inputs.build-and-push-docker-image-wasm }} run: make python-install-deps - name: Determine Build arguments - if: ${{ inputs.build-and-push-docker-image }} + if: ${{ inputs.build-and-push-docker-image-wasm }} id: build-args run: | echo "version=$(scripts/get-libwasm-version.py --get-version)" >> $GITHUB_OUTPUT echo "checksum=$(scripts/get-libwasm-version.py --get-checksum)" >> $GITHUB_OUTPUT - name: Log in to the Container registry - if: ${{ inputs.build-and-push-docker-image }} + if: ${{ inputs.build-and-push-docker-image-wasm }} uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d with: registry: ${{ env.REGISTRY }} @@ -161,14 +166,14 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata (tags, labels) for Docker - if: ${{ inputs.build-and-push-docker-image }} + if: ${{ inputs.build-and-push-docker-image-wasm }} id: meta uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 with: images: ${{ env.REGISTRY }}/cosmos/${{ env.IMAGE_NAME_WASM }} - name: Build and push Docker image - if: ${{ inputs.build-and-push-docker-image }} + if: ${{ inputs.build-and-push-docker-image-wasm }} uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 with: context: . diff --git a/.github/workflows/e2e-wasm.yaml b/.github/workflows/e2e-wasm.yaml new file mode 100644 index 00000000000..c497c6f9590 --- /dev/null +++ b/.github/workflows/e2e-wasm.yaml @@ -0,0 +1,67 @@ +# The Tests / E2E Wasm workflow is used to run end-to-end tests on pull requests originating +# from the ibc-go repository. The workflow specifically runs 08-wasm tests. +name: Tests / E2E Wasm +on: + workflow_dispatch: + pull_request: + paths: + - 'e2e/tests/wasm/**' # the e2e tests or contracts change. + - 'modules/light-clients/08-wasm/**' # modifications to the 08-wasm module. + - 'modules/core/02-client/**' # modifications to the 02-client module. + - '.github/workflows/e2e-wasm.yaml' # changes to this workflow. + types: + # trigger workflow if PR is opened directly as R4R. + - opened + # trigger workflow if changes are pushed to the branch. + - synchronize + # trigger workflow if PR is marked ready for review. + - ready_for_review + + +jobs: + # determine-image-tag will either output the PR number e.g. pr-1234 or the string main. + # this will be used to tag the images that are built during the workflow. + determine-image-tag: + if: ${{ !github.event.pull_request.draft && !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} + runs-on: ubuntu-latest + outputs: + simd-tag: ${{ steps.get-tag.outputs.simd-tag }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v4 + with: + go-version: '1.21' + - id: get-tag + run: | + if [ -z "${{ github.event.pull_request.number }}" ] + then + echo "simd-tag=main" >> $GITHUB_OUTPUT + else + tag="pr-${{ github.event.pull_request.number }}" + echo "Using tag $tag" + echo "simd-tag=$tag" >> $GITHUB_OUTPUT + fi + + # e2e generates the e2e tests for the non-forked PRs. It does so by using the + # e2e-test-workflow-call.yml each test runs the jobs defined in that file. + e2e: + # we will be running this job if the PR has not yet been marked for review, and we push additional changes. + # we skip the job in this case. + if: ${{ !github.event.pull_request.draft && !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} + needs: determine-image-tag # we are required to have a docker tag before we can build any images. + uses: ./.github/workflows/e2e-test-workflow-call.yml + # unless we explicitly tell the workflow to inherit secrets, required secrets such as GITHUB_TOKEN will not be + # provided to the workflow. This would cause privileged operations to fail. + secrets: inherit + with: + # with each test, we build an image from the current code. + build-and-push-docker-image-wasm: true + # if the test fails, we upload logs so that we can download them from the UI. + upload-logs: true + chain-image: ghcr.io/cosmos/ibc-go-wasm-simd + # with regular tests, both images are the same. + chain-a-tag: '${{ needs.determine-image-tag.outputs.simd-tag }}' + chain-b-tag: '${{ needs.determine-image-tag.outputs.simd-tag }}' + chain-binary: 'simd' + # only run the grandpa test suite for wasm tests. + test-entry-point: 'TestGrandpaTestSuite' diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 82f6ac49d20..c36df8cb388 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -63,4 +63,4 @@ jobs: chain-b-tag: '${{ needs.determine-image-tag.outputs.simd-tag }}' chain-binary: 'simd' # on regular PRs we won't run upgrade tests. - test-exclusions: 'TestUpgradeTestSuite' + test-exclusions: 'TestUpgradeTestSuite,TestGrandpaTestSuite'