chore: synchronize releases/v2.0.0
branch with main
branch
#4761
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
name: Unit Tests | |
on: | |
pull_request: | |
# Allow concurrent runs on main/release branches but isolates other branches | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }} | |
cancel-in-progress: ${{ ! (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')) }} | |
jobs: | |
unit-tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: "Check for Go-related changes" | |
id: check_nibiru_go | |
uses: dorny/paths-filter@v3 | |
with: | |
filters: | | |
nibiru-go: | |
- "app/**.go" | |
- "cmd/**.go" | |
- "eth/**.go" | |
- "gosdk/**.go" | |
- "x/**.go" | |
- "**.proto" | |
- "go.mod" | |
- "go.sum" | |
- "contrib/docker/*" | |
- name: skip-tests | |
if: steps.check_nibiru_go.outputs.nibiru-go == 'false' | |
run: | | |
echo "job: unit-tests was skipped since Nibiru Golang files were not changed." | |
- name: Set up Go | |
if: steps.check_nibiru_go.outputs.nibiru-go == 'true' | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.21 | |
cache: true | |
# Use GitHub actions output paramters to get go paths. For more info, see | |
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions | |
- name: "Set output variables for go cache" | |
if: steps.check_nibiru_go.outputs.nibiru-go == 'true' | |
id: go-cache-paths | |
run: | | |
echo "go-build-cache=$(go env GOCACHE)" >> $GITHUB_OUTPUT | |
echo "go-mod-cache=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT | |
- name: "Go build cache" | |
if: steps.check_nibiru_go.outputs.nibiru-go == 'true' | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.go-cache-paths.outputs.go-build-cache }} | |
key: go-build-cache-${{ hashFiles('**/go.sum') }} | |
- name: "Go mod cache" | |
if: steps.check_nibiru_go.outputs.nibiru-go == 'true' | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.go-cache-paths.outputs.go-mod-cache }} | |
key: go-mod-cache-${{ hashFiles('**/go.sum') }} | |
- name: Run all unit tests. | |
if: steps.check_nibiru_go.outputs.nibiru-go == 'true' | |
run: make test-unit | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: "Check for Go-related changes" | |
id: check_nibiru_go | |
uses: dorny/paths-filter@v3 | |
with: | |
filters: | | |
nibiru-go: | |
- "app/**.go" | |
- "cmd/**.go" | |
- "eth/**.go" | |
- "gosdk/**.go" | |
- "x/**.go" | |
- "**.proto" | |
- "go.mod" | |
- "go.sum" | |
- "contrib/docker/*" | |
- name: "Set up Go" | |
if: steps.check_nibiru_go.outputs.nibiru-go == 'true' | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.21 | |
- name: "Install just" | |
if: steps.check_nibiru_go.outputs.nibiru-go == 'true' | |
# casey/just: https://just.systems/man/en/chapter_6.html | |
# taiki-e/install-action: https://github.com/taiki-e/install-action | |
uses: taiki-e/install-action@just | |
- name: "Build the nibid binary" | |
if: steps.check_nibiru_go.outputs.nibiru-go == 'true' | |
run: | | |
just install | |
- name: "Run scripts/chaosnet.sh (Used in Docker image)" | |
if: steps.check_nibiru_go.outputs.nibiru-go == 'true' | |
run: | | |
just test-chaosnet | |
- name: "Run scripts/localnet.sh" | |
if: steps.check_nibiru_go.outputs.nibiru-go == 'true' | |
run: | | |
just test-localnet |