-
-
Notifications
You must be signed in to change notification settings - Fork 99
276 lines (254 loc) · 10.5 KB
/
ci.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
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
name: publish
on:
workflow_dispatch:
push:
branches:
- 'main'
pull_request:
branches:
- '*'
concurrency:
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_id || github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
NuGetDirectory: ${{ github.workspace}}/nuget
NuGetSource: "https://api.nuget.org/v3/index.json"
defaults:
run:
shell: pwsh
jobs:
validate_readme:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core (global.json)
uses: actions/setup-dotnet@v4
- name: Validate Readme
run: .\eng\update-readme.ps1
- name: Validate Tool Readme
run: .\eng\update-tool-readme.ps1
validate_test_projects:
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core (global.json)
uses: actions/setup-dotnet@v4
- name: Validate
run: .\eng\validate-testprojects-configuration.ps1
create_nuget:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core (global.json)
uses: actions/setup-dotnet@v4
- run: dotnet build eng/packages.proj --configuration Release /p:IsOfficialBuild=true /bl:build.binlog -warnaserror
- run: dotnet publish src/Meziantou.Framework.InlineSnapshotTesting.Prompt.TaskDialog --configuration Release --os win /p:IsOfficialBuild=true "--output:${{runner.temp}}/prompt" /bl:publish-taskdialog.binlog
- run: dotnet publish src/Meziantou.Framework.InlineSnapshotTesting.Prompt.NotificationTray --configuration Release --os win /p:IsOfficialBuild=true "--output:${{runner.temp}}/prompt" /bl:publish-notificationtray.binlog
- run: dotnet pack eng/packages.proj --configuration Release /p:IsOfficialBuild=true --output ${{ env.NuGetDirectory }} /p:RepositoryBranch="${{github.ref}}" "/p:PromptFolder=${{runner.temp}}/prompt" /bl:pack.binlog
- uses: actions/upload-artifact@v4
if: always()
with:
name: nuget
if-no-files-found: error
retention-days: 3
path: ${{ env.NuGetDirectory }}/**/*
- uses: actions/upload-artifact@v4
if: always()
with:
name: binlog
if-no-files-found: error
retention-days: 3
path: '**/*.binlog'
validate_nuget:
runs-on: ubuntu-24.04
needs: [ create_nuget ]
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core (global.json)
uses: actions/setup-dotnet@v4
- uses: actions/download-artifact@v4
with:
name: nuget
path: ${{ env.NuGetDirectory }}
- name: Validate NuGet packages
run: .\eng\validate-nuget.ps1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build_and_test_x64:
runs-on: ${{ matrix.runs-on }}
timeout-minutes: 60
env:
TestResultsDirectory: ${{ github.workspace}}/TestResults
strategy:
matrix:
runs-on: [ windows-2022, ubuntu-22.04, macos-14 ]
configuration: [ Debug, Release ]
additionalArguments: [ "", "/p:InvariantGlobalization=true" ]
fail-fast: false
steps:
- id: compute-artifact-name
name: Compute artifact name
run: |
$Name = "test-results-${{ matrix.runs-on }}-${{ matrix.configuration }}-x64-${{matrix.additionalArguments}}".Replace(":", "_").Replace("/", "_")
"artifact-name=$Name" >> $env:GITHUB_OUTPUT
- uses: actions/checkout@v4
- run: git config --global protocol.file.allow always
- name: Setup .NET Core (global.json)
uses: actions/setup-dotnet@v4
- name: Setup .NET Core (additional versions)
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
- name: Build
run: dotnet build eng/build.proj --configuration ${{ matrix.configuration }} /bl ${{ matrix.additionalArguments }}
- name: Run tests
run: dotnet test eng/build.proj --configuration ${{ matrix.configuration }} --no-build --logger trx --results-directory "${{ env.TestResultsDirectory }}" --collect:"Code Coverage" --blame-hang --blame-hang-timeout 5min ${{ matrix.additionalArguments }}
- uses: actions/upload-artifact@v4
if: always()
with:
name: ${{ steps.compute-artifact-name.outputs.artifact-name }}
if-no-files-found: error
retention-days: 3
path: |
**/*.binlog
${{ env.TestResultsDirectory }}/**/*
build_and_test_windows_x86:
runs-on: ${{ matrix.runs-on }}
timeout-minutes: 60
env:
TestResultsDirectory: ${{github.workspace}}/TestResults
Architecture: ${{ matrix.architecture }}
TestTfmsInParallel: false # Attempt to reduce flakiness
strategy:
matrix:
configuration: [ Debug, Release ]
additionalArguments: [ "", "/p:InvariantGlobalization=true" ]
include:
- runs-on: windows-2022
architecture: x86
fail-fast: false
steps:
- id: compute-artifact-name
name: Compute artifact name
run: |
$Name = "test-results-${{ matrix.runs-on }}-${{ matrix.configuration }}-${{ matrix.architecture }}-${{matrix.additionalArguments}}".Replace(":", "_").Replace("/", "_")
"artifact-name=$Name" >> $env:GITHUB_OUTPUT
- uses: actions/checkout@v4
- run: git config --global protocol.file.allow always
- name: Build and Run Tests
run: |
echo "::group::Install .NET"
echo "Downloading dotnet-install.ps1 script"
Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile 'dotnet-install.ps1'
echo "Installing .NET 8.0"
./dotnet-install.ps1 -Channel 8.0 -Architecture ${{ matrix.architecture }} -InstallDir ~/dotnet -NoPath
echo "Installing .NET (global.json)"
./dotnet-install.ps1 -JSonFile ${{github.workspace}}/global.json -Architecture ${{ matrix.architecture }} -InstallDir ~/dotnet
Get-Command dotnet
dotnet --info
echo "::endgroup::"
echo "::group::Build"
dotnet build eng/build.proj --configuration ${{ matrix.configuration }} /p:BuildInParallel=false /bl ${{ matrix.additionalArguments }}
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
echo "::endgroup::"
echo "::group::Run tests"
dotnet test eng/build.proj --configuration "${{ matrix.configuration }}" --no-build --logger trx --results-directory "${{ env.TestResultsDirectory }}" --collect:"Code Coverage" --blame-hang --blame-hang-timeout 5min ${{ matrix.additionalArguments }}
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
echo "::endgroup::"
- uses: actions/upload-artifact@v4
if: always()
with:
name: ${{ steps.compute-artifact-name.outputs.artifact-name }}
if-no-files-found: error
retention-days: 3
path: |
**/*.binlog
${{ env.TestResultsDirectory }}/**/*
test_trimming:
runs-on: ubuntu-24.04
timeout-minutes: 60
strategy:
matrix:
# https://docs.microsoft.com/en-us/dotnet/core/rid-catalog
runtime: [ "win-x64", "win-x86", "linux-x64", "osx-x64" ]
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core (global.json)
uses: actions/setup-dotnet@v4
- run: dotnet publish --configuration Release --runtime ${{ matrix.runtime }} --self-contained Samples/Trimmable/Trimmable.csproj
test_trimming_wpf:
runs-on: windows-2022
timeout-minutes: 60
strategy:
matrix:
runtime: [ "win-x64", "win-x86" ]
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core (global.json)
uses: actions/setup-dotnet@v4
- run: dotnet publish --configuration Release --runtime ${{ matrix.runtime }} --self-contained Samples/Trimmable.Wpf/Trimmable.Wpf.csproj
merge_coverage:
runs-on: ubuntu-24.04
needs: [build_and_test_x64, build_and_test_windows_x86]
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core (global.json)
uses: actions/setup-dotnet@v4
- name: Install dotnet-coverage
run: dotnet tool update --global dotnet-coverage
- name: Download test results
uses: actions/download-artifact@v4
with:
pattern: test-results-*
path: test-results
- name: Merge coverage files (format coverage)
run: dotnet-coverage merge --output test-result.coverage --output-format coverage (Get-ChildItem test-results -Recurse -Filter "*.coverage")
- name: Merge coverage files (format cobertura)
run: dotnet-coverage merge --output test-result.cobertura.xml --output-format cobertura (Get-ChildItem test-results -Recurse -Filter "*.coverage")
- uses: actions/upload-artifact@v4
with:
name: code-coverage
if-no-files-found: error
retention-days: 3
path: |
test-result.coverage
test-result.cobertura.xml
deploy:
runs-on: ubuntu-24.04
needs: [ validate_readme, validate_test_projects, validate_nuget, build_and_test_x64, build_and_test_windows_x86, test_trimming, test_trimming_wpf ]
steps:
- uses: actions/download-artifact@v4
with:
name: nuget
path: ${{ env.NuGetDirectory }}
- name: Setup .NET Core (global.json)
uses: actions/setup-dotnet@v4
- run: |
Write-Host "Current ref: $env:GITHUB_REF"
Write-Host "Searching nupkg in folder: ${{ env.NuGetDirectory }}"
$files = Get-ChildItem "${{ env.NuGetDirectory }}/*" -Include *.nupkg
foreach($file in $files) {
Write-Host "Pushing NuGet package: $($file.FullName)"
if ($env:GITHUB_REF -eq 'refs/heads/main')
{
& dotnet nuget push "$($file.FullName)" --api-key "$env:NUGETAPIKEY" --source ${{ env.NuGetSource }} --force-english-output --skip-duplicate
}
else
{
& dotnet nuget push "$($file.FullName)" --api-key "$env:FEEDZ_APIKEY" --source "https://f.feedz.io/meziantou/meziantou-framework/nuget/index.json" --force-english-output --skip-duplicate
}
}
name: Publish NuGet packages
if: always()
env:
NUGETAPIKEY: ${{ secrets.NUGETAPIKEY }}
FEEDZ_APIKEY: ${{ secrets.FEEDZ_APIKEY }}