generated from DFE-Digital/govuk-dotnet-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 2
72 lines (63 loc) · 2.52 KB
/
sonarqube.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Static code analysis
on:
workflow_dispatch:
# push:
# branches: ["main", "release/**", "feature/**", "fix/**"]
pull_request:
types: [opened, synchronize, reopened]
branches: ["next", "main", "release/**", "feature/**", "fix/**"]
jobs:
code-analysis:
name: Static code analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: "zulu" # Alternative distribution options are available.
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@v4
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarCloud coverage
id: cache-sonar-coverage
uses: actions/cache@v4
with:
path: ~\sonar\cache
key: ${{ runner.os }}-coverage
restore-keys: ${{ runner.os }}-coverage
- name: Install SonarCloud scanners
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
run: dotnet tool install --global dotnet-sonarscanner
- name: Install SonarCloud coverage
if: steps.cache-sonar-coverage.outputs.cache-hit != 'true'
run: dotnet tool install --global dotnet-coverage
- name: Build, Test and Analyze
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_AS }}
run: |
dotnet-sonarscanner begin \
/k:as2024ad_sfsw \
/o:as2024ad \
/d:sonar.qualitygate.wait=true \
/d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml \
/d:sonar.exclusions="**/*.css,**/*.scss,**/Models/*,**/Program.cs,**/WebApplicationBuilderExtensions.cs,**/GraphQL/Queries/*,**/Contentful-Schema/migrations/*.cjs" \
/d:sonar.test.exclusions="Childrens-Social-Care-CPD-Tests/**/*,Terraform-bootstrap/Error-pages/*" \
/d:sonar.token="${{ secrets.SONAR_TOKEN_AS }}" \
/d:sonar.host.url="https://sonarcloud.io"
dotnet build --no-incremental
dotnet-coverage collect --settings dotnet-cover-config.xml -f xml -o coverage.xml "dotnet test"
dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN_AS }}"