1
+ name : Static Analysis
2
+ on :
3
+ push :
4
+ branches :
5
+ - develop
6
+ paths :
7
+ - ' src/**'
8
+ - ' test/**'
9
+ - ' **.sln'
10
+ - ' .github/workflows/static-analysis.yml'
11
+ pull_request :
12
+ types : [opened, synchronize, reopened]
13
+ paths :
14
+ - ' src/**'
15
+ - ' test/**'
16
+ - ' **.sln'
17
+ - ' .github/workflows/static-analysis.yml'
18
+
19
+ env :
20
+ PROJECT_NAME : ' baynezy_Html2Markdown'
21
+ ORGANISATION : ' baynezy'
22
+ TEST_FILTER : " Category!=LocalTest"
23
+
24
+ jobs :
25
+ build :
26
+ name : Build and analyse
27
+ runs-on : ubuntu-latest
28
+ steps :
29
+ - name : Set up JDK 17
30
+ uses : actions/setup-java@v4
31
+ with :
32
+ java-version : 17
33
+ distribution : ' zulu'
34
+ - uses : actions/checkout@v4
35
+ with :
36
+ fetch-depth : 0 # This disables shallow clones. This allows SonarQube to access the history of the project to perform analysis.
37
+ - name : Cache SonarQube Cloud packages
38
+ uses : actions/cache@v4
39
+ with :
40
+ path : ~/.sonar/cache
41
+ key : ${{ runner.os }}-sonar
42
+ restore-keys : ${{ runner.os }}-sonar
43
+ - name : Cache SonarQube Cloud scanner
44
+ id : cache-sonar-scanner
45
+ uses : actions/cache@v4
46
+ with :
47
+ path : .sonar/scanner
48
+ key : ${{ runner.os }}-sonar-scanner
49
+ restore-keys : ${{ runner.os }}-sonar-scanner
50
+ - name : Install SonarQube Cloud scanner
51
+ if : steps.cache-sonar-scanner.outputs.cache-hit != 'true'
52
+ shell : bash
53
+ run : |
54
+ mkdir -p .sonar/scanner
55
+ dotnet tool update dotnet-sonarscanner --tool-path .sonar/scanner
56
+ - name : Install dotCover
57
+ shell : bash
58
+ run : |
59
+ dotnet tool install --global JetBrains.dotCover.GlobalTool
60
+ - name : Build, run code coverage, and analyze
61
+ env :
62
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
63
+ SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
64
+ shell : bash
65
+ run : |
66
+ filter=""
67
+
68
+ if [ "${{ env.TEST_FILTER }}" != "" ]; then
69
+ filter="--filter ${{ env.TEST_FILTER }}"
70
+ fi
71
+
72
+ .sonar/scanner/dotnet-sonarscanner begin /k:"${{ env.PROJECT_NAME }}" /o:"${{ env.ORGANISATION }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.dotcover.reportsPaths=dotCover.Output.html
73
+ dotnet build
74
+ dotnet dotcover test $filter --dcReportType=HTML
75
+ .sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
0 commit comments