ci: improve github actions (#13358)

* ci: improve github actions

* updates

* revert title change

* updates

* implement feedback

* Update go.mod

Co-authored-by: Marko <marbar3778@yahoo.com>
This commit is contained in:
Julien Robert 2022-09-22 00:57:19 +02:00 committed by GitHub
parent 7eb259fd86
commit c297caa697
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 143 additions and 188 deletions

38
.github/workflows/build.yml vendored Normal file
View File

@ -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

View File

@ -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"

View File

@ -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'

View File

@ -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'

View File

@ -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:

View File

@ -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')"

View File

@ -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')"

View File

@ -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

30
.github/workflows/test-e2e.yml vendored Normal file
View File

@ -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

30
.github/workflows/test-integration.yml vendored Normal file
View File

@ -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

View File

@ -5,37 +5,9 @@ on:
release:
types: [published]
concurrency: ci-${{ github.ref }}
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
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:

View File

@ -10,56 +10,9 @@ on:
permissions:
contents: read
concurrency: ci-${{ github.ref }}
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
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

View File

@ -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

5
tests/Makefile Normal file
View File

@ -0,0 +1,5 @@
test-integration:
go test ./integration/... -timeout 30m
test-e2e:
go test ./e2e/... -mod=readonly -timeout 30m -race -tags='e2e'