Skip to content

Commit

Permalink
ci: replace codecov with sonarcloud (#5931)
Browse files Browse the repository at this point in the history
* ci: replace codecov with sonarcloud

* simplify for now repo analysis step by not considering coverage by e2e tests

* Apply suggestions from code review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
Carlos Rodriguez and coderabbitai[bot] authored Mar 8, 2024
1 parent 3f7320c commit 9095690
Show file tree
Hide file tree
Showing 12 changed files with 107 additions and 87 deletions.
57 changes: 0 additions & 57 deletions .codecov.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ write a little note why.
- [ ] Provide a [conventional commit message](https://github.com/cosmos/ibc-go/blob/main/docs/dev/pull-requests.md#commit-messages) to follow the repository standards.
- [ ] Include a descriptive changelog entry when appropriate. This may be left to the discretion of the PR reviewers. (e.g. chores should be omitted from changelog)
- [ ] Re-reviewed `Files changed` in the GitHub PR explorer.
- [ ] Review `Codecov Report` in the comment section below once CI passes.
- [ ] Review `SonarCloud Report` in the comment section below once CI passes.
8 changes: 8 additions & 0 deletions .github/workflows/callbacks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,11 @@ jobs:
run: |
cd modules/apps/callbacks
go test -v -mod=readonly ./...
- name: sonarcloud
if: ${{ env.GIT_DIFF && !github.event.pull_request.draft && env.SONAR_TOKEN != null }}
uses: SonarSource/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: modules/apps/callbacks/
8 changes: 8 additions & 0 deletions .github/workflows/capability.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,11 @@ jobs:
run: |
cd modules/capability
go test -v -mod=readonly ./...
- name: sonarcloud
if: ${{ env.GIT_DIFF && !github.event.pull_request.draft && env.SONAR_TOKEN != null }}
uses: SonarSource/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: modules/capability/
43 changes: 17 additions & 26 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,53 +104,44 @@ jobs:
cat pkgs.txt.part.${{ matrix.part }} | xargs go test -mod=readonly -timeout 30m -coverprofile=${{ matrix.part }}profile.out -covermode=atomic -tags='ledger test_ledger_mock'
if: env.GIT_DIFF
- uses: actions/upload-artifact@v4
if: env.GIT_DIFF
with:
name: '${{ github.sha }}-${{ matrix.part }}-coverage'
path: ./${{ matrix.part }}profile.out

upload-coverage-report:
repo-analysis:
runs-on: ubuntu-latest
needs: tests
needs: [tests]
steps:
- uses: actions/checkout@v4
- uses: technote-space/[email protected]
id: git_diff
with:
PATTERNS: |
**/**.go
**/*.go
go.mod
go.sum
**/go.mod
**/go.sum
- uses: actions/download-artifact@v4
if: env.GIT_DIFF
with:
name: '${{ github.sha }}-00-coverage'
if: env.GIT_DIFF
- uses: actions/download-artifact@v4
if: env.GIT_DIFF
with:
name: '${{ github.sha }}-01-coverage'
if: env.GIT_DIFF
- uses: actions/download-artifact@v4
if: env.GIT_DIFF
with:
name: '${{ github.sha }}-02-coverage'
if: env.GIT_DIFF
- uses: actions/download-artifact@v4
with:
name: '${{ github.sha }}-03-coverage'
if: env.GIT_DIFF
- run: |
cat ./*profile.out | grep -v "mode: atomic" >> coverage.txt
if: env.GIT_DIFF
- 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\/cosmos\/cosmos-sdk/g')
echo "Excluding ${filename} from coverage report..."
sed -i.bak "/$(echo $filename | sed 's/\//\\\//g')/d" coverage.txt
done
if: env.GIT_DIFF
- uses: codecov/codecov-action@v4
with:
file: ./coverage.txt
if: env.GIT_DIFF
name: '${{ github.sha }}-03-coverage'
- 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 }}
8 changes: 8 additions & 0 deletions .github/workflows/wasm-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,11 @@ jobs:
run: |
cd modules/light-clients/08-wasm
go test -v -mod=readonly ./...
- name: sonarcloud
if: ${{ env.GIT_DIFF && !github.event.pull_request.draft && env.SONAR_TOKEN != null }}
uses: SonarSource/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: modules/light-clients/08-wasm/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<a href="https://goreportcard.com/report/github.com/cosmos/ibc-go">
<img alt="Go report card" src="https://goreportcard.com/badge/github.com/cosmos/ibc-go" />
</a>
<a href="https://codecov.io/gh/cosmos/ibc-go">
<img alt="Code Coverage" src="https://codecov.io/gh/cosmos/ibc-go/branch/main/graph/badge.svg" />
<a href="https://sonarcloud.io/summary/overall?id=cosmos_ibc-go">
<img alt="Code Coverage" src="https://sonarcloud.io/api/project_badges/measure?project=cosmos_ibc-go&metric=coverage" />
</a>
</div>
<div align="center">
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/development-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ When testing a function under a variety of different inputs, we prefer to use [t

All unit tests should use the testing package. Please see the testing package [README](../../testing/README.md) for more information.

Test coverage is continuously deployed at [codecov](https://app.codecov.io/github/cosmos/ibc-go). PRs that improve test coverage are welcome, but in general the test coverage should be used as a guidance for finding API use cases that are not covered by tests. We don't recommend adding tests that only improve coverage but not actually test a meaning use case.
Test coverage is continuously deployed at [SonarCloud](https://sonarcloud.io/project/overview?id=cosmos_ibc-go). PRs that improve test coverage are welcome, but in general the test coverage should be used as a guidance for finding API use cases that are not covered by tests. We don't recommend adding tests that only improve coverage but not actually test a meaning use case.

## Documentation

Expand Down
14 changes: 14 additions & 0 deletions modules/apps/callbacks/sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
sonar.projectKey=ibc-go-callbacks
sonar.organization=cosmos

sonar.projectName=ibc-go - Callbacks
sonar.project.monorepo.enabled=true

sonar.sources=.
sonar.exclusions=**/*_test.go
sonar.tests=.
sonar.test.inclusions=**/*_test.go
sonar.go.coverage.reportPaths=coverage.out

sonar.sourceEncoding=UTF-8
sonar.scm.provider=git
14 changes: 14 additions & 0 deletions modules/capability/sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
sonar.projectKey=ibc-go-capability
sonar.organization=cosmos

sonar.projectName=ibc-go - Capability
sonar.project.monorepo.enabled=true

sonar.sources=.
sonar.exclusions=**/*_test.go
sonar.tests=.
sonar.test.inclusions=**/*_test.go
sonar.go.coverage.reportPaths=coverage.out

sonar.sourceEncoding=UTF-8
sonar.scm.provider=git
14 changes: 14 additions & 0 deletions modules/light-clients/08-wasm/sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
sonar.projectKey=ibc-go-08-wasm
sonar.organization=cosmos

sonar.projectName=ibc-go - 08-wasm
sonar.project.monorepo.enabled=true

sonar.sources=.
sonar.exclusions=**/*_test.go
sonar.tests=.
sonar.test.inclusions=**/*_test.go
sonar.go.coverage.reportPaths=coverage.out

sonar.sourceEncoding=UTF-8
sonar.scm.provider=git
20 changes: 20 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
sonar-projects.propertiessonar.projectKey=cosmos_ibc-go
sonar.organization=cosmos

sonar.projectName=ibc-go
sonar.project.monorepo.enabled=true

sonar.sources=.
sonar.exclusions=**/*_test.go,**/testing/**,e2e/**,**/*.pb.go,**/*.pb.gw.go,**/*.pulsar.go,docs/**,**/*.md,scripts/**,
sonar.tests=.
sonar.test.inclusions=**/*_test.go,**/testing/**,e2e/**,**/testutil/**
sonar.go.coverage.reportPaths=coverage.out,*profile.out

sonar.python.version=3
sonar.sourceEncoding=UTF-8
sonar.scm.provider=git

# Exclude C/C++/Objective-C files from analysis
sonar.c.file.suffixes=-
sonar.cpp.file.suffixes=-
sonar.objc.file.suffixes=-

0 comments on commit 9095690

Please sign in to comment.