-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (57 loc) · 2.02 KB
/
Copy pathsonar.yml
File metadata and controls
65 lines (57 loc) · 2.02 KB
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
name: Sonar
on:
push:
branches: [master]
pull_request:
branches: [master]
permissions:
contents: read
concurrency:
group: sonar-${{ github.ref }}
cancel-in-progress: true
jobs:
analyze:
name: SonarCloud
runs-on: ubuntu-latest
# The whole job is skipped (neutral, never red) until SonarCloud is fully set up.
# To activate: import the project on sonarcloud.io, add the SONAR_TOKEN secret,
# then set the repository variable SONAR_ENABLED to "true"
# (gh variable set SONAR_ENABLED --body true).
if: ${{ vars.SONAR_ENABLED == 'true' && github.repository == 'thiagoluga/NeoReports' }}
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
steps:
- uses: actions/checkout@v6
with:
# Full history gives Sonar accurate new-code / blame information.
fetch-depth: 0
- name: Setup .NET (8 + 9)
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8.0.x
9.0.x
- name: Setup Java (required by the Sonar scanner)
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: "17"
- name: Install Sonar + coverage tools
run: |
dotnet tool install --global dotnet-sonarscanner
dotnet tool install --global dotnet-coverage
- name: Build, test (with coverage) and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
dotnet sonarscanner begin \
/k:"thiagoluga_NeoReports" \
/o:"thiagoluga" \
/d:sonar.host.url="https://sonarcloud.io" \
/d:sonar.token="${SONAR_TOKEN}" \
/d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml
dotnet build NeoReports.sln --configuration Release
dotnet-coverage collect "dotnet test NeoReports.sln --configuration Release --no-build" -f xml -o coverage.xml
dotnet sonarscanner end /d:sonar.token="${SONAR_TOKEN}"