Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update test.yml Github Action to report coverage to sonarcloud #8712

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,20 @@ jobs:
run: |
VERSION=$(echo $(git describe --tags) | sed 's/^v//') || VERSION=${GITHUB_SHA}
TESTS=$(cat pkgs.txt.part.${{ matrix.part }})
VERSION=$VERSION SKIP_WASM_WSL_TESTS="false" go test -race -mod=readonly -tags='ledger test_ledger_mock norace' $TESTS
VERSION=$VERSION SKIP_WASM_WSL_TESTS="false" go test -json -race -mod=readonly -tags='ledger test_ledger_mock norace' $TESTS
# re-run the tests to produce sonarcloud code coverage as covermode count is not compatible with -race option
- name: Code coverage report creation
run: |
VERSION=$(echo $(git describe --tags) | sed 's/^v//') || VERSION=${GITHUB_SHA}
TESTS=$(cat pkgs.txt.part.${{ matrix.part }})
VERSION=$VERSION SKIP_WASM_WSL_TESTS="false" go test -coverprofile=coverage.out -covermode=count -json -mod=readonly -tags='ledger test_ledger_mock norace' $TESTS > report.json;
- name: Archive code coverage results
uses: actions/upload-artifact@v4
with:
name: code-coverage-report
path: |
coverage.out
report.json

e2e:
needs: get_diff
Expand Down Expand Up @@ -155,3 +168,37 @@ jobs:
with:
name: logs.tgz
path: ./logs.tgz

sonarCloudTrigger:
needs: go
name: SonarCloud Trigger
runs-on: ubuntu-latest
steps:
- name: Clone Repository
uses: actions/checkout@master
with:
fetch-depth: 0
- name: Download code coverage results
uses: actions/download-artifact@v4
with:
name: code-coverage-report
#path: app
- name: Analyze with SonarCloud
uses: sonarsource/sonarcloud-github-action@master
with:
projectBaseDir: app
args: >
-Dsonar.projectKey=osmosis-labs-osmosis
-Dsonar.organization=osmosis-labs-polaris
-Dsonar.host.url=https://sonarcloud.io
-Dsonar.go.coverage.reportPaths=coverage.out
-Dsonar.go.tests.reportPaths=report.json
-Dsonar.sources=.
-Dsonar.tests=.
-Dsonar.test.inclusions=**/*_test.go,**/testdata/**
-Dsonar.language=go
-Dsonar.go.exclusions=**/vendor/**,**/*_mock.go
-Dsonar.coverage.exclusions=**/mock*/**,**/mock*.go,commands/debug.go
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Loading