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

ci: make sonarcloud more quiet (backport #14585) #14589

Merged
merged 2 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
ci: make sonarcloud more quiet (#14585)
Co-authored-by: Marko <marbar3778@yahoo.com>
(cherry picked from commit 538f7ce)

# Conflicts:
#	.github/workflows/pr-reviews.yml
#	.github/workflows/test.yml
#	collections/sonar-project.properties
#	tools/confix/sonar-project.properties
#	x/nft/sonar-project.properties
  • Loading branch information
julienrbrt authored and mergify[bot] committed Jan 12, 2023
commit d8368d4c5efbb1b0759fa8cb62eb96a643d50948
26 changes: 26 additions & 0 deletions .github/workflows/pr-reviews.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Request review on PRs without changing our codeowners file (which is stricter than review team)
name: Request review on PRs

on:
pull_request_target:
types:
- opened
- reopened
- ready_for_review
branches:
- "main"
- "release/**"

jobs:
request:
permissions:
pull-requests: write
name: Request reviews on opened PRs
runs-on: ubuntu-latest
steps:
- name: Create PR review request
if: ${{ !github.event.pull_request.draft }}
run: gh pr edit $PR_URL --add-reviewer @cosmos/sdk-core-review
env:
GH_TOKEN: ${{ secrets.PRBOT_PAT }}
PR_URL: ${{ github.event.pull_request.html_url }}
114 changes: 105 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ jobs:
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_CLIENT_V2 }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: client/v2/

Expand Down Expand Up @@ -301,7 +301,7 @@ jobs:
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_CORE }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: core/

Expand Down Expand Up @@ -331,7 +331,7 @@ jobs:
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_DEPINJECT }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

test-errors:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -359,7 +359,7 @@ jobs:
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_ERRORS }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: errors/

Expand Down Expand Up @@ -389,7 +389,7 @@ jobs:
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_MATH }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: math/

Expand Down Expand Up @@ -424,7 +424,7 @@ jobs:
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_SIMAPP }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: simapp/

Expand Down Expand Up @@ -454,7 +454,7 @@ jobs:
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_TX }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: tx/

Expand Down Expand Up @@ -488,10 +488,43 @@ jobs:
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_ROSETTA }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: tools/rosetta/

<<<<<<< HEAD
=======
test-collections:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.19.4
cache: true
cache-dependency-path: collections/go.sum
- uses: technote-space/get-diff-action@v6.1.2
id: git_diff
with:
PATTERNS: |
collections/**/*.go
collections/go.mod
collections/go.sum
- name: tests
if: env.GIT_DIFF
run: |
cd collections
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: collections/

>>>>>>> 538f7ce72 (ci: make sonarcloud more quiet (#14585))
test-cosmovisor:
runs-on: ubuntu-latest
steps:
Expand All @@ -518,6 +551,69 @@ jobs:
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_COSMOVISOR }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: tools/cosmovisor/
<<<<<<< HEAD
=======

test-x-nft:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.19.4
cache: true
cache-dependency-path: x/nft/go.sum
- uses: technote-space/get-diff-action@v6.1.2
id: git_diff
with:
PATTERNS: |
x/nft/**/*.go
x/nft/go.mod
x/nft/go.sum
- name: tests
if: env.GIT_DIFF
run: |
cd x/nft
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/nft/

test-confix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.19.4
cache: true
cache-dependency-path: tools/confix/go.sum
- uses: technote-space/get-diff-action@v6.1.2
id: git_diff
with:
PATTERNS: |
tools/confix/**/*.go
tools/confix/go.mod
tools/confix/go.sum
- name: tests
if: env.GIT_DIFF
run: |
cd tools/confix
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
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: tools/confix/
>>>>>>> 538f7ce72 (ci: make sonarcloud more quiet (#14585))
5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,13 @@ For consistency between our CI and the local tests, `GOWORK=off` is set in the `

When extracting a package to its own go modules, some extra steps are required, for keeping our CI checks and Dev UX:

* Add a CHANGELOG.md / README.md under the new package folder
* Add the package in [`go.work.example`](./go.work.example)
* Add weekly dependabot checks (see [dependabot.yml](./.github/dependabot.yml))
* Pre-configure SonarCloud
* Add tests to github workflow [test.yml](.github/workflows/test.yml) (under submodules)
* Configure SonarCloud
* Add `sonar-projects.properties` (see math [sonar-projects.properties](./math/sonar-projects.properties) for example)
* Add a GitHub Workflow entry for running the scans (see [test.yml](.github/workflows/test.yml))
* Add an entry for skipping the tests (see [test-skip.yml](.github/workflows/test-skip.yml))
* Ask the team to add the project to SonarCloud

## Protobuf
Expand Down
3 changes: 1 addition & 2 deletions client/v2/sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ sonar.test.inclusions=**/*_test.go
sonar.go.coverage.reportPaths=coverage.out

sonar.sourceEncoding=UTF-8
sonar.scm.provider=git
sonar.pullrequest.github.summary_comment=true
sonar.scm.provider=git
14 changes: 14 additions & 0 deletions collections/sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
sonar.projectKey=cosmos-sdk-collections
sonar.organization=cosmos

sonar.projectName=Cosmos SDK - Collections
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
3 changes: 1 addition & 2 deletions core/sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ sonar.test.inclusions=**/*_test.go
sonar.go.coverage.reportPaths=coverage.out

sonar.sourceEncoding=UTF-8
sonar.scm.provider=git
sonar.pullrequest.github.summary_comment=true
sonar.scm.provider=git
3 changes: 1 addition & 2 deletions depinject/sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ sonar.test.inclusions=**/*_test.go
sonar.go.coverage.reportPaths=coverage.out

sonar.sourceEncoding=UTF-8
sonar.scm.provider=git
sonar.pullrequest.github.summary_comment=true
sonar.scm.provider=git
2 changes: 2 additions & 0 deletions errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
grpcstatus "google.golang.org/grpc/status"
)

// foo

// UndefinedCodespace when we explicitly declare no codespace
const UndefinedCodespace = "undefined"

Expand Down
5 changes: 2 additions & 3 deletions errors/sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sonar.projectKey=cosmos-sdk-errors
sonar.organization=cosmos

sonar.projectName=Cosmos SDK Errors
sonar.projectName=Cosmos SDK - Errors
sonar.project.monorepo.enabled=true

sonar.sources=.
Expand All @@ -11,5 +11,4 @@ sonar.test.inclusions=**/*_test.go
sonar.go.coverage.reportPaths=coverage.out

sonar.sourceEncoding=UTF-8
sonar.scm.provider=git
sonar.pullrequest.github.summary_comment=true
sonar.scm.provider=git
3 changes: 1 addition & 2 deletions math/sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ sonar.test.inclusions=**/*_test.go
sonar.go.coverage.reportPaths=coverage.out

sonar.sourceEncoding=UTF-8
sonar.scm.provider=git
sonar.pullrequest.github.summary_comment=true
sonar.scm.provider=git
3 changes: 1 addition & 2 deletions simapp/sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ sonar.test.inclusions=**/*_test.go
sonar.go.coverage.reportPaths=coverage.out

sonar.sourceEncoding=UTF-8
sonar.scm.provider=git
sonar.pullrequest.github.summary_comment=true
sonar.scm.provider=git
1 change: 0 additions & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ sonar.go.coverage.reportPaths=coverage.out,*profile.out
sonar.python.version=3
sonar.sourceEncoding=UTF-8
sonar.scm.provider=git
sonar.pullrequest.github.summary_comment=true

# Exclude C/C++/Objective-C files from analysis
sonar.c.file.suffixes=-
Expand Down
14 changes: 14 additions & 0 deletions tools/confix/sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
sonar.projectKey=cosmos-sdk-tools-confix
sonar.organization=cosmos

sonar.projectName=Cosmos SDK - Confix
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
3 changes: 1 addition & 2 deletions tools/cosmovisor/sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ sonar.test.inclusions=**/*_test.go
sonar.go.coverage.reportPaths=coverage.out

sonar.sourceEncoding=UTF-8
sonar.scm.provider=git
sonar.pullrequest.github.summary_comment=true
sonar.scm.provider=git
3 changes: 1 addition & 2 deletions tools/rosetta/sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ sonar.test.inclusions=**/*_test.go
sonar.go.coverage.reportPaths=coverage.out

sonar.sourceEncoding=UTF-8
sonar.scm.provider=git
sonar.pullrequest.github.summary_comment=true
sonar.scm.provider=git
3 changes: 1 addition & 2 deletions tx/sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ sonar.test.inclusions=**/*_test.go
sonar.go.coverage.reportPaths=coverage.out

sonar.sourceEncoding=UTF-8
sonar.scm.provider=git
sonar.pullrequest.github.summary_comment=true
sonar.scm.provider=git
14 changes: 14 additions & 0 deletions x/nft/sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
sonar.projectKey=cosmos-sdk-x-nft
sonar.organization=cosmos

sonar.projectName=Cosmos SDK - x/nft
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