ci: configure sonarcloud (#13921)

This commit is contained in:
Julien Robert 2022-11-18 16:14:49 +01:00 committed by GitHub
parent b425907b95
commit eb4afa74ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 38 additions and 89 deletions

View File

@ -57,3 +57,6 @@ ignore:
- "x/**/test_common.go"
- "scripts/"
- "contrib"
- "**/*.pb.gw.go"
- "**/*.pulsar.go"
- "tests/mocks/*.go"

View File

@ -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: |
@ -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

View File

@ -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">

View File

@ -1,7 +1,5 @@
package server
// DONTCOVER
import (
"fmt"
"os"

View File

@ -1,7 +1,5 @@
package server
// DONTCOVER
import (
"errors"
"fmt"

View File

@ -1,7 +1,5 @@
package server
// DONTCOVER
import (
"fmt"

View File

@ -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")

View File

@ -1,7 +1,5 @@
package cmd
// DONTCOVER
import (
"bufio"
"encoding/json"

24
sonar-project.properties Normal file
View File

@ -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=-

View File

@ -1,6 +1,5 @@
package testdata
// DONTCOVER
// nolint
import (

View File

@ -110,5 +110,3 @@ func TxMultiSignBatchExec(clientCtx client.Context, filename string, from string
return clitestutil.ExecTestCLICmd(clientCtx, cli.GetMultiSignBatchCmd(), args)
}
// DONTCOVER

View File

@ -1,7 +1,5 @@
package simulation
// DONTCOVER
import (
"fmt"
"math/rand"

View File

@ -1,7 +1,5 @@
package simulation
// DONTCOVER
import (
"encoding/json"
"fmt"

View File

@ -1,7 +1,5 @@
package simulation
// DONTCOVER
import (
"fmt"
"math/rand"

View File

@ -1,7 +1,5 @@
package simulation
// DONTCOVER
import (
"encoding/json"
"fmt"

View File

@ -1,7 +1,5 @@
package types
// DONTCOVER
import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)

View File

@ -1,7 +1,5 @@
package simulation
// DONTCOVER
import (
"encoding/json"
"fmt"

View File

@ -1,7 +1,5 @@
package simulation
// DONTCOVER
import (
"fmt"
"math/rand"

View File

@ -1,7 +1,5 @@
package simulation
// DONTCOVER
import (
"encoding/json"
"fmt"

View File

@ -1,4 +1,3 @@
// DONTCOVER
package types
import (

View File

@ -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)

View File

@ -1,7 +1,5 @@
package genutil
// DONTCOVER
import (
"encoding/json"
"errors"

View File

@ -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

View File

@ -1,7 +1,5 @@
package keeper
// DONTCOVER
import (
"fmt"

View File

@ -1,7 +1,5 @@
package gov
// DONTCOVER
import (
"context"
"encoding/json"

View File

@ -1,7 +1,5 @@
package simulation
// DONTCOVER
import (
"encoding/json"
"fmt"

View File

@ -1,7 +1,5 @@
package simulation
// DONTCOVER
import (
"encoding/json"
"fmt"

View File

@ -4,8 +4,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
// DONTCOVER
// query endpoints supported by the governance Querier
const (
QueryParams = "params"

View File

@ -4,8 +4,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
// DONTCOVER
// query endpoints supported by the governance Querier
const (
QueryParams = "params"

View File

@ -1,7 +1,5 @@
package simulation
// DONTCOVER
import (
"encoding/json"
"fmt"

View File

@ -1,7 +1,5 @@
package simulation
// DONTCOVER
import (
"fmt"
"math/rand"

View File

@ -1,7 +1,5 @@
package simulation
// DONTCOVER
import (
"encoding/json"
"fmt"

View File

@ -1,7 +1,5 @@
package simulation
// DONTCOVER
import (
"fmt"
"math/rand"

View File

@ -1,7 +1,5 @@
package types
// DONTCOVER
// Query endpoints supported by the slashing querier
const (
QueryParameters = "parameters"

View File

@ -1,7 +1,5 @@
package simulation
// DONTCOVER
import (
"encoding/json"
"fmt"

View File

@ -1,7 +1,5 @@
package simulation
// DONTCOVER
import (
"fmt"
"math/rand"