-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (53 loc) · 2.53 KB
/
Copy pathsonarcloud-scan.yml
File metadata and controls
53 lines (53 loc) · 2.53 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
name: SonarCloud Scan
on:
push:
branches:
- master
jobs:
build:
name: Build, test and analyze
runs-on: ubuntu-latest
steps:
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'zulu' # Alternative distribution options are available.
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@v3
with:
path: ./.sonar/scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- 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: Static analyzers
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
./.sonar/scanner/dotnet-sonarscanner begin /k:"efthymios-ks_CoreSharp.ReflectionCache" /o:"efthymios-ks" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
dotnet build ./CoreSharp.ReflectionCache/CoreSharp.ReflectionCache.csproj --no-incremental
./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
- name: Test coverage
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
./.sonar/scanner/dotnet-sonarscanner begin /k:"efthymios-ks_CoreSharp.ReflectionCache" /o:"efthymios-ks" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.coverage.inclusions="./CoreSharp.ReflectionCache/**/*.cs" /d:sonar.cs.opencover.reportsPaths=coverage.xml
dotnet tool install coverlet.console --global
dotnet build CoreSharp.ReflectionCache.Tests/CoreSharp.ReflectionCache.Tests.csproj --no-incremental
coverlet CoreSharp.ReflectionCache.Tests/bin/Debug/**/CoreSharp.ReflectionCache.Tests.dll --target "dotnet" --targetargs "test --no-build" -f=opencover -o="coverage.xml"
./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"