From 555d774c7313dbeb2d88fdf685c4248c74570a46 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Fri, 23 Sep 2022 18:33:38 +0200 Subject: [PATCH] ci: further improve gh actions (#13361) --- .github/labeler.yml | 1 - .../{check-docs.yml => build-docs.yml} | 17 ++-- .github/workflows/build-skip.yml | 17 ++++ .github/workflows/build.yml | 5 +- .github/workflows/dependencies-review.yml | 2 +- .github/workflows/lint.yml | 3 +- .github/workflows/proto-docker.yml | 13 ++- .github/workflows/release-sims.yml | 39 -------- .github/workflows/sims-045.yml | 14 +-- .github/workflows/sims-046.yml | 14 +-- .github/workflows/sims-nightly.yml | 89 +++++++++++++++++++ .github/workflows/sims.yml | 9 +- .github/workflows/test-e2e-skip.yml | 14 +++ .github/workflows/test-e2e.yml | 2 +- .github/workflows/test-integration-skip.yml | 14 +++ .github/workflows/test-integration.yml | 2 +- .github/workflows/test-legacy.yml | 6 +- .github/workflows/test.yml | 6 +- go.work.example | 1 - 19 files changed, 172 insertions(+), 96 deletions(-) rename .github/workflows/{check-docs.yml => build-docs.yml} (60%) create mode 100644 .github/workflows/build-skip.yml delete mode 100644 .github/workflows/release-sims.yml create mode 100644 .github/workflows/sims-nightly.yml create mode 100644 .github/workflows/test-e2e-skip.yml create mode 100644 .github/workflows/test-integration-skip.yml diff --git a/.github/labeler.yml b/.github/labeler.yml index e34b8d5eeb..fd9cd36895 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -60,6 +60,5 @@ - container/**/* "C:Store": - store/**/* - - db/**/* "C:orm": - orm/**/* diff --git a/.github/workflows/check-docs.yml b/.github/workflows/build-docs.yml similarity index 60% rename from .github/workflows/check-docs.yml rename to .github/workflows/build-docs.yml index 427257ecc0..05efa3cad6 100644 --- a/.github/workflows/check-docs.yml +++ b/.github/workflows/build-docs.yml @@ -1,11 +1,12 @@ -name: Check docs build +name: Build Docs # This workflow runs when a PR is labeled with `docs` -# This will check if the docs build successfully by running `npm run build` +# This will check if the docs build successfully by running `make build-docs` on: pull_request: - types: [ labeled ] - paths: - - "docs/**" + types: [labeled] + paths: + - "docs/**" + - "x/**/*.md" permissions: contents: read @@ -23,8 +24,6 @@ jobs: persist-credentials: false fetch-depth: 0 - - name: Install dependencies and build docs 🧱 + - name: Build docs run: | - cd docs - npm install - npm run build + make build-docs LEDGER_ENABLED=false diff --git a/.github/workflows/build-skip.yml b/.github/workflows/build-skip.yml new file mode 100644 index 0000000000..bbcd02f303 --- /dev/null +++ b/.github/workflows/build-skip.yml @@ -0,0 +1,17 @@ +name: Build SimApp +# This workflow allows to skip the build step if the PR does not contain any changes to the code +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 e2c39a00be..bf71da5a99 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,6 +9,7 @@ on: push: branches: - main + - release/** paths: - "**/*.go" - "go.mod" @@ -16,7 +17,9 @@ on: permissions: contents: read -concurrency: ci-${{ github.ref }} +concurrency: + group: ci-${{ github.ref }}-build + cancel-in-progress: true jobs: build: diff --git a/.github/workflows/dependencies-review.yml b/.github/workflows/dependencies-review.yml index d26f6f1671..28411dd5d2 100644 --- a/.github/workflows/dependencies-review.yml +++ b/.github/workflows/dependencies-review.yml @@ -1,5 +1,5 @@ name: "Dependency Review" -on: [pull_request] +on: pull_request permissions: contents: read diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a100013b2b..498b4dfdc5 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,10 +1,9 @@ name: Lint on: push: - tags: - - v* branches: - main + - release/** pull_request: permissions: contents: read diff --git a/.github/workflows/proto-docker.yml b/.github/workflows/proto-docker.yml index dd8316daef..840667882e 100644 --- a/.github/workflows/proto-docker.yml +++ b/.github/workflows/proto-docker.yml @@ -8,8 +8,8 @@ on: workflow_dispatch: inputs: tags: - description: 'Docker image tags' - required: true + description: "Docker image tags" + required: true type: string pull_request: paths: @@ -19,7 +19,7 @@ env: REGISTRY: ghcr.io IMAGE_NAME: cosmos/proto-builder - # Allow one concurrent deployment +# Allow one concurrent deployment concurrency: group: "proto-docker" cancel-in-progress: true @@ -36,7 +36,7 @@ jobs: - name: Set up QEMU uses: docker/setup-qemu-action@v2 - + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 @@ -47,16 +47,15 @@ jobs: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} # modify value when deploying a new version tags: | - type=semver,pattern={{version}},value=${{ inputs.tags }} + type=semver,pattern={{version}},value=${{ inputs.tags }} - name: Login to GitHub Container Registry - uses: docker/login-action@v2 + uses: docker/login-action@v2 if: ${{ github.event_name != 'pull_request' }} with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Publish to GHCR uses: docker/build-push-action@v3 diff --git a/.github/workflows/release-sims.yml b/.github/workflows/release-sims.yml deleted file mode 100644 index e5a0d32817..0000000000 --- a/.github/workflows/release-sims.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Release Sims -# Release Sims workflow runs long-lived (multi-seed & large block size) simulations -# This workflow only runs on a pull request when the branch contains rc** (rc1/vX.X.x) -on: - pull_request: - branches: - - "rc**" - -permissions: - contents: read - -jobs: - test-sim-multi-seed-long: - runs-on: buildjet-4vcpu-ubuntu-2004 - if: "!contains(github.event.head_commit.message, 'skip-sims')" - timeout-minutes: 60 - steps: - - uses: actions/checkout@v3 - - uses: actions/cache@v3 - with: - path: ~/go/bin - key: ${{ runner.os }}-go-runsim-binary - - 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') }} - - - run: | - make build - - - name: test-sim-multi-seed-long - run: | - make test-sim-multi-seed-long diff --git a/.github/workflows/sims-045.yml b/.github/workflows/sims-045.yml index b25e79db2e..56824aae7e 100644 --- a/.github/workflows/sims-045.yml +++ b/.github/workflows/sims-045.yml @@ -7,7 +7,9 @@ on: release: types: [published] -concurrency: ci-${{ github.ref }} +concurrency: + group: ci-${{ github.ref }}-sims-045 + cancel-in-progress: true jobs: build: @@ -20,8 +22,6 @@ jobs: - uses: actions/setup-go@v3 with: go-version: 1.18 - - name: Display go version - run: go version - run: make build install-runsim: @@ -33,8 +33,6 @@ jobs: - uses: actions/setup-go@v3 with: go-version: 1.18 - - name: Display go version - run: go version - name: Install runsim run: go install github.com/cosmos/tools/cmd/runsim@v1.0.0 - uses: actions/cache@v3 @@ -52,8 +50,6 @@ jobs: - uses: actions/setup-go@v3 with: go-version: 1.18 - - name: Display go version - run: go version - uses: actions/cache@v3 with: path: ~/go/bin @@ -72,8 +68,6 @@ jobs: - uses: actions/setup-go@v3 with: go-version: 1.18 - - name: Display go version - run: go version - uses: actions/cache@v3 with: path: ~/go/bin @@ -93,8 +87,6 @@ jobs: - uses: actions/setup-go@v3 with: go-version: 1.18 - - name: Display go version - run: go version - uses: actions/cache@v3 with: path: ~/go/bin diff --git a/.github/workflows/sims-046.yml b/.github/workflows/sims-046.yml index caf13d1e57..13665bdcec 100644 --- a/.github/workflows/sims-046.yml +++ b/.github/workflows/sims-046.yml @@ -7,7 +7,9 @@ on: release: types: [published] -concurrency: ci-${{ github.ref }} +concurrency: + group: ci-${{ github.ref }}-sims-046 + cancel-in-progress: true jobs: build: @@ -20,8 +22,6 @@ jobs: - uses: actions/setup-go@v3 with: go-version: 1.18 - - name: Display go version - run: go version - run: make build install-runsim: @@ -33,8 +33,6 @@ jobs: - uses: actions/setup-go@v3 with: go-version: 1.18 - - name: Display go version - run: go version - name: Install runsim run: go install github.com/cosmos/tools/cmd/runsim@v1.0.0 - uses: actions/cache@v3 @@ -53,8 +51,6 @@ jobs: - uses: actions/setup-go@v3 with: go-version: 1.18 - - name: Display go version - run: go version - uses: actions/cache@v3 with: path: ~/go/bin @@ -73,8 +69,6 @@ jobs: - uses: actions/setup-go@v3 with: go-version: 1.18 - - name: Display go version - run: go version - uses: actions/cache@v3 with: path: ~/go/bin @@ -93,8 +87,6 @@ jobs: - uses: actions/setup-go@v3 with: go-version: 1.18 - - name: Display go version - run: go version - uses: actions/cache@v3 with: path: ~/go/bin diff --git a/.github/workflows/sims-nightly.yml b/.github/workflows/sims-nightly.yml new file mode 100644 index 0000000000..20c6d5ea42 --- /dev/null +++ b/.github/workflows/sims-nightly.yml @@ -0,0 +1,89 @@ +name: Sims Nightly (Long) +# Release Sims workflow runs long-lived (multi-seed & large block size) simulations +# This workflow only runs mightly at 8am UTC and on releases +on: + schedule: + - cron: "0 8 * * *" + release: + types: [published] + +permissions: + contents: read + +concurrency: + group: ci-${{ github.ref }}-sims-nightly-long + cancel-in-progress: true + +jobs: + install-runsim: + permissions: + contents: none + runs-on: buildjet-4vcpu-ubuntu-2004 + steps: + - uses: actions/setup-go@v3 + with: + go-version: 1.18 + - 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 + + test-sim-multi-seed-long: + runs-on: buildjet-4vcpu-ubuntu-2004 + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: 1.18 + - uses: actions/cache@v3 + with: + path: ~/go/bin + key: ${{ runner.os }}-go-runsim-binary + - name: test-sim-multi-seed-long + run: | + make test-sim-multi-seed-long + + sims-notify-success: + needs: [test-sim-multi-seed-long] + runs-on: ubuntu-latest + if: ${{ success() }} + steps: + - name: Check out repository + uses: actions/checkout@v3 + - name: Get previous workflow status + uses: ./.github/actions/last-workflow-status + id: last_status + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Notify Slack on success + if: ${{ steps.last_status.outputs.last_status == 'failure' }} + uses: rtCamp/action-slack-notify@12e36fc18b0689399306c2e0b3e0f2978b7f1ee7 + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + SLACK_CHANNEL: cosmos-sdk-sims + SLACK_USERNAME: Sim Tests + SLACK_ICON_EMOJI: ":white_check_mark:" + SLACK_COLOR: good + SLACK_MESSAGE: Sims Nightly (Long) are passing + SLACK_FOOTER: "" + + sims-notify-failure: + permissions: + contents: none + needs: [test-sim-multi-seed-long] + runs-on: ubuntu-latest + if: ${{ failure() }} + steps: + - name: Notify Slack on failure + uses: rtCamp/action-slack-notify@12e36fc18b0689399306c2e0b3e0f2978b7f1ee7 + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + SLACK_CHANNEL: cosmos-sdk-sims + SLACK_USERNAME: Sim Tests + SLACK_ICON_EMOJI: ":skull:" + SLACK_COLOR: danger + SLACK_MESSAGE: Sims Nightly (Long) are failing + SLACK_FOOTER: "" diff --git a/.github/workflows/sims.yml b/.github/workflows/sims.yml index ea746fdaa9..1eff92a7da 100644 --- a/.github/workflows/sims.yml +++ b/.github/workflows/sims.yml @@ -7,7 +7,9 @@ on: release: types: [published] -concurrency: ci-${{ github.ref }} +concurrency: + group: ci-${{ github.ref }}-sims + cancel-in-progress: true jobs: build: @@ -21,8 +23,6 @@ jobs: - uses: actions/setup-go@v3 with: go-version: 1.18 - - name: Display go version - run: go version - uses: technote-space/get-diff-action@v6.1.0 with: PATTERNS: | @@ -30,7 +30,6 @@ jobs: go.mod go.sum - name: Get data from Go build cache - # if: env.GIT_DIFF if: ${{ false }} uses: actions/cache@v3 with: @@ -56,8 +55,6 @@ jobs: - uses: actions/setup-go@v3 with: go-version: 1.18 - - name: Display go version - run: go version - uses: actions/cache@v3 with: path: ~/go/bin diff --git a/.github/workflows/test-e2e-skip.yml b/.github/workflows/test-e2e-skip.yml new file mode 100644 index 0000000000..c4622f3dc5 --- /dev/null +++ b/.github/workflows/test-e2e-skip.yml @@ -0,0 +1,14 @@ +name: Tests E2E +# This workflow allows to skip the e2e step if the PR does not contain any changes to the code +on: + pull_request: + paths-ignore: + - "**/*.go" + - "go.mod" + - "go.sum" + +jobs: + test-e2e: + runs-on: ubuntu-latest + steps: + - run: 'echo "No e2e tests required"' diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index c4ce149449..d3ce076ecf 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -19,7 +19,7 @@ permissions: jobs: test-e2e: - runs-on: ubuntu-latest + runs-on: buildjet-4vcpu-ubuntu-2004 steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 diff --git a/.github/workflows/test-integration-skip.yml b/.github/workflows/test-integration-skip.yml new file mode 100644 index 0000000000..3c0fef3803 --- /dev/null +++ b/.github/workflows/test-integration-skip.yml @@ -0,0 +1,14 @@ +name: Tests Integration +# This workflow allows to skip the integration step if the PR does not contain any changes to the code +on: + pull_request: + paths-ignore: + - "**/*.go" + - "go.mod" + - "go.sum" + +jobs: + test-integration: + runs-on: ubuntu-latest + steps: + - run: 'echo "No integration tests required"' diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 025855b92f..f081677c21 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -19,7 +19,7 @@ permissions: jobs: test-integration: - runs-on: ubuntu-latest + runs-on: buildjet-4vcpu-ubuntu-2004 steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 diff --git a/.github/workflows/test-legacy.yml b/.github/workflows/test-legacy.yml index be55d76653..34cc74a3dd 100644 --- a/.github/workflows/test-legacy.yml +++ b/.github/workflows/test-legacy.yml @@ -1,11 +1,13 @@ -name: Legacy App Testing +name: Tests (Legacy App) on: schedule: - cron: "0 0,12 * * *" release: types: [published] -concurrency: ci-${{ github.ref }} +concurrency: + group: ci-${{ github.ref }}-tests-legacy + cancel-in-progress: true jobs: test-submodules: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b07cb69fec..ff8aacb70e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,9 @@ on: permissions: contents: read -concurrency: ci-${{ github.ref }} +concurrency: + group: ci-${{ github.ref }}-tests + cancel-in-progress: true jobs: test-submodules: @@ -237,8 +239,6 @@ jobs: - uses: actions/setup-go@v3 with: go-version: 1.18 - - name: Display go version - run: go version - uses: technote-space/get-diff-action@v6.1.0 with: PATTERNS: | diff --git a/go.work.example b/go.work.example index 38aac97a52..b1309636c0 100644 --- a/go.work.example +++ b/go.work.example @@ -6,7 +6,6 @@ use ( ./client/v2 ./core ./cosmovisor - ./db ./depinject ./errors ./math