-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #110 from b-harvest/simulation-cicd
feat: CI/CD workflow and Cosmos-sdk simulation
- Loading branch information
Showing
20 changed files
with
1,110 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# To validate: | ||
# cat codecov.yml | curl --data-binary @- https://codecov.io/validate | ||
|
||
codecov: | ||
notify: | ||
require_ci_to_pass: yes | ||
|
||
coverage: | ||
precision: 2 | ||
round: down | ||
range: "50...80" | ||
|
||
status: | ||
project: | ||
default: | ||
target: auto | ||
threshold: 1% | ||
patch: | ||
default: | ||
enabled: no # disable patch since it is noisy and not correct | ||
if_not_found: success | ||
|
||
comment: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Build Canto Core | ||
# 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 | ||
- release/** | ||
- upgrade/** | ||
permissions: | ||
contents: read | ||
|
||
concurrency: | ||
group: ci-${{ github.ref }}-build | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
go-arch: ["amd64"] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: "^1.18" | ||
- uses: technote-space/get-diff-action@v6.1.2 | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
name: Sims | ||
# Sims workflow runs multiple types of simulations (nondeterminism, import-export, after-import) | ||
# This workflow will run on all Pull Requests, if a .go, .mod or .sum file have been changed | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
- release/** | ||
- upgrade/** | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
if: "!contains(github.event.head_commit.message, 'skip-sims')" | ||
steps: | ||
- uses: actions/checkout@v3.5.2 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: 1.18 | ||
- name: Install runsim | ||
run: go install github.com/cosmos/tools/cmd/runsim@v1.0.0 | ||
- name: Display go version | ||
run: go version | ||
- run: make build | ||
|
||
test-sim-nondeterminism: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- uses: actions/checkout@v3.5.2 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: 1.18 | ||
- name: Display go version | ||
run: go version | ||
- uses: technote-space/get-diff-action@v4 | ||
with: | ||
PATTERNS: | | ||
**/**.go | ||
go.mod | ||
go.sum | ||
- uses: actions/cache@v3.3.1 | ||
with: | ||
path: ~/go/bin | ||
key: ${{ runner.os }}-go-runsim-binary | ||
if: env.GIT_DIFF | ||
- name: test-sim-nondeterminism | ||
run: | | ||
make test-sim-nondeterminism | ||
if: env.GIT_DIFF | ||
|
||
install-runsim: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: Install runsim | ||
run: go install github.com/cosmos/tools/cmd/runsim@v1.0.0 | ||
- uses: actions/cache@v3.3.1 | ||
with: | ||
path: ~/go/bin | ||
key: ${{ runner.os }}-go-runsim-binary | ||
|
||
test-sim-import-export: | ||
runs-on: ubuntu-latest | ||
needs: [build, install-runsim] | ||
steps: | ||
- uses: actions/checkout@v3.5.2 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: 1.18 | ||
- name: Display go version | ||
run: go version | ||
- uses: technote-space/get-diff-action@v4 | ||
with: | ||
SUFFIX_FILTER: | | ||
**/**.go | ||
go.mod | ||
go.sum | ||
SET_ENV_NAME_INSERTIONS: 1 | ||
SET_ENV_NAME_LINES: 1 | ||
- uses: actions/cache@v3.3.1 | ||
with: | ||
path: ~/go/bin | ||
key: ${{ runner.os }}-go-runsim-binary | ||
if: env.GIT_DIFF | ||
- name: test-sim-import-export | ||
run: | | ||
make test-sim-import-export | ||
if: env.GIT_DIFF | ||
|
||
test-sim-after-import: | ||
runs-on: ubuntu-latest | ||
needs: [build, install-runsim] | ||
steps: | ||
- uses: actions/checkout@v3.5.2 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: 1.18 | ||
- name: Display go version | ||
run: go version | ||
- uses: technote-space/get-diff-action@v4 | ||
with: | ||
SUFFIX_FILTER: | | ||
**/**.go | ||
go.mod | ||
go.sum | ||
SET_ENV_NAME_INSERTIONS: 1 | ||
SET_ENV_NAME_LINES: 1 | ||
- uses: actions/cache@v3.3.1 | ||
with: | ||
path: ~/go/bin | ||
key: ${{ runner.os }}-go-runsim-binary | ||
if: env.GIT_DIFF | ||
- name: test-sim-after-import | ||
run: | | ||
make test-sim-after-import | ||
if: env.GIT_DIFF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Tests / Code Coverage | ||
# Tests / Code Coverage workflow runs unit tests and uploads a code coverage report | ||
# 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 | ||
- release/** | ||
- upgrade/** | ||
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'" | ||
|
||
test-coverage: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.18 | ||
- name: display go version | ||
run: go version | ||
- name: test & coverage report creation | ||
run: make test-unit-cover | ||
- name: filter out DONTCOVER | ||
run: | | ||
excludelist="$(find ./ -type f -name '*.go' | xargs grep -l 'DONTCOVER')" | ||
excludelist+=" $(find ./ -type f -name '*.pb.go')" | ||
excludelist+=" $(find ./ -type f -name '*.pb.gw.go')" | ||
excludelist+=" $(find ./ -type f -path './tests/mocks/*.go')" | ||
for filename in ${excludelist}; do | ||
filename=$(echo $filename | sed 's/^./github.com\/Canto-Network\/Canto\/v6/g') | ||
echo "Excluding ${filename} from coverage report..." | ||
sed -i "/$(echo $filename | sed 's/\//\\\//g')/d" coverage.txt | ||
done | ||
- uses: codecov/codecov-action@v2.1.0 | ||
with: | ||
file: ./coverage.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,7 @@ | |
.testnets | ||
.bencher | ||
DS_Store | ||
node_modules | ||
.idea | ||
coverage.txt | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.