70 lines
2.1 KiB
YAML
70 lines
2.1 KiB
YAML
on:
|
|
push:
|
|
pull_request:
|
|
types: [opened, synchronize, reopened]
|
|
|
|
name: SonarQube Scan
|
|
jobs:
|
|
sonarqube:
|
|
name: SonarQube Trigger
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checking out
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v6
|
|
with:
|
|
go-version: '1.25.5'
|
|
cache: false
|
|
|
|
- name: Install dependencies
|
|
run: go mod tidy
|
|
|
|
- name: Run go vet
|
|
run: go vet ./... 2>&1 | tee vet-results.txt
|
|
|
|
- name: Run tests with coverage
|
|
run: |
|
|
go test ./... -v -coverprofile=coverage
|
|
|
|
- name: Run GolangCI-Lint Analysis
|
|
uses: golangci/golangci-lint-action@v9
|
|
with:
|
|
skip-cache: true
|
|
version: v2.6
|
|
args: >
|
|
--issues-exit-code=0
|
|
--output.text.path=stdout
|
|
--output.checkstyle.path=golangci-lint-report.xml
|
|
|
|
- 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/**,**/golangci-lint-report.xml
|
|
-Dsonar.go.govet.reportPaths=vet-results.txt
|
|
-Dsonar.go.golangci-lint.reportPaths=golangci-lint-report.xml
|
|
-Dsonar.sources=./
|
|
-Dsonar.tests=./ |