Skip to content

Commit

Permalink
ci: configure sonarcloud (cosmos#13921)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt authored Nov 18, 2022
1 parent b425907 commit eb4afa7
Show file tree
Hide file tree
Showing 36 changed files with 38 additions and 89 deletions.
3 changes: 3 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@ ignore:
- "x/**/test_common.go"
- "scripts/"
- "contrib"
- "**/*.pb.gw.go"
- "**/*.pulsar.go"
- "tests/mocks/*.go"
31 changes: 6 additions & 25 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,13 @@ jobs:
name: "${{ github.sha }}-${{ matrix.part }}-coverage"
path: ./${{ matrix.part }}profile.out

upload-coverage-report:
repo-analysis:
runs-on: ubuntu-latest
needs: tests
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: technote-space/get-diff-action@v6.1.1
with:
PATTERNS: |
Expand Down Expand Up @@ -154,35 +156,14 @@ jobs:
- 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@v3
with:
file: ./coverage.txt
if: env.GIT_DIFF

sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- uses: codecov/codecov-action@v3
with:
file: ./coverage.txt

test-rosetta:
runs-on: ubuntu-latest
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
<a href="https://goreportcard.com/report/github.com/cosmos/cosmos-sdk">
<img alt="Go report card" src="https://goreportcard.com/badge/github.com/cosmos/cosmos-sdk" />
</a>
<a href="https://codecov.io/gh/cosmos/cosmos-sdk">
<img alt="Code Coverage" src="https://codecov.io/gh/cosmos/cosmos-sdk/branch/main/graph/badge.svg" />
<a href="https://sonarcloud.io/summary/overall?id=cosmos_cosmos-sdk">
<img alt="Code Coverage" src="https://sonarcloud.io/api/project_badges/measure?project=cosmos_cosmos-sdk&metric=coverage" />
</a>
<a href="https://sonarcloud.io/summary/overall?id=cosmos_cosmos-sdk">
<img alt="SonarCloud Analysis" src="https://sonarcloud.io/api/project_badges/measure?project=cosmos_cosmos-sdk&metric=alert_status">
</a>
</div>
<div align="center">
Expand Down
2 changes: 0 additions & 2 deletions server/export.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package server

// DONTCOVER

import (
"fmt"
"os"
Expand Down
2 changes: 0 additions & 2 deletions server/start.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package server

// DONTCOVER

import (
"errors"
"fmt"
Expand Down
2 changes: 0 additions & 2 deletions server/tm_cmds.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package server

// DONTCOVER

import (
"fmt"

Expand Down
2 changes: 0 additions & 2 deletions server/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ import (
"github.com/cosmos/cosmos-sdk/version"
)

// DONTCOVER

// ServerContextKey defines the context key used to retrieve a server.Context from
// a command's Context.
const ServerContextKey = sdk.ContextKey("server.context")
Expand Down
2 changes: 0 additions & 2 deletions simapp/simd/cmd/testnet.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package cmd

// DONTCOVER

import (
"bufio"
"encoding/json"
Expand Down
24 changes: 24 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
sonar.projectKey=cosmos_cosmos-sdk
sonar.organization=cosmos

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

sonar.sources=.
sonar.exclusions=**/*_test.go,tests/**,**/*.pb.go,**/*.pb.gw.go,**/*.pulsar.go,test_helpers.go,docs/**,testutil/testdata/**,testutil/testdata_pulsar/**,**/*.java

sonar.go.coverage.reportPaths=coverage.txt
sonar.coverage.exclusions=**/*_test.go,tests/**,**/*.pb.go,**/*.pb.gw.go,**/*.pulsar.go,test_helpers.go,docs/**,testutil/testdata/**,testutil/testdata_pulsar/**,**/*.java

sonar.tests=.
sonar.test.inclusions=**/*_test.go,tests/**

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=-
sonar.cpp.file.suffixes=-
sonar.objc.file.suffixes=-
1 change: 0 additions & 1 deletion testutil/testdata/animal.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package testdata

// DONTCOVER
// nolint

import (
Expand Down
2 changes: 0 additions & 2 deletions x/auth/client/testutil/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,3 @@ func TxMultiSignBatchExec(clientCtx client.Context, filename string, from string

return clitestutil.ExecTestCLICmd(clientCtx, cli.GetMultiSignBatchCmd(), args)
}

// DONTCOVER
2 changes: 0 additions & 2 deletions x/auth/simulation/params.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package simulation

// DONTCOVER

import (
"fmt"
"math/rand"
Expand Down
2 changes: 0 additions & 2 deletions x/bank/simulation/genesis.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package simulation

// DONTCOVER

import (
"encoding/json"
"fmt"
Expand Down
2 changes: 0 additions & 2 deletions x/bank/simulation/params.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package simulation

// DONTCOVER

import (
"fmt"
"math/rand"
Expand Down
2 changes: 0 additions & 2 deletions x/capability/simulation/genesis.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package simulation

// DONTCOVER

import (
"encoding/json"
"fmt"
Expand Down
2 changes: 0 additions & 2 deletions x/capability/types/errors.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package types

// DONTCOVER

import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
Expand Down
2 changes: 0 additions & 2 deletions x/distribution/simulation/genesis.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package simulation

// DONTCOVER

import (
"encoding/json"
"fmt"
Expand Down
2 changes: 0 additions & 2 deletions x/distribution/simulation/params.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package simulation

// DONTCOVER

import (
"fmt"
"math/rand"
Expand Down
2 changes: 0 additions & 2 deletions x/evidence/simulation/genesis.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package simulation

// DONTCOVER

import (
"encoding/json"
"fmt"
Expand Down
1 change: 0 additions & 1 deletion x/evidence/types/errors.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// DONTCOVER
package types

import (
Expand Down
2 changes: 0 additions & 2 deletions x/evidence/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"time"
)

// DONTCOVER

// DoubleSignJailEndTime period ends at Max Time supported by Amino
// (Dec 31, 9999 - 23:59:59 GMT).
var DoubleSignJailEndTime = time.Unix(253402300799, 0)
2 changes: 0 additions & 2 deletions x/genutil/collect.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package genutil

// DONTCOVER

import (
"encoding/json"
"errors"
Expand Down
2 changes: 0 additions & 2 deletions x/genutil/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
)

// DONTCOVER

type (
// AppMap map modules names with their json raw representation.
AppMap map[string]json.RawMessage
Expand Down
2 changes: 0 additions & 2 deletions x/gov/keeper/invariants.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package keeper

// DONTCOVER

import (
"fmt"

Expand Down
2 changes: 0 additions & 2 deletions x/gov/module.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package gov

// DONTCOVER

import (
"context"
"encoding/json"
Expand Down
2 changes: 0 additions & 2 deletions x/gov/simulation/genesis.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package simulation

// DONTCOVER

import (
"encoding/json"
"fmt"
Expand Down
2 changes: 0 additions & 2 deletions x/gov/simulation/params.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package simulation

// DONTCOVER

import (
"encoding/json"
"fmt"
Expand Down
2 changes: 0 additions & 2 deletions x/gov/types/v1/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

// DONTCOVER

// query endpoints supported by the governance Querier
const (
QueryParams = "params"
Expand Down
2 changes: 0 additions & 2 deletions x/gov/types/v1beta1/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

// DONTCOVER

// query endpoints supported by the governance Querier
const (
QueryParams = "params"
Expand Down
2 changes: 0 additions & 2 deletions x/mint/simulation/genesis.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package simulation

// DONTCOVER

import (
"encoding/json"
"fmt"
Expand Down
2 changes: 0 additions & 2 deletions x/mint/simulation/params.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package simulation

// DONTCOVER

import (
"fmt"
"math/rand"
Expand Down
2 changes: 0 additions & 2 deletions x/slashing/simulation/genesis.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package simulation

// DONTCOVER

import (
"encoding/json"
"fmt"
Expand Down
2 changes: 0 additions & 2 deletions x/slashing/simulation/params.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package simulation

// DONTCOVER

import (
"fmt"
"math/rand"
Expand Down
2 changes: 0 additions & 2 deletions x/slashing/types/querier.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package types

// DONTCOVER

// Query endpoints supported by the slashing querier
const (
QueryParameters = "parameters"
Expand Down
2 changes: 0 additions & 2 deletions x/staking/simulation/genesis.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package simulation

// DONTCOVER

import (
"encoding/json"
"fmt"
Expand Down
2 changes: 0 additions & 2 deletions x/staking/simulation/params.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package simulation

// DONTCOVER

import (
"fmt"
"math/rand"
Expand Down

0 comments on commit eb4afa7

Please sign in to comment.