-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (67 loc) · 2.44 KB
/
sonarcloud.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
name: Publish Hot Fix
on:
workflow_call:
permissions:
id-token: write
contents: read
pull-requests: write
jobs:
build:
if: github.run_number != 1
name: CDP SonarCloud coverage scan
runs-on: ubuntu-latest
steps:
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: "zulu"
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up .NET 8.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.0
- 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/scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: Cache dotNet code coverage
id: cache-sonar-coverage
uses: actions/cache@v4
with:
path: ./.sonar/coverage
key: ${{ runner.os }}-sonar-coverage
restore-keys: ${{ runner.os }}-sonar-coverage
- name: Install SonarCloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
run: |
mkdir -p ./.sonar/scanner
dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner
- name: Install dotNet code coverage
if: steps.cache-sonar-coverage.outputs.cache-hit != 'true'
run: |
mkdir -p ./.sonar/coverage
dotnet tool update dotnet-coverage --tool-path ./.sonar/coverage
- name: Build and analyze
if: github.actor != 'dependabot[bot]'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
./.sonar/scanner/dotnet-sonarscanner begin /k:"DEFRA_cdp-dotnet-backend-template" /o:"defra" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml
dotnet build --no-incremental
./.sonar/coverage/dotnet-coverage collect "dotnet test" -f xml -o "coverage.xml"
./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"