-
Notifications
You must be signed in to change notification settings - Fork 1.9k
367 lines (343 loc) · 15.1 KB
/
dotnet_nugets.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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
name: .NET Nugets
on:
push:
branches:
- master
tags:
- '[0-9]+.[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+-*'
pull_request:
branches:
- '*'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.sha }}
cancel-in-progress: true
jobs:
build_nuget_dotnet:
strategy:
fail-fast: false
matrix:
config:
- { os: "windows-latest", runtime_id: "win-x64" }
- { os: "ubuntu-latest", runtime_id: "linux-x64" }
- { os: "macos-13", runtime_id: "osx-x64" }
runs-on: ${{matrix.config.os}}
steps:
# Setup for build
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Setup MSVC Developer Command Prompt
if: ${{ startsWith(matrix.config.os, 'windows') }}
uses: ilammy/msvc-dev-cmd@v1
- name: Install Ninja
uses: seanmiddleditch/gha-setup-ninja@master
- name: Install dotnet t4
run: dotnet tool install --global dotnet-t4
# Get version number
- name: Update git tags
# Needed because actions/checkout performs a shallow checkout without tags
run: git fetch --unshallow --tags --recurse-submodules=no
- name: Get version number
id: get_version
shell: bash
run: |
version=$(./utl/version_number.py)
version_trimmed=$(echo $version | sed 's/\+.*//')
echo "Generated version number: $version"
echo "version=$version" >> $GITHUB_OUTPUT
echo "version_trimmed=$version_trimmed" >> $GITHUB_OUTPUT
# Build .NET Core, all platforms
- name: Configure .NET Core
run: >
cmake -S . -B build -G Ninja
-Dvw_BUILD_NET_CORE=On
-Dvw_DOTNET_USE_MSPROJECT=Off
-DVW_NUGET_PACKAGE_NAME=VowpalWabbit
-DVW_NUGET_PACKAGE_VERSION="${{ steps.get_version.outputs.version }}"
-DVW_NUGET_PACKAGE_VERSION_TRIMMED="${{ steps.get_version.outputs.version_trimmed }}"
-DVW_FEAT_FLATBUFFERS=Off
-DRAPIDJSON_SYS_DEP=Off
-DFMT_SYS_DEP=Off
-DSPDLOG_SYS_DEP=Off
-DVW_ZLIB_SYS_DEP=Off
-DVW_BOOST_MATH_SYS_DEP=Off
-DVW_BUILD_VW_C_WRAPPER=Off
-DBUILD_TESTING=Off
-DBUILD_SHARED_LIBS=Off
- name: Build .NET Core
run: cmake --build build --config Release
- name: Install .NET Core
run: cmake --install build --prefix ./nuget_staging
# Build .NET Framework on Windows
- name: Reset build directory
if: ${{ startsWith(matrix.config.os, 'windows') }}
run: Remove-Item -Recurse -Force .\build
- name: Configure .NET Framework
if: ${{ startsWith(matrix.config.os, 'windows') }}
run: >
cmake -S . -B build -G "Visual Studio 17 2022" -A x64
-Dvw_BUILD_NET_FRAMEWORK=On
-DVW_NUGET_PACKAGE_NAME=VowpalWabbit
-DVW_NUGET_PACKAGE_VERSION="${{ steps.get_version.outputs.version }}"
-DVW_NUGET_PACKAGE_VERSION_TRIMMED="${{ steps.get_version.outputs.version_trimmed }}"
-DVW_FEAT_FLATBUFFERS=Off
-DRAPIDJSON_SYS_DEP=Off
-DFMT_SYS_DEP=Off
-DSPDLOG_SYS_DEP=Off
-DVW_ZLIB_SYS_DEP=Off
-DVW_BOOST_MATH_SYS_DEP=Off
-DVW_BUILD_VW_C_WRAPPER=Off
-DBUILD_TESTING=Off
-DBUILD_SHARED_LIBS=Off
- name: Build .NET Framework
if: ${{ startsWith(matrix.config.os, 'windows') }}
run: cmake --build build --config Release
- name: Install .NET Framework
if: ${{ startsWith(matrix.config.os, 'windows') }}
run: cmake --install build --prefix ./nuget_staging
# Create the combined package on Windows
- name: Package Combined
if: ${{ startsWith(matrix.config.os, 'windows') }}
shell: powershell
id: generate-nuget
run: |
cd nuget_staging
nuget pack dotnet.nuspec
$NugetFileName = Get-ChildItem *.nupkg -name
echo "NugetFileName=$NugetFileName" >> $GITHUB_OUTPUT
- name: Upload Combined
if: ${{ startsWith(matrix.config.os, 'windows') }}
uses: actions/upload-artifact@v1
with:
name: VowpalWabbit.${{steps.get_version.outputs.version}}.nupkg
path: nuget_staging/${{ steps.generate-nuget.outputs.NugetFileName }}
# Create the .NET Core runtime package, all platforms
- name: Package .NET Core Runtime
shell: bash
id: generate-runtime-nuget
run: |
cd nuget_staging
nuget pack dotnetcore_runtime.nuspec
NugetFileName=(*runtime*.nupkg)
echo "NugetFileName=${NugetFileName[0]}" >> $GITHUB_OUTPUT
- name: Upload .NET Core Runtime
uses: actions/upload-artifact@v1
with:
name: VowpalWabbit.runtime.${{matrix.config.runtime_id}}.${{steps.get_version.outputs.version}}.nupkg
path: nuget_staging/${{ steps.generate-runtime-nuget.outputs.NugetFileName }}
test_nuget_dotnetcore:
needs: [build_nuget_dotnet]
strategy:
fail-fast: false
matrix:
config:
- { os: "windows-latest", runtime_id: "win-x64" }
- { os: "ubuntu-latest", runtime_id: "linux-x64" }
- { os: "macos-13", runtime_id: "osx-x64" }
runs-on: ${{matrix.config.os}}
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- if: ${{ startsWith(matrix.config.os, 'windows') }}
uses: ilammy/msvc-dev-cmd@v1
# Get version number
- name: Update git tags
# Needed because actions/checkout performs a shallow checkout without tags
run: git fetch --unshallow --tags --recurse-submodules=no
- name: Get version number
id: get_version
shell: bash
run: |
version=$(./utl/version_number.py)
echo "Generated version number: $version"
echo "version=$version" >> $GITHUB_OUTPUT
# Download the previously built Nuget packages
- name: Clear nuget cache
run: dotnet nuget locals all --clear
- uses: actions/download-artifact@v1
with:
name: VowpalWabbit.${{steps.get_version.outputs.version}}.nupkg
path: downloaded_nugets
- uses: actions/download-artifact@v1
with:
name: VowpalWabbit.runtime.win-x64.${{steps.get_version.outputs.version}}.nupkg
path: downloaded_nugets
- uses: actions/download-artifact@v1
with:
name: VowpalWabbit.runtime.linux-x64.${{steps.get_version.outputs.version}}.nupkg
path: downloaded_nugets
- uses: actions/download-artifact@v1
with:
name: VowpalWabbit.runtime.osx-x64.${{steps.get_version.outputs.version}}.nupkg
path: downloaded_nugets
- name: List downloaded packages
run: ls downloaded_nugets
# Some of these commands may generate an error message because we are installing packages from local source with remote dependencies
# The missing dependencies are installed in later steps
- name: Install package
run: |
set +e
cd nuget/dotnet/test
dotnet add dotnetcore_nuget_test.csproj package VowpalWabbit --version ${{steps.get_version.outputs.version}} --source "${{github.workspace}}/downloaded_nugets" --no-restore
dotnet restore dotnetcore_nuget_test.csproj --runtime ${{matrix.config.runtime_id}} --source "${{github.workspace}}/downloaded_nugets"
dotnet restore dotnetcore_nuget_test.csproj --runtime ${{matrix.config.runtime_id}}
exit 0
- name: Build and run test
run: |
cd nuget/dotnet/test
dotnet build dotnetcore_nuget_test.csproj --runtime ${{matrix.config.runtime_id}} --output build --no-restore --self-contained
./build/dotnetcore_nuget_test
test_nuget_dotnetframework:
needs: [build_nuget_dotnet]
runs-on: "windows-latest"
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- uses: ilammy/msvc-dev-cmd@v1
# Get version number
- name: Update git tags
# Needed because actions/checkout performs a shallow checkout without tags
run: git fetch --unshallow --tags --recurse-submodules=no
- name: Get version number
id: get_version
shell: bash
run: |
version=$(./utl/version_number.py)
echo "Generated version number: $version"
echo "version=$version" >> $GITHUB_OUTPUT
# Download the previously built Nuget packages
- name: Clear nuget cache
run: dotnet nuget locals all --clear
- uses: actions/download-artifact@v1
with:
name: VowpalWabbit.${{steps.get_version.outputs.version}}.nupkg
path: downloaded_nugets
- uses: actions/download-artifact@v1
with:
name: VowpalWabbit.runtime.win-x64.${{steps.get_version.outputs.version}}.nupkg
path: downloaded_nugets
- uses: actions/download-artifact@v1
with:
name: VowpalWabbit.runtime.linux-x64.${{steps.get_version.outputs.version}}.nupkg
path: downloaded_nugets
- uses: actions/download-artifact@v1
with:
name: VowpalWabbit.runtime.osx-x64.${{steps.get_version.outputs.version}}.nupkg
path: downloaded_nugets
- name: List downloaded packages
run: ls downloaded_nugets
# Some of these commands may generate an error message because we are installing packages from local source with remote dependencies
# The missing dependencies are installed in later steps
- name: Install package
run: |
set +e
cd nuget/dotnet/test
dotnet add dotnetframework_nuget_test.csproj package VowpalWabbit --version ${{steps.get_version.outputs.version}} --source "${{github.workspace}}/downloaded_nugets" --no-restore
dotnet restore dotnetframework_nuget_test.csproj --runtime win-x64 --source "${{github.workspace}}/downloaded_nugets"
dotnet restore dotnetframework_nuget_test.csproj --runtime win-x64
exit 0
- name: Build and run test
run: |
cd nuget/dotnet/test
dotnet build dotnetframework_nuget_test.csproj --runtime win-x64 --output build --no-restore --self-contained
./build/dotnetframework_nuget_test
benchmark_nuget:
needs: [build_nuget_dotnet]
runs-on: "windows-latest"
permissions:
contents: write
deployments: write
if: ${{ github.event_name == 'push' && github.ref_name == 'master' }}
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- uses: ilammy/msvc-dev-cmd@v1
# Needed for generating benchmark plots
- uses: r-lib/actions/setup-r@v2
# Get version number
- name: Update git tags
# Needed because actions/checkout performs a shallow checkout without tags
run: git fetch --unshallow --tags --recurse-submodules=no
- name: Get version number
id: get_version
shell: bash
run: |
version=$(./utl/version_number.py)
echo "Generated version number: $version"
echo "version=$version" >> $GITHUB_OUTPUT
# Download the previously built Nuget packages
- name: Clear nuget cache
run: dotnet nuget locals all --clear
- uses: actions/download-artifact@v1
with:
name: VowpalWabbit.${{steps.get_version.outputs.version}}.nupkg
path: downloaded_nugets
- uses: actions/download-artifact@v1
with:
name: VowpalWabbit.runtime.win-x64.${{steps.get_version.outputs.version}}.nupkg
path: downloaded_nugets
- uses: actions/download-artifact@v1
with:
name: VowpalWabbit.runtime.linux-x64.${{steps.get_version.outputs.version}}.nupkg
path: downloaded_nugets
- uses: actions/download-artifact@v1
with:
name: VowpalWabbit.runtime.osx-x64.${{steps.get_version.outputs.version}}.nupkg
path: downloaded_nugets
- name: List downloaded packages
run: ls downloaded_nugets
# Some of these commands may generate an error message because we are installing packages from local source with remote dependencies
# The missing dependencies are installed in later steps
- name: Install package
run: |
set +e
cd test/benchmarks/dotnet
dotnet add dotnet_benchmark.csproj package VowpalWabbit --version ${{steps.get_version.outputs.version}} --source "${{github.workspace}}/downloaded_nugets" --no-restore
dotnet add dotnet_benchmark.csproj package VowpalWabbit.runtime.win-x64 --version ${{steps.get_version.outputs.version}} --source "${{github.workspace}}/downloaded_nugets" --no-restore
dotnet restore dotnet_benchmark.csproj --runtime win-x64 --source "${{github.workspace}}/downloaded_nugets"
dotnet restore dotnet_benchmark.csproj --runtime win-x64
exit 0
- name: Build and run benchmarks
run: |
cd test/benchmarks/dotnet
# Build for both .NET Core and Framework
dotnet build dotnet_benchmark.csproj --framework net6.0 --runtime win-x64 --configuration Release --no-restore --self-contained
dotnet build dotnet_benchmark.csproj --framework net4.8 --runtime win-x64 --configuration Release --no-restore --self-contained
# Run with .NET Core as host process
# Arguments after "--" are for BenchmarkDotNet
dotnet run --project dotnet_benchmark.csproj --framework net6.0 --runtime win-x64 --configuration Release --no-build -- --filter '*' --join
# Generate output for Github workflow artifacts
- name: Print benchmark results
shell: bash
run: |
cd test/benchmarks/dotnet/BenchmarkDotNet.Artifacts/results
echo "## .NET Benchmark Results" >> $GITHUB_STEP_SUMMARY
cat BenchmarkRun-joined-*.md | sed 's/\*\*//g' >> $GITHUB_STEP_SUMMARY
- name: Upload benchmark artifacts
uses: actions/upload-artifact@v3
with:
name: benchmark_results
path: test/benchmarks/dotnet/BenchmarkDotNet.Artifacts/results/
# Generate output for github-action-benchmark
- name: Reset dotnet_benchmark.csproj
run: git restore test/benchmarks/dotnet/dotnet_benchmark.csproj
- name: Filter only .NET Core output for github-action-benchmark
shell: bash
run: |
cd test/benchmarks/dotnet/BenchmarkDotNet.Artifacts/results
cat BenchmarkRun-joined-*.json | jq '.Benchmarks |= map(select(.DisplayInfo | contains(".NET Framework") | not))' > BenchmarkRun.json
- uses: benchmark-action/github-action-benchmark@v1
with:
tool: 'benchmarkdotnet'
output-file-path: test/benchmarks/dotnet/BenchmarkDotNet.Artifacts/results/BenchmarkRun.json
alert-threshold: '200%'
fail-on-alert: true
comment-on-alert: true
auto-push: false
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Push results to gh-pages branch
run: git push 'https://VowpalWabbit:${{ secrets.GITHUB_TOKEN }}@github.com/VowpalWabbit/vowpal_wabbit.git' gh-pages:gh-pages