-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (62 loc) · 1.83 KB
/
tests-base.yaml
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
79
name: Run Tests
on:
push:
branches-ignore:
- main
paths-ignore:
- "**.md"
- ".github/**"
- "!.github/workflows/tests-base.yaml"
workflow_call:
inputs:
sonarqube:
type: boolean
required: false
default: false
sonarqube_host:
type: string
required: false
secrets:
SONARQUBE_TOKEN:
required: false
jobs:
run-tests:
name: Run Tests
timeout-minutes: 10
runs-on: ubuntu-latest
env:
ASPNETCORE_ENVIRONMENT: Testing
steps:
- uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"
- uses: actions/checkout@v4
if: ${{ !inputs.sonarqube }}
- name: Run tests
run: dotnet test
###############################
########## SONARQUBE ##########
###############################
- name: Set up JDK
uses: actions/setup-java@v4
if: ${{ inputs.sonarqube }}
with:
distribution: "zulu"
java-version: "17"
- uses: actions/checkout@v4
if: ${{ inputs.sonarqube }}
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Restore tools
if: ${{ inputs.sonarqube }}
run: dotnet tool restore
- name: Run tests (SonarQube)
if: ${{ inputs.sonarqube }}
run: |
dotnet tool run dotnet-sonarscanner begin -k:"$PROJECT_KEY" \
-d:sonar.login="$SONARQUBE_TOKEN" \
-d:sonar.host.url="${{ inputs.sonarqube_host }}" \
-d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml
dotnet build --no-incremental
dotnet dotnet-coverage collect "dotnet test" -f xml -o "coverage.xml"
dotnet tool run dotnet-sonarscanner end -d:sonar.login="$SONARQUBE_TOKEN"