Repository navigation
229 lines (181 loc) · 8.16 KB
/
Copy pathdotnet.yml
File metadata and controls
229 lines (181 loc) · 8.16 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
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
name: .NET
on:
workflow_dispatch:
push:
branches: [main]
pull_request:
branches: [main]
env:
RETENTION_DAYS: 5
packageVersionPrefix: ${{ '6.3.' }}
packageVersionSuffixForFeatureBranch: ${{ '-alpha' }}
packageVersionSuffixForMainBranch: ${{ '-alpha' }}
jobs:
build-and-test:
runs-on: ubuntu-latest
name: Build and test
steps:
- uses: actions/checkout@v4
- name: Setup environment variables (main branch)
if: github.ref == 'refs/heads/main'
run: echo "packageVersion=${{ env.packageVersionPrefix }}${{ github.run_number }}${{ env.packageVersionSuffixForMainBranch }}" >> $GITHUB_ENV
- name: Setup environment variables (feature branch)
if: github.ref != 'refs/heads/main'
run: echo "packageVersion=${{ env.packageVersionPrefix }}${{ github.run_number }}${{ env.packageVersionSuffixForFeatureBranch }}" >> $GITHUB_ENV
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: Install dotnet global tools (coverlet, reportgenerator)
run: |
dotnet tool install --global coverlet.console
dotnet tool install --global dotnet-reportgenerator-globaltool
dotnet tool install --global SpecFlow.Plus.LivingDoc.CLI
- name: Install dependencies
run: dotnet restore
- name: Build
run: |
dotnet build --configuration Debug --no-restore
dotnet build --configuration Release --no-restore TestProcessWrapper.LongLived.Application/TestProcessWrapper.LongLived.Application.csproj
- name: Test with coverage
run: dotnet test --no-restore --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput='./TestResults/coverage.cobertura.xml'
- name: Build NuGet package
run: |
dotnet pack --configuration Debug TestProcessWrapper/TestProcessWrapper.csproj /p:PackageVersion=${{ env.packageVersion }}
echo "packageVersion=${{ env.packageVersion }}" > TestProcessWrapper/bin/Debug/VERSION.txt
- name: Generate coverage reports
run: reportgenerator "-reports:TestProcessWrapper.Acceptance.Tests/TestResults/*.xml;TestProcessWrapper.Unit.Tests/TestResults/*.xml" \
"-targetdir:report" \
"-reporttypes:Html;lcov" \
"-title:TestProcessWrapper"
- name: Generate SpecFlow LivingDoc
run: livingdoc test-assembly TestProcessWrapper.Acceptance.Tests.dll -t TestExecution.json
working-directory: TestProcessWrapper.Acceptance.Tests/bin/Debug/net8.0
- name: Attach NuGet package to build artifacts
uses: actions/upload-artifact@v4
with:
name: nuget-package
path: |
TestProcessWrapper/bin/Debug/Boos.TestProcessWrapper.${{ env.packageVersion }}.nupkg
TestProcessWrapper/bin/Debug/VERSION.txt
- name: Attach coverage reports to build artifacts
uses: actions/upload-artifact@v4
with:
name: coverage-reports
path: report
- name: Attach LivingDoc to build artifacts
uses: actions/upload-artifact@v4
with:
name: LivingDoc
path: TestProcessWrapper.Acceptance.Tests/bin/Debug/net8.0/LivingDoc.html
smoketest:
name: Test NuGet package
needs: build-and-test
strategy:
matrix:
os: [ macos-latest, windows-latest, ubuntu-latest ]
dotnet:
- { setupVersion: 6.x, binFolder: net6.0 }
- { setupVersion: 7.x, binFolder: net7.0 }
- { setupVersion: 8.x, binFolder: net8.0 }
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup environment variables (main branch)
if: github.ref == 'refs/heads/main'
run: echo "packageVersion=${{ env.packageVersionPrefix }}${{ github.run_number }}${{ env.packageVersionSuffixForMainBranch }}" >> $GITHUB_ENV
- name: Setup environment variables (feature branch)
if: github.ref != 'refs/heads/main'
run: echo "packageVersion=${{ env.packageVersionPrefix }}${{ github.run_number }}${{ env.packageVersionSuffixForFeatureBranch }}" >> $GITHUB_ENV
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet.setupVersion }}
- name: Download nuget package
uses: actions/download-artifact@v4
with:
name: nuget-package
path: ./TestProcessWrapper/bin/Debug
# Downloading the nuget package to this path allows to run the ./smoketest.sh script on your
# local development machine without changes
- name: Test NuGet package
run: ./smoketest.sh "${{ matrix.dotnet.binFolder }}"
working-directory: TestProcessWrapper.Nupkg.Tests
publish-reports:
runs-on: ubuntu-latest
name: Publish coverage reports
if: github.ref == 'refs/heads/main'
needs: smoketest
steps:
# the repository is required by codeclimate-action
- uses: actions/checkout@v4
- name: Download coverage reports
uses: actions/download-artifact@v4
with:
name: coverage-reports
path: coverage-reports
- name: Publish coverage report to coveralls.io
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: coverage-reports/lcov.info
- name: Publish coverage report to CodeClimate
uses: paambaati/codeclimate-action@v8.0.0
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageLocations: coverage-reports/lcov.info:lcov
publish-nuget:
runs-on: ubuntu-latest
name: Publish NuGet package
needs: smoketest
steps:
- name: Download NuGet package
uses: actions/download-artifact@v4
with:
name: nuget-package
path: nuget-package
- name: Identify package version
run: cat nuget-package/VERSION.txt >> $GITHUB_ENV
- name: Publish NuGet package
if: github.ref == 'refs/heads/main'
run: dotnet nuget push nuget-package/Boos.TestProcessWrapper.${{ env.packageVersion }}.nupkg --skip-duplicate --api-key ${{ secrets.NUGET_API_ACESS_TOKEN }} --source https://api.nuget.org/v3/index.json
release:
runs-on: ubuntu-latest
name: Release
needs: publish-nuget
# Configure GITHUB_TOKEN so that it allows uploading to the release
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
- name: Identify package version
run: cat nuget-package/VERSION.txt >> $GITHUB_ENV
- name: Create release folder
run: mkdir release
- name: Create release ZIP
run: |
mv -v nuget-package/*.nupkg ./release/
mv -v coverage-reports ./release/
mv -v LivingDoc/LivingDoc.html ./release/features.html
mv -v release Boos.TestProcessWrapper.${{ env.packageVersion }}
zip -r9 Boos.TestProcessWrapper.${{ env.packageVersion }}.zip Boos.TestProcessWrapper.${{ env.packageVersion }}
# Adopted from https://github.com/svenstaro/upload-release-action
- name: Read CHANGELOG.md and use it as a body of new release
id: read_release
run: |
r=$(./build/extract_latest_changelog.sh) # <--- Read CHANGELOG.md
r="${r//'%'/%25}" # Multiline escape sequences for %
r="${r//$'\n'/%0A}" # Multiline escape sequences for '\n'
r="${r//$'\r'/%0D}" # Multiline escape sequences for '\r'
echo "RELEASE_BODY=$r" >> $GITHUB_OUTPUT # <--- Set environment variable
- name: Upload applications to release
if: github.ref == 'refs/heads/main'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: Boos.TestProcessWrapper.${{ env.packageVersion }}.zip
tag: ${{ env.packageVersion }}
overwrite: true
body: ${{ steps.read_release.outputs.RELEASE_BODY }}