ci: update SonarQube action configuration
This commit is contained in:
@@ -24,10 +24,30 @@ jobs:
|
||||
run: go mod tidy
|
||||
|
||||
- name: Run tests with coverage
|
||||
run: go test ./... -coverprofile=coverage
|
||||
run: go test ./... -coverprofile=coverage -json > test-results.json
|
||||
|
||||
- name: Set SonarQube project key
|
||||
run: |
|
||||
BRANCH_NAME=${GITHUB_REF#refs/heads/}
|
||||
if [ "$BRANCH_NAME" = "main" ]; then
|
||||
SONAR_PROJECT_KEY="tunnel-please"
|
||||
else
|
||||
BRANCH_KEY=${BRANCH_NAME//\//-}
|
||||
SONAR_PROJECT_KEY="tunnel-please-$BRANCH_KEY"
|
||||
fi
|
||||
echo "SONAR_PROJECT_KEY=tunnel-please-$BRANCH_KEY" >> $GITHUB_ENV
|
||||
echo "Using SonarQube Project Key: $SONAR_PROJECT_KEY"
|
||||
|
||||
- name: SonarQube Scan
|
||||
uses: SonarSource/sonarqube-scan-action@v7.0.0
|
||||
env:
|
||||
SONAR_HOST_URL: ${{ secrets.SONARQUBE_HOST }}
|
||||
SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
|
||||
with:
|
||||
args: >
|
||||
-Dsonar.projectKey=${{ env.SONAR_PROJECT_KEY }}
|
||||
-Dsonar.go.coverage.reportPaths=coverage
|
||||
-Dsonar.test.inclusions=**/*_test.go
|
||||
-Dsonar.test.exclusions=**/vendor/**
|
||||
-Dsonar.exclusions=**/*_test.go,**/vendor/**
|
||||
-Dsonar.go.tests.reportPaths=test-results.json
|
||||
Vendored
+2
-1
@@ -5,4 +5,5 @@ id_rsa*
|
||||
tmp
|
||||
certs
|
||||
app
|
||||
coverage
|
||||
coverage
|
||||
test-results.json
|
||||
@@ -1,3 +0,0 @@
|
||||
sonar.projectKey=tunnel-please
|
||||
sonar.go.coverage.reportPaths=coverage
|
||||
sonar.test.inclusions=**/*_test.go
|
||||
Reference in New Issue
Block a user