forked from cosmos/gaia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: migrate code quality tooling from Codecov to Sonar Cloud (cosmos#…
…2598) * remove codecov and add sonarcloud * remove /tools folder * add sonarcloud properties * update README.md
- Loading branch information
Showing
4 changed files
with
99 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,25 +12,35 @@ on: | |
- "**/*.md" | ||
- "docs/**" | ||
|
||
jobs: | ||
cleanup-runs: | ||
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: rokroskar/workflow-run-cleanup-action@master | ||
env: | ||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | ||
permissions: | ||
contents: read | ||
|
||
test-coverage-upload: | ||
concurrency: | ||
group: ci-${{ github.ref }}-tests | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/[email protected] | ||
- uses: technote-space/[email protected] | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: "1.20" | ||
check-latest: true | ||
cache: true | ||
cache-dependency-path: go.sum | ||
- uses: technote-space/[email protected] | ||
id: git_diff | ||
with: | ||
PATTERNS: | | ||
**/**.go | ||
**/*.go | ||
go.mod | ||
go.sum | ||
**/go.mod | ||
**/go.sum | ||
**/Makefile | ||
Makefile | ||
- uses: actions/[email protected] | ||
with: | ||
path: | | ||
|
@@ -39,29 +49,15 @@ jobs: | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.mod') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: 1.20.x | ||
- name: test & coverage report creation | ||
if: env.GIT_DIFF | ||
run: | | ||
go test -v -coverprofile=coverage.txt -covermode=atomic -coverpkg=./... $(go list ./... | grep -v -e '/tests/e2e') | ||
- name: filter non-testable files | ||
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 ./cmd -type d)" | ||
excludelist+=" $(find ./tests -type d)" | ||
for filename in ${excludelist}; do | ||
filename=${filename#".//"} | ||
echo "Excluding ${filename} from coverage report..." | ||
filename=$(echo "$filename" | sed 's/\//\\\//g') | ||
sed -i.bak "/""$filename""/d" coverage.txt | ||
done | ||
- uses: codecov/[email protected] | ||
go test -v -coverprofile=profile.out -covermode=atomic -coverpkg=./... $(go list ./... | grep -v -e '/tests/e2e') | ||
- uses: actions/upload-artifact@v3 | ||
if: env.GIT_DIFF | ||
with: | ||
file: ./coverage.txt | ||
fail_ci_if_error: true | ||
name: "${{ github.sha }}-coverage" | ||
path: ./profile.out | ||
|
||
test-e2e: | ||
runs-on: ubuntu-latest | ||
|
@@ -82,6 +78,31 @@ jobs: | |
- name: Test E2E | ||
run: make test-e2e | ||
|
||
repo-analysis: | ||
runs-on: ubuntu-latest | ||
needs: [tests] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: technote-space/[email protected] | ||
id: git_diff | ||
with: | ||
PATTERNS: | | ||
**/*.go | ||
go.mod | ||
go.sum | ||
**/go.mod | ||
**/go.sum | ||
- uses: actions/download-artifact@v3 | ||
if: env.GIT_DIFF | ||
with: | ||
name: "${{ github.sha }}-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 }} | ||
|
||
liveness-test: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
sonar.projectKey=cosmos_gaia | ||
sonar.organization=cosmos | ||
|
||
sonar.projectName=Gaia | ||
|
||
sonar.sources=. | ||
sonar.exclusions=**/*_test.go,tests/**,**/testutil/**,**/*.pb.go,**/*.pb.gw.go,test_helpers.go,docs/**,client/docs/**,contrib/**, | ||
sonar.tests=. | ||
sonar.test.inclusions=**/*_test.go,tests/**,**/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=- |
This file was deleted.
Oops, something went wrong.