From 2849050e1a38c133ae5ad662b261b6ddafb111a0 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Wed, 23 Nov 2022 14:39:43 +0100 Subject: [PATCH] ci: improve test skipping mechanism (#13987) --- .github/workflows/build-skip.yml | 18 ----- .github/workflows/build.yml | 22 +++--- .github/workflows/test-skip.yml | 111 ------------------------------- .github/workflows/test.yml | 100 +++++++++++++++++++++++++--- 4 files changed, 105 insertions(+), 146 deletions(-) delete mode 100644 .github/workflows/build-skip.yml delete mode 100644 .github/workflows/test-skip.yml diff --git a/.github/workflows/build-skip.yml b/.github/workflows/build-skip.yml deleted file mode 100644 index c96e8a1022..0000000000 --- a/.github/workflows/build-skip.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Build SimApp -# This workflow allows to skip the build step if the PR does not contain any changes to the code -# See https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks -on: - pull_request: - paths-ignore: - - "**/*.go" - - "go.mod" - - "go.sum" - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - go-arch: ["amd64", "arm", "arm64"] - steps: - - run: 'echo "No build required"' diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7227bf9e3c..ed4cac0e93 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,18 +2,10 @@ name: Build SimApp # This workflow is run on pushes to main & every Pull Requests where a .go, .mod, .sum have been changed on: pull_request: - paths: - - "**/*.go" - - "go.mod" - - "go.sum" push: branches: - main - release/** - paths: - - "**/*.go" - - "go.mod" - - "go.sum" permissions: contents: read @@ -32,9 +24,23 @@ jobs: - uses: actions/setup-go@v3 with: go-version: 1.19.2 + - uses: technote-space/get-diff-action@v6.1.1 + id: git_diff + with: + PATTERNS: | + **/*.go + go.mod + go.sum + **/go.mod + **/go.sum + **/Makefile + Makefile - name: Build + if: env.GIT_DIFF run: GOARCH=${{ matrix.go-arch }} LEDGER_ENABLED=false make build - name: Build Legacy + if: env.GIT_DIFF run: GOARCH=${{ matrix.go-arch }} LEDGER_ENABLED=false COSMOS_BUILD_OPTIONS=legacy make build - name: Build Cosmovisor + if: env.GIT_DIFF run: GOARCH=${{ matrix.go-arch }} LEDGER_ENABLED=false make cosmovisor diff --git a/.github/workflows/test-skip.yml b/.github/workflows/test-skip.yml deleted file mode 100644 index 00acbb2386..0000000000 --- a/.github/workflows/test-skip.yml +++ /dev/null @@ -1,111 +0,0 @@ -name: Tests / Code Coverage -# This workflow allows to skip the test step if the PR does not contain any changes to the code -# See https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks -on: - pull_request: - paths-ignore: - - "**/*.go" - - "go.mod" - - "go.sum" - -concurrency: - group: ci-${{ github.ref }}-tests - cancel-in-progress: true - -jobs: - test-submodules: - runs-on: ubuntu-latest - steps: - - run: 'echo "No tests required"' - - tests: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - part: ["00", "01", "02", "03"] - steps: - - run: 'echo "No tests required"' - - tests-legacy: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - part: ["00", "01", "02", "03"] - steps: - - run: 'echo "No tests required"' - - test-integration: - runs-on: ubuntu-latest - steps: - - run: 'echo "No tests required"' - - test-e2e: - runs-on: ubuntu-latest - steps: - - run: 'echo "No tests required"' - - repo-analysis: - runs-on: ubuntu-latest - steps: - - run: 'echo "No tests required"' - - liveness-test: - runs-on: ubuntu-latest - steps: - - run: 'echo "No tests required"' - - test-sim-nondeterminism: - runs-on: ubuntu-latest - steps: - - run: 'echo "No tests required"' - - ################################## - #### Cosmos SDK Go Submodules #### - ################################## - - test-clientv2: - runs-on: ubuntu-latest - steps: - - run: 'echo "No tests required"' - - test-core: - runs-on: ubuntu-latest - steps: - - run: 'echo "No tests required"' - - test-depinject: - runs-on: ubuntu-latest - steps: - - run: 'echo "No tests required"' - - test-errors: - runs-on: ubuntu-latest - steps: - - run: 'echo "No tests required"' - - test-math: - runs-on: ubuntu-latest - steps: - - run: 'echo "No tests required"' - - test-simapp: - runs-on: ubuntu-latest - steps: - - run: 'echo "No tests required"' - - test-tx: - runs-on: ubuntu-latest - steps: - - run: 'echo "No tests required"' - - test-rosetta: - runs-on: ubuntu-latest - steps: - - run: 'echo "No tests required"' - - test-cosmovisor: - runs-on: ubuntu-latest - steps: - - run: 'echo "No tests required"' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 80951dab50..38e3e2ef7d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,17 +1,9 @@ name: Tests / Code Coverage on: pull_request: - paths: - - "**/*.go" - - "go.mod" - - "go.sum" push: branches: - main - paths: - - "**/*.go" - - "go.mod" - - "go.sum" permissions: contents: read @@ -61,13 +53,24 @@ jobs: - uses: actions/setup-go@v3 with: go-version: 1.19.2 + - uses: technote-space/get-diff-action@v6.1.1 + id: git_diff + with: + PATTERNS: | + **/*.go + go.mod + go.sum + **/go.mod + **/go.sum - uses: actions/download-artifact@v3 with: name: "${{ github.sha }}-${{ matrix.part }}" - name: test & coverage report creation + if: env.GIT_DIFF run: | cat pkgs.txt.part.${{ matrix.part }} | xargs go test -mod=readonly -race -timeout 30m -coverprofile=${{ matrix.part }}profile.out -covermode=atomic -tags='ledger test_ledger_mock' - uses: actions/upload-artifact@v3 + if: env.GIT_DIFF with: name: "${{ github.sha }}-${{ matrix.part }}-coverage" path: ./${{ matrix.part }}profile.out @@ -84,10 +87,20 @@ jobs: - uses: actions/setup-go@v3 with: go-version: 1.19.2 + - uses: technote-space/get-diff-action@v6.1.1 + id: git_diff + with: + PATTERNS: | + **/*.go + go.mod + go.sum + **/go.mod + **/go.sum - uses: actions/download-artifact@v3 with: name: "${{ github.sha }}-${{ matrix.part }}" - name: test app (v1) + if: env.GIT_DIFF run: | cat pkgs.txt.part.${{ matrix.part }} | xargs go test -mod=readonly -timeout 30m -tags='app_v1 norace ledger test_ledger_mock' @@ -98,10 +111,23 @@ jobs: - uses: actions/setup-go@v3 with: go-version: 1.19.2 + - uses: technote-space/get-diff-action@v6.1.1 + id: git_diff + with: + PATTERNS: | + **/*.go + go.mod + go.sum + **/go.mod + **/go.sum + **/Makefile + Makefile - name: integration tests + if: env.GIT_DIFF run: | make test-integration-cov - uses: actions/upload-artifact@v3 + if: env.GIT_DIFF with: name: "${{ github.sha }}-integration-coverage" path: ./tests/integration-profile.out @@ -113,41 +139,70 @@ jobs: - uses: actions/setup-go@v3 with: go-version: 1.19.2 + - uses: technote-space/get-diff-action@v6.1.1 + id: git_diff + with: + PATTERNS: | + **/*.go + go.mod + go.sum + **/go.mod + **/go.sum + **/Makefile + Makefile - name: e2e tests + if: env.GIT_DIFF run: | make test-e2e-cov - uses: actions/upload-artifact@v3 + if: env.GIT_DIFF with: name: "${{ github.sha }}-e2e-coverage" path: ./tests/e2e-profile.out repo-analysis: runs-on: ubuntu-latest - needs: [tests, tests-integration, tests-e2e] + needs: [tests, test-integration, test-e2e] steps: - uses: actions/checkout@v3 with: fetch-depth: 0 + - uses: technote-space/get-diff-action@v6.1.1 + id: git_diff + with: + PATTERNS: | + **/*.go + go.mod + go.sum + **/go.mod + **/go.sum - uses: actions/download-artifact@v3 + if: env.GIT_DIFF with: name: "${{ github.sha }}-00-coverage" - uses: actions/download-artifact@v3 + if: env.GIT_DIFF with: name: "${{ github.sha }}-01-coverage" - uses: actions/download-artifact@v3 + if: env.GIT_DIFF with: name: "${{ github.sha }}-02-coverage" - uses: actions/download-artifact@v3 + if: env.GIT_DIFF with: name: "${{ github.sha }}-03-coverage" - uses: actions/download-artifact@v3 + if: env.GIT_DIFF with: name: "${{ github.sha }}-integration-coverage" - uses: actions/download-artifact@v3 + if: env.GIT_DIFF with: name: "${{ github.sha }}-e2e-coverage" continue-on-error: true - name: sonarcloud + if: env.GIT_DIFF uses: SonarSource/sonarcloud-github-action@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -161,10 +216,23 @@ jobs: - uses: actions/setup-go@v3 with: go-version: 1.19.2 + - uses: technote-space/get-diff-action@v6.1.1 + id: git_diff + with: + PATTERNS: | + **/*.go + go.mod + go.sum + **/go.mod + **/go.sum + **/Makefile + Makefile - name: start localnet + if: env.GIT_DIFF run: | make clean localnet-start - name: test liveness + if: env.GIT_DIFF run: | ./contrib/localnet_liveness.sh 100 5 50 localhost @@ -175,7 +243,19 @@ jobs: - uses: actions/setup-go@v3 with: go-version: 1.19.2 + - uses: technote-space/get-diff-action@v6.1.1 + id: git_diff + with: + PATTERNS: | + **/*.go + go.mod + go.sum + **/go.mod + **/go.sum + **/Makefile + Makefile - name: test-sim-nondeterminism + if: env.GIT_DIFF run: | make test-sim-nondeterminism @@ -410,6 +490,8 @@ jobs: tools/rosetta/**/*.go tools/rosetta/go.mod tools/rosetta/go.sum + tools/rosetta/Makefile + Makefile - name: tests if: env.GIT_DIFF run: |