-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (65 loc) · 2.85 KB
/
Copy pathSonar.yml
File metadata and controls
78 lines (65 loc) · 2.85 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
66
67
68
69
70
71
72
73
74
75
76
77
78
name: SonarQube Analysis
permissions:
contents: read
# Analyze only the long-lived branch. Community-Edition Sonar has no branch/PR
# support — every analysis writes to the single main branch. PR build/test feedback
# is covered by CI.yml.
on:
push:
branches:
- develop
workflow_dispatch:
jobs:
build:
name: Build and analyze
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v5.6.0
with:
java-version: 17
distribution: 'zulu'
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: 10.0.x
- name: Cache SonarQube packages
uses: actions/cache@v6
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarQube scanner
id: cache-sonar-scanner
uses: actions/cache@v6
with:
path: ./.sonar/scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarQube 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: Restore dependencies
run: dotnet restore
- name: Build and analyze
run: |
./.sonar/scanner/dotnet-sonarscanner begin /k:"${{ secrets.SONAR_PROJECT_KEY }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="${{ secrets.SONAR_HOST_URL }}" /d:sonar.coverage.exclusions="**/tests/**,**/Program.cs,**/Modules/**,**/*ServiceCollectionExtensions.cs,**/DesignTimeDbContextFactory.cs,**/DiscordOptions.cs,**/WorkspaceOptions.cs,**/MapOptions.cs,**/DiscordBotService.cs,**/DiscordUserDmSender.cs,**/DiscordChannelMessenger.cs,**/Discord*ChannelPoster.cs,**/DiscordTeamChatWebhookPoster.cs,**/DiscordWorkspaceGateway.cs" /d:sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml" /d:sonar.cpd.exclusions="**/Migrations/*.cs" /d:sonar.exclusions="**/Migrations/*.cs,**/obj/**,**/bin/**"
dotnet build --no-restore --configuration Release
dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage;Format=opencover" --blame-hang-timeout 60s
./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v7
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v7
with:
token: ${{ secrets.CODECOV_TOKEN }}
report_type: test_results