diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 765f0a589f..439cc413d4 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -95,6 +95,56 @@ jobs: make test make build-alpine + sonarqube: + name: SonarQube + runs-on: ubuntu-latest + # needs: [test-frontend, test-backend] + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + + - uses: actions/setup-go@v5 + with: + go-version: "^1.22" + cache: false + + - name: Cache Go Modules + id: cache-go-modules + uses: actions/cache@v4 + with: + path: | + ~/.cache/go-build + /go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('server/src/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Download Go Modules + if: steps.cache-go-modules.outputs.cache-hit != 'true' + working-directory: ./server/src + run: go mod download + + - name: Verify Go Modules + working-directory: ./server/src + run: go list -m all + + - name: Get coverage report + id: coverage + working-directory: ./server + run: | + make test + sed -i 's|scrumlr.io/server/|server/src/|g' src/coverage.txt + + - name: SonarQube Scan + uses: SonarSource/sonarqube-scan-action@v4 + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + - name: SonarQube Quality Gate + uses: SonarSource/sonarqube-quality-gate-action@v1 + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} package: needs: [test-frontend, test-backend] uses: ./.github/workflows/package.yml diff --git a/.github/workflows/sonarqube.yaml b/.github/workflows/sonarqube.yaml deleted file mode 100644 index 897720f0cb..0000000000 --- a/.github/workflows/sonarqube.yaml +++ /dev/null @@ -1,25 +0,0 @@ -name: Build -on: - push: - branches: - - main - pull_request: - types: [opened, synchronize, reopened] -jobs: - sonarqube: - name: SonarQube - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - name: SonarQube Scan - uses: SonarSource/sonarqube-scan-action@v4 - with: - args: > - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - name: SonarQube Quality Gate - uses: SonarSource/sonarqube-quality-gate-action@v1 - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/sonar-project.properties b/sonar-project.properties index e2aed02dd0..e41a5f51c9 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -13,3 +13,5 @@ sonar.organization=scrumlr #sonar.sourceEncoding=UTF-8 sonar.typescript.tsconfigPath=tsconfig.json +sonar.go.coverage.reportPaths=server/src/coverage.txt +sonar.coverage.exclusions=src/**/*