forked from arkavo-com/backend-go
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sonar Cloud analysis + coverage gathering (#33)
- Loading branch information
1 parent
8ddcdfc
commit 3d1d52b
Showing
2 changed files
with
79 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: SonarCloud | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
- reopened | ||
|
||
jobs: | ||
gotest: | ||
name: 'Generate Golang Test Reports' | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
|
||
steps: | ||
|
||
- name: 'Checkout repo' | ||
uses: actions/checkout@v3 | ||
|
||
- name: 'Setup Go' | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: '${{ inputs.go-version }}' | ||
cache: true | ||
|
||
- name: 'Generate Golang Test Reports' | ||
run: go test -v -coverprofile coverage.out -json ./... | tee coverage.json | ||
|
||
- name: 'Archive Golang Test Results' | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: code-coverage-report | ||
path: coverage.* | ||
retention-days: 1 | ||
|
||
sonarcloud: | ||
name: 'SonarCloud' | ||
runs-on: ubuntu-latest | ||
needs: [gotest] | ||
permissions: | ||
contents: read | ||
|
||
steps: | ||
- name: 'Checkout repo' | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: 'Download Code Coverage Report' | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: code-coverage-report | ||
|
||
- name: 'SonarCloud Scan' | ||
uses: SonarSource/sonarcloud-github-action@master | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
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,17 @@ | ||
# must be unique in a given SonarQube instance | ||
sonar.projectKey=opentdf_backend-go | ||
sonar.organization=opentdf | ||
|
||
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. | ||
# This property is optional if sonar.modules is set. | ||
sonar.sources=pkg | ||
sonar.exclusions=**/*_test.go,**/mock_*.go,cmd/*.go | ||
|
||
sonar.tests=. | ||
sonar.test.inclusions=**/*_test.go | ||
|
||
sonar.go.coverage.reportPaths=coverage.out | ||
sonar.go.tests.reportPaths=coverage.json | ||
|
||
# Encoding of the source code. Default is default system encoding | ||
sonar.sourceEncoding=UTF-8 |