From 90956904f13248495558d96565dc8ffc6594eacf Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Fri, 8 Mar 2024 08:50:45 +0100 Subject: [PATCH] ci: replace codecov with sonarcloud (#5931) * 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> --- .codecov.yml | 57 ------------------- .github/PULL_REQUEST_TEMPLATE.md | 2 +- .github/workflows/callbacks.yml | 8 +++ .github/workflows/capability.yml | 8 +++ .github/workflows/test.yml | 43 ++++++-------- .github/workflows/wasm-client.yml | 8 +++ README.md | 4 +- docs/dev/development-setup.md | 2 +- .../apps/callbacks/sonar-project.properties | 14 +++++ modules/capability/sonar-project.properties | 14 +++++ .../08-wasm/sonar-project.properties | 14 +++++ sonar-project.properties | 20 +++++++ 12 files changed, 107 insertions(+), 87 deletions(-) delete mode 100644 .codecov.yml create mode 100644 modules/apps/callbacks/sonar-project.properties create mode 100644 modules/capability/sonar-project.properties create mode 100644 modules/light-clients/08-wasm/sonar-project.properties create mode 100644 sonar-project.properties diff --git a/.codecov.yml b/.codecov.yml deleted file mode 100644 index 88f51441f92..00000000000 --- a/.codecov.yml +++ /dev/null @@ -1,57 +0,0 @@ -# -# This codecov.yml is the default configuration for -# all repositories on Codecov. You may adjust the settings -# below in your own codecov.yml in your repository. -# -coverage: - precision: 2 - round: down - range: 70...100 - - status: - # Learn more at https://docs.codecov.io/docs/commit-status - project: - default: - threshold: 1% # allow this much decrease on project - app: - target: 70% - flags: - - app - modules: - target: 70% - flags: - - modules - client: - flags: - - client - changes: false - -comment: - layout: "reach, diff, files" - behavior: default # update if exists else create new - require_changes: true - -flags: - app: - paths: - - "app/" - - "baseapp/" - modules: - paths: - - "core/" - - "!modules/core/**/client/" # ignore client package - client: - paths: - - "client/" - - "core/**/client/" - -ignore: - - "docs" - - "*.md" - - "**/*.pb.go" - - "**/*.pb.gw.go" - - "modules/**/**/**/*.pb.go" - - "modules/**/**/**/*.pb.gw.go" - - "modules/**/**/**/test_common.go" - - "testing/" - - "scripts/" diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 6892d116b0a..3ceba15c17a 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -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. diff --git a/.github/workflows/callbacks.yml b/.github/workflows/callbacks.yml index 836edcc29fb..2d35637fccb 100644 --- a/.github/workflows/callbacks.yml +++ b/.github/workflows/callbacks.yml @@ -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/sonarcloud-github-action@v1.6 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + with: + projectBaseDir: modules/apps/callbacks/ diff --git a/.github/workflows/capability.yml b/.github/workflows/capability.yml index 89274a5c145..41c51b55715 100644 --- a/.github/workflows/capability.yml +++ b/.github/workflows/capability.yml @@ -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/sonarcloud-github-action@v1.6 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + with: + projectBaseDir: modules/capability/ diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index da37c93fa73..d56600fc350 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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/get-diff-action@v6.1.2 + 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 }} diff --git a/.github/workflows/wasm-client.yml b/.github/workflows/wasm-client.yml index a2a3990ae3e..e752992fcb9 100644 --- a/.github/workflows/wasm-client.yml +++ b/.github/workflows/wasm-client.yml @@ -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/sonarcloud-github-action@v1.6 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + with: + projectBaseDir: modules/light-clients/08-wasm/ diff --git a/README.md b/README.md index 6eb557c4653..0661d5a24f4 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,8 @@ Go report card - - Code Coverage + + Code Coverage
diff --git a/docs/dev/development-setup.md b/docs/dev/development-setup.md index 3c0d7c03ace..b1687859e56 100644 --- a/docs/dev/development-setup.md +++ b/docs/dev/development-setup.md @@ -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 diff --git a/modules/apps/callbacks/sonar-project.properties b/modules/apps/callbacks/sonar-project.properties new file mode 100644 index 00000000000..15684f17c39 --- /dev/null +++ b/modules/apps/callbacks/sonar-project.properties @@ -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 \ No newline at end of file diff --git a/modules/capability/sonar-project.properties b/modules/capability/sonar-project.properties new file mode 100644 index 00000000000..4b0d5147597 --- /dev/null +++ b/modules/capability/sonar-project.properties @@ -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 \ No newline at end of file diff --git a/modules/light-clients/08-wasm/sonar-project.properties b/modules/light-clients/08-wasm/sonar-project.properties new file mode 100644 index 00000000000..a6dda8e144e --- /dev/null +++ b/modules/light-clients/08-wasm/sonar-project.properties @@ -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 \ No newline at end of file diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 00000000000..32d5decda91 --- /dev/null +++ b/sonar-project.properties @@ -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=- \ No newline at end of file