From e1413cb698d7207b84b3d09e630ea8a13d2398b6 Mon Sep 17 00:00:00 2001 From: Robert Zaremba Date: Thu, 26 May 2022 21:59:04 +0200 Subject: [PATCH] chore: improve go module chache (#12057) --- .github/workflows/lint.yml | 23 ++---- .github/workflows/release-sims.yml | 35 ++++---- .github/workflows/sims.yml | 36 +++++---- .github/workflows/test-race.yml | 35 ++++---- .github/workflows/test.yml | 123 +++++++++++------------------ x/gov/abci.go | 3 +- 6 files changed, 106 insertions(+), 149 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 500efb41d5..1117ece8f5 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -22,28 +22,19 @@ jobs: **/**.go go.mod go.sum - - name: Get data from build cache + - name: Get data from Go build cache + if: env.GIT_DIFF uses: actions/cache@v3 with: - # In order: - # * Module download cache - # * Linter cache (Linux) - # * Build cache (Linux) - # * Build cache (Mac) - # * Build cache (Windows) path: | - ~/go/pkg/mod - ~/.cache/golangci-lint - ~/.cache/go-build - ~/Library/Caches/go-build - ~\AppData\Local\go-build - key: ${{ runner.os }}-go-linter-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go-linter-${{ matrix.go-version }}- + ~/go/pkg/mod + ~/.cache/golangci-lint + ~/.cache/go-build + key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} - name: golangci-lint + if: env.GIT_DIFF uses: golangci/golangci-lint-action@v3 with: version: latest args: --out-format=tab skip-go-installation: true - if: env.GIT_DIFF diff --git a/.github/workflows/release-sims.yml b/.github/workflows/release-sims.yml index 9df30442eb..625dee39c0 100644 --- a/.github/workflows/release-sims.yml +++ b/.github/workflows/release-sims.yml @@ -7,29 +7,9 @@ on: - "rc**" jobs: - build: - runs-on: ubuntu-latest - if: "!contains(github.event.head_commit.message, 'skip-sims')" - steps: - - uses: actions/checkout@v3 - - run: | - make build - - install-runsim: - runs-on: ubuntu-latest - needs: build - steps: - - name: install runsim - run: | - export GO111MODULE="on" && go get 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: ubuntu-latest - needs: [build, install-runsim] + if: "!contains(github.event.head_commit.message, 'skip-sims')" timeout-minutes: 60 steps: - uses: actions/checkout@v3 @@ -37,6 +17,19 @@ jobs: with: path: ~/go/bin key: ${{ runner.os }}-go-runsim-binary + - name: Get data from Go build cache + if: env.GIT_DIFF + 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.yml b/.github/workflows/sims.yml index 43e1d8d63a..1c778fcece 100644 --- a/.github/workflows/sims.yml +++ b/.github/workflows/sims.yml @@ -15,6 +15,7 @@ jobs: env: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'" + build: runs-on: ubuntu-latest if: "!contains(github.event.head_commit.message, 'skip-sims')" @@ -25,17 +26,22 @@ jobs: go-version: 1.18 - name: Display go version run: go version - - run: make build - - install-runsim: - runs-on: ubuntu-latest - needs: build - steps: - - uses: actions/setup-go@v3 + - uses: technote-space/get-diff-action@v6.0.1 with: - go-version: 1.18 - - name: Display go version - run: go version + PATTERNS: | + **/**.go + go.mod + go.sum + - name: Get data from Go build cache + if: env.GIT_DIFF + 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: Install runsim run: go install github.com/cosmos/tools/cmd/runsim@v1.0.0 - uses: actions/cache@v3 @@ -45,7 +51,7 @@ jobs: test-sim-import-export: runs-on: ubuntu-latest - needs: [build, install-runsim] + needs: [build] timeout-minutes: 60 steps: - uses: actions/checkout@v3 @@ -64,15 +70,13 @@ jobs: test-sim-after-import: runs-on: ubuntu-latest - needs: [build, install-runsim] + needs: [build] timeout-minutes: 60 steps: - uses: actions/checkout@v3 - 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 @@ -83,15 +87,13 @@ jobs: test-sim-multi-seed-short: runs-on: ubuntu-latest - needs: [build, install-runsim] + needs: [build] timeout-minutes: 60 steps: - uses: actions/checkout@v3 - 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-race.yml b/.github/workflows/test-race.yml index fa171970a6..76ef6baa53 100644 --- a/.github/workflows/test-race.yml +++ b/.github/workflows/test-race.yml @@ -48,10 +48,21 @@ jobs: **/**.go **/go.mod **/go.sum + - name: Get data from Go build cache + uses: actions/cache@v3 + if: env.GIT_DIFF + with: + path: | + ~/go/pkg/mod + ~/.cache/golangci-lint + ~/.cache/go-build + key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} - name: Build + if: env.GIT_DIFF run: GOARCH=${{ matrix.go-arch }} LEDGER_ENABLED=false make build - name: Build cosmovisor + if: env.GIT_DIFF run: GOARCH=${{ matrix.go-arch }} LEDGER_ENABLED=false make cosmovisor split-test-files: @@ -101,31 +112,25 @@ jobs: **/**.go go.mod go.sum - - name: Get data from build cache + - name: Get data from Go build cache uses: actions/cache@v3 + if: env.GIT_DIFF with: - # In order: - # * Module download cache - # * Build cache (Linux) - # * Build cache (Mac) - # * Build cache (Windows) path: | - ~/go/pkg/mod - ~/.cache/go-build - ~/Library/Caches/go-build - ~\AppData\Local\go-build - key: ${{ runner.os }}-go-race-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go-race-${{ matrix.go-version }}- + ~/go/pkg/mod + ~/.cache/golangci-lint + ~/.cache/go-build + key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} - uses: actions/download-artifact@v3 + if: env.GIT_DIFF with: name: "${{ github.sha }}-${{ matrix.part }}" - if: env.GIT_DIFF - name: test & coverage report creation + if: env.GIT_DIFF run: | xargs --arg-file=pkgs.txt.part.${{ matrix.part }} go test -mod=readonly -timeout 30m -race -tags='cgo ledger test_ledger_mock' - if: env.GIT_DIFF - uses: actions/upload-artifact@v3 + if: env.GIT_DIFF with: name: "${{ github.sha }}-${{ matrix.part }}-race-output" path: ./${{ matrix.part }}-race-output.txt diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1516d005bc..40e8ad6b2d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,12 +35,28 @@ jobs: **/**.go **/go.mod **/go.sum + - name: Get data from Go build cache + if: env.GIT_DIFF + 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 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 + test-submodules: runs-on: ubuntu-latest container: tendermintdev/docker-tm-db-testing @@ -56,6 +72,15 @@ jobs: **/**.go go.mod go.sum + - name: Get data from Go build cache + if: env.GIT_DIFF + uses: actions/cache@v3 + with: + path: | + ~/go/pkg/mod + ~/.cache/golangci-lint + ~/.cache/go-build + key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} - name: Run submodule tests and create test coverage profile. # GIT_DIFF is passed to the scripts run: bash scripts/module-tests.sh @@ -112,24 +137,15 @@ jobs: **/**.go go.mod go.sum - - name: Get data from build cache + - name: Get data from Go build cache + if: env.GIT_DIFF uses: actions/cache@v3 with: - # In order: - # * Module download cache - # * Linter cache (Linux) - # * Build cache (Linux) - # * Build cache (Mac) - # * Build cache (Windows) path: | - ~/go/pkg/mod - ~/.cache/golangci-lint - ~/.cache/go-build - ~/Library/Caches/go-build - ~\AppData\Local\go-build - key: ${{ runner.os }}-go-linter-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go-linter-${{ matrix.go-version }}- + ~/go/pkg/mod + ~/.cache/golangci-lint + ~/.cache/go-build + key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} - uses: actions/download-artifact@v3 with: name: "${{ github.sha }}-${{ matrix.part }}" @@ -207,23 +223,15 @@ jobs: **/**.go go.mod go.sum - - name: Get data from build cache + - name: Get data from Go build cache + if: env.GIT_DIFF uses: actions/cache@v3 with: - # In order: - # * Module download cache - # * Build cache (Linux) - # * Build cache (Mac) - # * Build cache (Windows) path: | - ~/go/pkg/mod - ~/.cache/golangci-lint - ~/.cache/go-build - ~/Library/Caches/go-build - ~\AppData\Local\go-build - key: ${{ runner.os }}-go-rosetta-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go-rosetta-${{ matrix.go-version }}- + ~/go/pkg/mod + ~/.cache/golangci-lint + ~/.cache/go-build + key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} - name: test rosetta run: | make test-rosetta @@ -244,22 +252,15 @@ jobs: **/**.go go.mod go.sum - - name: Get data from build cache + - name: Get data from Go build cache + if: env.GIT_DIFF uses: actions/cache@v3 with: - # In order: - # * Module download cache - # * Build cache (Linux) - # * Build cache (Mac) - # * Build cache (Windows) path: | - ~/go/pkg/mod - ~/.cache/go-build - ~/Library/Caches/go-build - ~\AppData\Local\go-build - key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go-${{ matrix.go-version }}- + ~/go/pkg/mod + ~/.cache/golangci-lint + ~/.cache/go-build + key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} - name: start localnet run: | make clean localnet-start @@ -269,25 +270,9 @@ jobs: ./contrib/localnet_liveness.sh 100 5 50 localhost if: env.GIT_DIFF - install-runsim: - runs-on: ubuntu-latest - needs: build - steps: - - 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 - with: - path: ~/go/bin - key: ${{ runner.os }}-go-runsim-binary - test-sim-nondeterminism: runs-on: ubuntu-latest - needs: [build, install-runsim] + needs: [build] steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 @@ -301,26 +286,6 @@ jobs: **/**.go go.mod go.sum - - name: Get data from build cache - uses: actions/cache@v3 - with: - # In order: - # * Module download cache - # * Build cache (Linux) - # * Build cache (Mac) - # * Build cache (Windows) - path: | - ~/go/pkg/mod - ~/.cache/go-build - ~/Library/Caches/go-build - ~\AppData\Local\go-build - key: ${{ runner.os }}-go-sim-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go-sim-${{ matrix.go-version }}- - - uses: actions/cache@v3 - with: - path: ~/go/bin - key: ${{ runner.os }}-go-runsim-binary if: env.GIT_DIFF - name: test-sim-nondeterminism run: | diff --git a/x/gov/abci.go b/x/gov/abci.go index 9f97cba47b..b712053756 100644 --- a/x/gov/abci.go +++ b/x/gov/abci.go @@ -17,7 +17,8 @@ func EndBlocker(ctx sdk.Context, keeper keeper.Keeper) { logger := keeper.Logger(ctx) - // delete dead proposals from store and returns theirs deposits. A proposal is dead when it's inactive and didn't get enough deposit on time to get into voting phase. + // delete dead proposals from store and returns theirs deposits. + // A proposal is dead when it's inactive and didn't get enough deposit on time to get into voting phase. keeper.IterateInactiveProposalsQueue(ctx, ctx.BlockHeader().Time, func(proposal v1.Proposal) bool { keeper.DeleteProposal(ctx, proposal.Id) keeper.RefundAndDeleteDeposits(ctx, proposal.Id) // refund deposit if proposal got removed without getting 100% of the proposal