-
-
Notifications
You must be signed in to change notification settings - Fork 147
176 lines (168 loc) · 5.88 KB
/
test.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
name: test
on:
workflow_call:
pull_request:
branches:
- '**'
push:
branches:
- main
# run on the first day of each month
# since the coverage artifacts will expire after 35d
schedule:
- cron: '0 0 1 * *'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
- run: dotnet build /p:TreatWarningsAsErrors=true
- run: dotnet test --no-build --logger 'junit' /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura
- uses: test-summary/action@v2
if: always()
with:
paths: 'test/**/TestResults/**/*.xml'
- uses: danielpalme/ReportGenerator-GitHub-Action@v5
if: always()
with:
reports: 'test/**/*cobertura.xml'
reporttypes: 'Cobertura'
targetdir: '${{ github.workspace }}'
- uses: clearlyip/code-coverage-report-action@v5
id: code_coverage_report_action
# dont run for dependabot
if: ${{ always() && github.actor != 'dependabot[bot]'}}
with:
filename: 'Cobertura.xml'
overall_coverage_fail_threshold: 75
retention_days: 35
package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: sudo apt update && sudo apt -y install zipmerge # zipmerge is used to merge the multi target nupkg
- uses: actions/setup-dotnet@v4
- run: dotnet tool restore
- run: RELEASE_VERSION="0.0.1-dev.$GITHUB_RUN_ID" ./build/package.sh
- uses: actions/upload-artifact@v4
with:
name: mapperly-nupkg
path: artifacts/*.nupkg
- if: failure()
uses: actions/upload-artifact@v4
with:
name: verify-test-results-package
path: '**/*.received.*'
retention-days: 3
validate-package:
needs: package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
- run: dotnet tool restore
- uses: actions/download-artifact@v4
with:
name: mapperly-nupkg
path: artifacts
- run: dotnet meziantou.validate-nuget-package ./artifacts/*.nupkg
- run: dotnet validate package local ./artifacts/*.nupkg
integration-test:
needs: package
runs-on: ubuntu-latest
# use an alpine container to ensure only the dotnet version we want to test is installed,
# ubuntu-latest already contains several dotnet versions...
container:
image: alpine:3.17
strategy:
fail-fast: false
matrix:
dotnet:
- '9.0'
- '8.0'
- '7.0'
- '6.0'
steps:
- uses: actions/checkout@v4
# install required dotnet dependencies
# https://learn.microsoft.com/en-us/dotnet/core/install/linux-alpine#dependencies
- run: apk add --no-cache bash icu-libs krb5-libs libgcc libintl libssl1.1 libstdc++ zlib
# delete global.json since we want to use custom versions here
- run: rm global.json
- uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet }}
- run: dotnet --list-sdks
- uses: actions/download-artifact@v4
with:
name: mapperly-nupkg
path: artifacts
# use nupkg artifact for integration tests instead of project references
- run: dotnet nuget add source "$(pwd)/artifacts"
- run: >-
dotnet build
-f net${{ matrix.dotnet }}
-p:MapperlyIntegrationTestsTargetFramework=net${{ matrix.dotnet }}
-p:MapperlyNugetPackageVersion="0.0.1-dev.$GITHUB_RUN_ID"
working-directory: ./test/Riok.Mapperly.IntegrationTests
- run: dotnet test --no-build -f net${{ matrix.dotnet }}
working-directory: ./test/Riok.Mapperly.IntegrationTests
- if: failure()
uses: actions/upload-artifact@v4
with:
name: verify-test-results-net${{ matrix.dotnet }}
path: '**/*.received.*'
retention-days: 3
integration-test-net-framework:
needs: package
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
# delete global.json since we want to use custom versions here
- run: rm global.json
- uses: actions/download-artifact@v4
with:
name: mapperly-nupkg
path: artifacts
# use nupkg artifact for integration tests instead of project references
- run: dotnet nuget add source "$(Get-Location)/artifacts"
- run: >-
dotnet build
-f net48
-p:MapperlyIntegrationTestsTargetFramework=net48
-p:MapperlyNugetPackageVersion=0.0.1-dev.$env:GITHUB_RUN_ID
working-directory: ./test/Riok.Mapperly.IntegrationTests
- run: dotnet test --no-build -f net48
working-directory: ./test/Riok.Mapperly.IntegrationTests
- if: failure()
uses: actions/upload-artifact@v4
with:
name: verify-test-results-net-framework
path: '**/*.received.*'
retention-days: 3
sample:
runs-on: ubuntu-latest
needs: package
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
- run: dotnet run --project ./samples/Riok.Mapperly.Sample
# run the same again with the real nuget without runtime assets
- uses: actions/download-artifact@v4
with:
name: mapperly-nupkg
path: artifacts
# use nupkg artifact instead of project references
- run: dotnet nuget add source "$(pwd)/artifacts"
- run: dotnet clean
- run: dotnet build -p:MapperlyNugetPackageVersion="0.0.1-dev.$GITHUB_RUN_ID"
working-directory: ./samples/Riok.Mapperly.Sample
- run: dotnet run --no-build
working-directory: ./samples/Riok.Mapperly.Sample