Skip to content

ci: enable sonar analysis #3669

ci: enable sonar analysis

ci: enable sonar analysis #3669

Workflow file for this run

name: Tests / Code Coverage
on:
pull_request:
merge_group:
push:
branches:
- main
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}-tests
cancel-in-progress: true
jobs:
split-test-files:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: "1.21"
check-latest: true
- name: Create a file with all core Cosmos SDK pkgs
run: go list ./... > pkgs.txt
- name: Split pkgs into 4 files
run: split -d -n l/4 pkgs.txt pkgs.txt.part.
- uses: actions/upload-artifact@v3
with:
name: "${{ github.sha }}-00"
path: ./pkgs.txt.part.00
- uses: actions/upload-artifact@v3
with:
name: "${{ github.sha }}-01"
path: ./pkgs.txt.part.01
- uses: actions/upload-artifact@v3
with:
name: "${{ github.sha }}-02"
path: ./pkgs.txt.part.02
- uses: actions/upload-artifact@v3
with:
name: "${{ github.sha }}-03"
path: ./pkgs.txt.part.03
tests:
runs-on: ubuntu-latest
needs: split-test-files
strategy:
fail-fast: false
matrix:
part: ["00", "01", "02", "03"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: "1.21"
check-latest: true
cache: true
cache-dependency-path: go.sum
- uses: technote-space/[email protected]
id: git_diff
with:
PATTERNS: |
**/*.go
go.mod
go.sum
**/go.mod
**/go.sum
**/Makefile
Makefile
- uses: actions/download-artifact@v3
with:
name: "${{ github.sha }}-${{ matrix.part }}"
- name: test & coverage report creation
if: env.GIT_DIFF
run: |
cat pkgs.txt.part.${{ matrix.part }} | xargs go test -mod=readonly -race -timeout 30m -coverprofile=${{ matrix.part }}profile.out -covermode=atomic -tags='ledger test_ledger_mock'
- uses: actions/upload-artifact@v3
if: env.GIT_DIFF
with:
name: "${{ github.sha }}-${{ matrix.part }}-coverage"
path: ./${{ matrix.part }}profile.out
# test-integration:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-go@v4
# with:
# go-version: "1.21"
# check-latest: true
# cache: true
# cache-dependency-path: go.sum
# - uses: technote-space/[email protected]
# id: git_diff
# with:
# PATTERNS: |
# **/*.go
# go.mod
# go.sum
# **/go.mod
# **/go.sum
# **/Makefile
# Makefile
# - name: integration tests
# if: env.GIT_DIFF
# run: |
# make test-integration-cov
# - uses: actions/upload-artifact@v3
# if: env.GIT_DIFF
# with:
# name: "${{ github.sha }}-integration-coverage"
# path: ./tests/integration-profile.out
test-e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: "1.21"
check-latest: true
cache: true
cache-dependency-path: go.sum
- uses: technote-space/[email protected]
id: git_diff
with:
PATTERNS: |
**/*.go
go.mod
go.sum
**/go.mod
**/go.sum
**/Makefile
Makefile
- name: e2e tests
if: env.GIT_DIFF
run: |
make test-e2e-cov
- uses: actions/upload-artifact@v3
if: env.GIT_DIFF
with:
name: "${{ github.sha }}-e2e-coverage"
path: ./tests/e2e-profile.out
repo-analysis:
runs-on: ubuntu-latest
# needs: [tests, test-integration, test-e2e]
needs: [tests, test-e2e]
steps:
- uses: actions/checkout@v3
- uses: technote-space/[email protected]
id: git_diff
with:
PATTERNS: |
**/*.go
go.mod
go.sum
**/go.mod
**/go.sum
- uses: actions/download-artifact@v3
if: env.GIT_DIFF
with:
name: "${{ github.sha }}-00-coverage"
- uses: actions/download-artifact@v3
if: env.GIT_DIFF
with:
name: "${{ github.sha }}-01-coverage"
- uses: actions/download-artifact@v3
if: env.GIT_DIFF
with:
name: "${{ github.sha }}-02-coverage"
- uses: actions/download-artifact@v3
if: env.GIT_DIFF
with:
name: "${{ github.sha }}-03-coverage"
# - uses: actions/download-artifact@v3
# if: env.GIT_DIFF
# with:
# name: "${{ github.sha }}-integration-coverage"
- uses: actions/download-artifact@v3
if: env.GIT_DIFF
with:
name: "${{ github.sha }}-e2e-coverage"
continue-on-error: true
- name: sonarcloud
if: ${{ env.GIT_DIFF && !github.event.pull_request.draft }}
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
liveness-test:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: "1.21"
check-latest: true
cache: true
cache-dependency-path: go.sum
- uses: technote-space/[email protected]
id: git_diff
with:
PATTERNS: |
**/*.go
go.mod
go.sum
**/go.mod
**/go.sum
**/Makefile
Makefile
- name: start localnet
if: env.GIT_DIFF
run: |
make clean localnet-start
- name: test liveness
if: env.GIT_DIFF
run: |
./contrib/localnet_liveness.sh 100 5 50 localhost
test-sim-nondeterminism:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: "1.21"
check-latest: true
cache: true
cache-dependency-path: go.sum
- uses: technote-space/[email protected]
id: git_diff
with:
PATTERNS: |
**/*.go
go.mod
go.sum
**/go.mod
**/go.sum
**/Makefile
Makefile
- name: test-sim-nondeterminism
if: env.GIT_DIFF
run: |
make test-sim-nondeterminism
#################################
#### Finschia SDK Submodules ####
#################################
# NOTE: The following jobs are used to test the Finschia SDK Go submodules.
# They run when there is a diff in their respective directories.
test-simapp:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: "1.21"
check-latest: true
cache: true
cache-dependency-path: simapp/go.sum
- uses: technote-space/[email protected]
id: git_diff
with:
PATTERNS: |
**/*.go
simapp/go.mod
simapp/go.sum
- name: tests simapp
if: env.GIT_DIFF
run: |
cd simapp
go test -mod=readonly -timeout 30m -coverprofile=coverage.out -covermode=atomic -tags='norace ledger test_ledger_mock rocksdb_build' ./...
- name: sonarcloud
if: ${{ env.GIT_DIFF && !github.event.pull_request.draft }}
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: simapp/
###############################
### Finschia SDK x/{module} ###
###############################
# NOTE: The following jobs are used to test the Finschia SDK Go submodules present under x/{module}.
# They run when there is a diff in their respective directories.
test-x-foundation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: "1.21"
check-latest: true
cache: true
cache-dependency-path: x/foundation/go.sum
- uses: technote-space/[email protected]
id: git_diff
with:
PATTERNS: |
x/foundation/**/*.go
x/foundation/go.mod
x/foundation/go.sum
- name: tests
if: env.GIT_DIFF
run: |
cd x/foundation
go test -mod=readonly -timeout 30m -coverprofile=coverage.out -covermode=atomic -tags='norace ledger test_ledger_mock rocksdb_build' ./...
- name: sonarcloud
if: ${{ env.GIT_DIFF && !github.event.pull_request.draft }}
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: x/foundation/