From c297caa6973adbf3ec067c6232e270c9b4b99f5c Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 22 Sep 2022 00:57:19 +0200 Subject: [PATCH] ci: improve github actions (#13358) * ci: improve github actions * updates * revert title change * updates * implement feedback * Update go.mod Co-authored-by: Marko --- .github/workflows/build.yml | 38 ++++++++++++++ .github/workflows/clean-action-artifacts.yml | 17 ++++++ .github/workflows/clean-artifacts.yml | 17 ------ .github/workflows/e2e.yml | 51 ------------------ .github/workflows/gosec.yml | 12 ++--- .../{linkchecker.yml => md-link-checker.yml} | 0 .github/workflows/sims-045.yml | 12 +---- .github/workflows/sims-046.yml | 12 +---- .github/workflows/sims.yml | 13 +---- .github/workflows/test-e2e.yml | 30 +++++++++++ .github/workflows/test-integration.yml | 30 +++++++++++ .../{legacy-test.yml => test-legacy.yml} | 36 ++----------- .github/workflows/test.yml | 52 +------------------ Makefile | 6 ++- tests/Makefile | 5 ++ 15 files changed, 143 insertions(+), 188 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/clean-action-artifacts.yml delete mode 100644 .github/workflows/clean-artifacts.yml delete mode 100644 .github/workflows/e2e.yml rename .github/workflows/{linkchecker.yml => md-link-checker.yml} (100%) create mode 100644 .github/workflows/test-e2e.yml create mode 100644 .github/workflows/test-integration.yml rename .github/workflows/{legacy-test.yml => test-legacy.yml} (79%) create mode 100644 tests/Makefile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000000..e2c39a00be57 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,38 @@ +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 + paths: + - "**/*.go" + - "go.mod" + - "go.sum" +permissions: + contents: read + +concurrency: ci-${{ github.ref }} + +jobs: + build: + runs-on: buildjet-4vcpu-ubuntu-2004 + strategy: + matrix: + go-arch: ["amd64", "arm", "arm64"] + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: 1.18 + - name: Build + run: GOARCH=${{ matrix.go-arch }} LEDGER_ENABLED=false make build + - name: Build Legacy + run: GOARCH=${{ matrix.go-arch }} LEDGER_ENABLED=false COSMOS_BUILD_OPTIONS=legacy make build + + - name: Build Cosmovisor + run: GOARCH=${{ matrix.go-arch }} LEDGER_ENABLED=false make cosmovisor diff --git a/.github/workflows/clean-action-artifacts.yml b/.github/workflows/clean-action-artifacts.yml new file mode 100644 index 000000000000..b84b15d4bbd3 --- /dev/null +++ b/.github/workflows/clean-action-artifacts.yml @@ -0,0 +1,17 @@ +name: Remove GitHub Action Old Artifacts + +on: + schedule: + # Every day at 1am + - cron: "0 1 * * *" + +jobs: + remove-old-artifacts: + runs-on: ubuntu-latest + timeout-minutes: 30 + + steps: + - name: Remove old artifacts + uses: c-hive/gha-remove-artifacts@v1 + with: + age: "7 days" diff --git a/.github/workflows/clean-artifacts.yml b/.github/workflows/clean-artifacts.yml deleted file mode 100644 index edebe53a8dad..000000000000 --- a/.github/workflows/clean-artifacts.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Remove old artifacts - -on: - schedule: - # Every day at 1am - - cron: '0 1 * * *' - -jobs: - remove-old-artifacts: - runs-on: ubuntu-latest - timeout-minutes: 10 - - steps: - - name: Remove old artifacts - uses: c-hive/gha-remove-artifacts@v1 - with: - age: '7 days' diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml deleted file mode 100644 index 6598e00166c6..000000000000 --- a/.github/workflows/e2e.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: Tests E2E -# Tests Race workflow runs unit tests with the race detector -# This workflow is run on pushes to main & every Pull Requests where a .go, .mod, .sum have been changed -on: - pull_request: - push: - branches: - - main - -permissions: - contents: read - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 - with: - go-version: 1.18 - - uses: technote-space/get-diff-action@v6.1.0 - id: git_diff - with: - PATTERNS: | - **/**.go - **/go.mod - **/go.sum - key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} - - name: Build - if: env.GIT_DIFF - run: GOARCH=${{ matrix.go-arch }} LEDGER_ENABLED=false make build - - - test-e2e: - runs-on: ubuntu-latest - needs: build - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 - with: - go-version: 1.18 - - uses: technote-space/get-diff-action@v6.1.0 - with: - PATTERNS: | - **/**.go - go.mod - go.sum - - name: e2e tests - if: env.GIT_DIFF - run: | - cd tests/e2e && go test ./... -mod=readonly -timeout 30m -race -tags='e2e' diff --git a/.github/workflows/gosec.yml b/.github/workflows/gosec.yml index 8d85c3eac251..935432808b8e 100644 --- a/.github/workflows/gosec.yml +++ b/.github/workflows/gosec.yml @@ -2,16 +2,16 @@ name: Run Gosec on: pull_request: paths: - - '**/*.go' - - 'go.mod' - - 'go.sum' + - "**/*.go" + - "go.mod" + - "go.sum" push: branches: - main paths: - - '**/*.go' - - 'go.mod' - - 'go.sum' + - "**/*.go" + - "go.mod" + - "go.sum" jobs: Gosec: diff --git a/.github/workflows/linkchecker.yml b/.github/workflows/md-link-checker.yml similarity index 100% rename from .github/workflows/linkchecker.yml rename to .github/workflows/md-link-checker.yml diff --git a/.github/workflows/sims-045.yml b/.github/workflows/sims-045.yml index 6b6920d6e0e3..b25e79db2e3c 100644 --- a/.github/workflows/sims-045.yml +++ b/.github/workflows/sims-045.yml @@ -7,17 +7,9 @@ on: release: types: [published] +concurrency: ci-${{ github.ref }} + jobs: - cleanup-runs: - permissions: - actions: write # for rokroskar/workflow-run-cleanup-action to obtain workflow name & cancel it - contents: read # for rokroskar/workflow-run-cleanup-action to obtain branch - runs-on: buildjet-4vcpu-ubuntu-2004 - steps: - - uses: rokroskar/workflow-run-cleanup-action@master - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'" build: runs-on: buildjet-4vcpu-ubuntu-2004 if: "!contains(github.event.head_commit.message, 'skip-sims')" diff --git a/.github/workflows/sims-046.yml b/.github/workflows/sims-046.yml index 106716859ed7..caf13d1e5797 100644 --- a/.github/workflows/sims-046.yml +++ b/.github/workflows/sims-046.yml @@ -7,17 +7,9 @@ on: release: types: [published] +concurrency: ci-${{ github.ref }} + jobs: - cleanup-runs: - permissions: - actions: write # for rokroskar/workflow-run-cleanup-action to obtain workflow name & cancel it - contents: read # for rokroskar/workflow-run-cleanup-action to obtain branch - runs-on: buildjet-4vcpu-ubuntu-2004 - steps: - - uses: rokroskar/workflow-run-cleanup-action@master - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'" build: runs-on: buildjet-4vcpu-ubuntu-2004 if: "!contains(github.event.head_commit.message, 'skip-sims')" diff --git a/.github/workflows/sims.yml b/.github/workflows/sims.yml index 3f1584b23d27..ea746fdaa993 100644 --- a/.github/workflows/sims.yml +++ b/.github/workflows/sims.yml @@ -7,18 +7,9 @@ on: release: types: [published] -jobs: - cleanup-runs: - permissions: - actions: write # for rokroskar/workflow-run-cleanup-action to obtain workflow name & cancel it - contents: read # for rokroskar/workflow-run-cleanup-action to obtain branch - runs-on: buildjet-4vcpu-ubuntu-2004 - steps: - - uses: rokroskar/workflow-run-cleanup-action@master - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'" +concurrency: ci-${{ github.ref }} +jobs: build: permissions: contents: read # for actions/checkout to fetch code diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml new file mode 100644 index 000000000000..c4ce14944941 --- /dev/null +++ b/.github/workflows/test-e2e.yml @@ -0,0 +1,30 @@ +name: Tests E2E +# 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 + paths: + - "**/*.go" + - "go.mod" + - "go.sum" + +permissions: + contents: read + +jobs: + test-e2e: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: 1.18 + - name: e2e tests + run: | + make test-e2e diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml new file mode 100644 index 000000000000..025855b92fbd --- /dev/null +++ b/.github/workflows/test-integration.yml @@ -0,0 +1,30 @@ +name: Tests Integration +# 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 + paths: + - "**/*.go" + - "go.mod" + - "go.sum" + +permissions: + contents: read + +jobs: + test-integration: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: 1.18 + - name: integration tests + run: | + make test-integration diff --git a/.github/workflows/legacy-test.yml b/.github/workflows/test-legacy.yml similarity index 79% rename from .github/workflows/legacy-test.yml rename to .github/workflows/test-legacy.yml index f3b859f5fe32..be55d7665357 100644 --- a/.github/workflows/legacy-test.yml +++ b/.github/workflows/test-legacy.yml @@ -5,37 +5,9 @@ on: release: types: [published] -jobs: - cleanup-runs: - runs-on: ubuntu-latest - steps: - - uses: rokroskar/workflow-run-cleanup-action@master - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'" - build: - runs-on: ubuntu-latest - strategy: - matrix: - go-arch: ["amd64", "arm", "arm64"] - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 - with: - go-version: 1.18 - - name: Build - run: GOARCH=${{ matrix.go-arch }} LEDGER_ENABLED=false make build - - - name: Build cosmovisor - run: GOARCH=${{ matrix.go-arch }} LEDGER_ENABLED=false make cosmovisor - - - name: Install runsim - run: go install github.com/cosmos/tools/cmd/runsim@v1.0.0 - - uses: actions/cache@v3 - with: - path: ~/go/bin - key: ${{ runner.os }}-go-runsim-binary +concurrency: ci-${{ github.ref }} +jobs: test-submodules: runs-on: ubuntu-latest container: tendermintdev/docker-tm-db-testing @@ -104,7 +76,7 @@ jobs: path: ./${{ matrix.part }}profile.out sims-notify-success: - needs: [tests] + needs: tests runs-on: ubuntu-latest if: ${{ success() }} steps: @@ -130,7 +102,7 @@ jobs: SLACK_FOOTER: "" sims-notify-failure: - needs: [tests] + needs: tests runs-on: ubuntu-latest if: ${{ failure() }} steps: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c1a26183a0c9..b07cb69fecd0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,56 +10,9 @@ on: permissions: contents: read -jobs: - cleanup-runs: - runs-on: buildjet-4vcpu-ubuntu-2004 - steps: - - uses: rokroskar/workflow-run-cleanup-action@master - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'" - build: - runs-on: buildjet-4vcpu-ubuntu-2004 - strategy: - matrix: - go-arch: ["amd64", "arm", "arm64"] - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 - with: - go-version: 1.18 - - uses: technote-space/get-diff-action@v6.1.0 - id: git_diff - with: - PATTERNS: | - **/**.go - **/go.mod - **/go.sum - - name: Get data from Go build cache - # if: env.GIT_DIFF - if: ${{ false }} - uses: actions/cache@v3 - with: - path: | - ~/go/pkg/mod - ~/.cache/golangci-lint - ~/.cache/go-build - key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} - - name: Build - run: GOARCH=${{ matrix.go-arch }} LEDGER_ENABLED=false make build - - name: Build Legacy - run: GOARCH=${{ matrix.go-arch }} LEDGER_ENABLED=false COSMOS_BUILD_OPTIONS=legacy make build - - - name: Build cosmovisor - run: GOARCH=${{ matrix.go-arch }} LEDGER_ENABLED=false make cosmovisor - - - name: Install runsim - run: go install github.com/cosmos/tools/cmd/runsim@v1.0.0 - - uses: actions/cache@v3 - with: - path: ~/go/bin - key: ${{ runner.os }}-go-runsim-binary +concurrency: ci-${{ github.ref }} +jobs: test-submodules: runs-on: buildjet-4vcpu-ubuntu-2004 container: tendermintdev/docker-tm-db-testing @@ -279,7 +232,6 @@ jobs: test-sim-nondeterminism: runs-on: buildjet-4vcpu-ubuntu-2004 - needs: [build] steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 diff --git a/Makefile b/Makefile index 6f0a3c81290f..249e00d3bc75 100644 --- a/Makefile +++ b/Makefile @@ -210,7 +210,11 @@ build-docs: ############################################################################### test: test-unit -test-all: test-unit test-ledger-mock test-race test-cover +test-e2e: + make -C tests test-e2e +test-integration: + make -C tests test-integration +test-all: test-unit test-e2e test-integration test-ledger-mock test-race test-cover TEST_PACKAGES=./... TEST_TARGETS := test-unit test-unit-amino test-unit-proto test-ledger-mock test-race test-ledger test-race diff --git a/tests/Makefile b/tests/Makefile new file mode 100644 index 000000000000..2aff22faa9a2 --- /dev/null +++ b/tests/Makefile @@ -0,0 +1,5 @@ +test-integration: + go test ./integration/... -timeout 30m + +test-e2e: + go test ./e2e/... -mod=readonly -timeout 30m -race -tags='e2e'