-
Notifications
You must be signed in to change notification settings - Fork 0
157 lines (144 loc) · 5.02 KB
/
step-dotnet-tests.yml
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
on:
workflow_call:
inputs:
enableSonarQube:
required: false
type: boolean
default: false
enableCleanUpDockerDocker:
required: false
type: boolean
default: false
disableCoverageUpload:
required: false
type: boolean
default: false
dotnet-logging:
required: false
type: string
default: quiet
dotnet-version:
required: false
type: string
default: 8.x
dotnet-quality:
required: false
type: string
default: ga
runs-on:
required: false
type: string
default: ubuntu-latest
solution:
required: true
type: string
solution-version:
required: true
type: string
retry-max-attempts:
required: false
type: number
default: 3
retry-timeout:
required: false
type: number
default: 15
secrets:
CODECOV_TOKEN:
required: false
SONAR_ORGANIZATION:
required: false
SONAR_PROJECT:
required: false
SONAR_TOKEN:
required: false
FETCH_TOKEN:
required: false
jobs:
testing:
name: Testing .NET solution
runs-on: ${{ inputs.runs-on || 'ubuntu-latest' }}
env:
codecov_token: ${{ secrets.CODECOV_TOKEN }}
steps:
- name: Checkout repository
uses: actions/[email protected]
with:
fetch-depth: 0
submodules: recursive
token: ${{ secrets.FETCH_TOKEN || github.token }}
# Our modules occupy too much disk space. The GitHub-hosted runners ran into the
# error: "no space left on device." The pulled images are not cleaned up between
# the test runs. One obvious approach is splitting the tests and running them on
# multiple runners. However, we need to keep in mind that running too many
# simultaneous builds has an impact on others as well. We observed that scheduled
# Dependabot builds blocked others in the Testcontainers organization.
- name: Free Disk Space - Docker Images
uses: jlumbroso/[email protected]
if: ${{ inputs.enableCleanUpDockerDocker == true && runner.os == 'Linux' }}
with:
android: true
haskell: true
dotnet: false
large-packages: false
tool-cache: false
swap-storage: false
docker-images: true
- name: Setup .NET
uses: actions/[email protected]
with:
dotnet-version: ${{ inputs.dotnet-version }}
dotnet-quality: ${{ inputs.dotnet-quality }}
- name: Setup JDK 17
if: ${{ inputs.enableSonarQube == true }}
uses: actions/[email protected]
with:
java-version: 17
distribution: 'zulu'
- name: Install SonarCloud scanner
if: ${{ inputs.enableSonarQube == true }}
shell: pwsh
run: dotnet tool install --global dotnet-sonarscanner
- name: Start SonarQube Analysis
if: ${{ inputs.enableSonarQube == true }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: pwsh
run: |
dotnet-sonarscanner begin /k:"${{ secrets.SONAR_PROJECT }}" /o:"${{ secrets.SONAR_ORGANIZATION }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="**/*.opencover.xml" /v:"${{ inputs.solution-version }}"
- name: Restore dependencies
run: dotnet restore ${{ inputs.solution }} -v ${{ inputs.dotnet-logging }}
- name: Build
run: dotnet build ${{ inputs.solution }} -c Release -v ${{ inputs.dotnet-logging || 'quiet' }} --no-restore /p:GeneratePackageOnBuild=false
- name: Test
id: test
uses: nick-fields/[email protected]
with:
timeout_minutes: ${{ inputs.retry-timeout || 15 }}
max_attempts: ${{ inputs.retry-max-attempts || 1 }}
shell: pwsh
command: |
dotnet test ${{ inputs.solution }} -c Release -v ${{ inputs.dotnet-logging }} --no-build --no-restore --collect:"XPlat Code Coverage;Format=cobertura,opencover" /p:GeneratePackageOnBuild=false -- --coverage --coverage-output-format cobertura
- name: Stop SonarQube Analysis
if: ${{ inputs.enableSonarQube == true && (success() || steps.test.conclusion == 'failure') }}
id: sonar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: pwsh
run: |
dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
- name: Update codecov
uses: codecov/[email protected]
if: ${{ env.codecov_token != '' && (success() || steps.test.conclusion == 'failure' || steps.sonar.conclusion == 'skipped' ) }}
with:
token: ${{ env.codecov_token }}
fail_ci_if_error: true
- name: Upload Coverage Reports
uses: actions/[email protected]
if: ${{ inputs.disableCoverageUpload == false }}
with:
name: "coverage"
path: |
**/TestResults/**/*.opencover.xml