-
-
Notifications
You must be signed in to change notification settings - Fork 172
290 lines (247 loc) · 10.6 KB
/
build.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
name: 🏭 Build
on:
push:
branches:
- main
- 'v*.*'
- validate/*
pull_request:
workflow_dispatch:
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
BUILDCONFIGURATION: Release
# codecov_token: 4dc9e7e2-6b01-4932-a180-847b52b43d35 # Get a new one from https://codecov.io/
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages/
# dotnetfoundation code signing
jobs:
build:
name: 🏭 Build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-22.04
- windows-2022
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
submodules: true
- name: ⚙ Install prerequisites
run: |
./init.ps1 -UpgradePrerequisites
dotnet --info
# Print mono version if it is present.
if (Get-Command mono -ErrorAction SilentlyContinue) {
mono --version
}
shell: pwsh
- name: ⚙ Install 32-bit .NET SDK and runtimes
shell: pwsh
run: |
Invoke-WebRequest -Uri "https://dot.net/v1/dotnet-install.ps1" -OutFile dotnet-install.ps1
& .\dotnet-install.ps1 -Architecture x86 -Version 9.0.101 -InstallDir "C:\Program Files (x86)\dotnet\" -NoPath -Verbose
if: runner.os == 'Windows'
- name: ⚙️ Set pipeline variables based on source
run: tools/variables/_define.ps1
shell: pwsh
- name: 🛠 build
run: dotnet build -t:build,pack --no-restore -c ${{ env.BUILDCONFIGURATION }} -warnAsError -warnNotAsError:NU1901,NU1902,NU1903,NU1904 /bl:"${{ runner.temp }}/_artifacts/build_logs/build.binlog"
- name: 🛠️ Build LKG package
run: dotnet pack -c ${{ env.BUILDCONFIGURATION }} --no-build -p:PackLKG=true /bl:"${{ runner.temp }}/_artifacts/build_logs/msbuild_lkg.binlog"
working-directory: src/Nerdbank.GitVersioning.Tasks
- name: 📢 Publish nbgv tool
run: dotnet publish -c ${{ env.BUILDCONFIGURATION }} -o ../nerdbank-gitversioning.npm/out/nbgv.cli/tools/net8.0/any /bl:"${{ runner.temp }}/_artifacts/build_logs/nbgv_publish.binlog"
working-directory: src/nbgv
- name: 🛠️ Build nerdbank-gitversioning NPM package
run: yarn build
working-directory: src/nerdbank-gitversioning.npm
- name: Capture .git directory
shell: pwsh
run: |
md ${{ runner.temp }}\_artifacts\drop
7z a ${{ runner.temp }}\_artifacts\drop\nbgv.7z * -r
Write-Host "##vso[artifact.upload containerfolder=drop;artifactname=drop;]${{ runner.temp }}\_artifacts\drop"
if: failure() && runner.os == 'Windows'
- name: 🧪 test
run: |
Write-Host "⚙️ Configure git commit author for testing"
git config --global user.name ci
git config --global user.email [email protected]
Write-Host "🧪 Run tests"
tools/dotnet-test-cloud.ps1 -Configuration ${{ env.BUILDCONFIGURATION }} -Agent ${{ runner.os }} -PublishResults
shell: pwsh
- name: 🧪 test x86
run: tools/dotnet-test-cloud.ps1 -Configuration ${{ env.BUILDCONFIGURATION }} -Agent ${{ runner.os }} -PublishResults -X86
if: success() && runner.os == 'Windows'
- name: 💅🏻 Verify formatted code
run: dotnet format --verify-no-changes --no-restore
shell: pwsh
if: runner.os == 'Linux'
- name: 📚 Verify docfx build
run: dotnet docfx docfx/docfx.json --warningsAsErrors --disableGitFeatures
if: runner.os == 'Linux'
- name: ⚙ Update pipeline variables based on build outputs
run: tools/variables/_define.ps1
shell: pwsh
- name: 📢 Publish artifacts
uses: ./.github/actions/publish-artifacts
if: cancelled() == false
- name: 📦 Push CI package
shell: pwsh
run: |
if ('${{ secrets.AZP_TOKEN }}') {
dotnet nuget add source https://pkgs.dev.azure.com/andrewarnott/OSS/_packaging/PublicCI/nuget/v3/index.json -n publicCI -u andrewarnott -p ${{ secrets.AZP_TOKEN }} --store-password-in-clear-text
dotnet nuget push ${{ runner.temp }}/_artifacts/deployables/*.nupkg -s publicCI -k x
dotnet nuget push ${{ runner.temp }}/_artifacts/deployables-LKG/*.nupkg -s publicCI -k x
}
if: success() && runner.os == 'Linux' && github.event_name != 'pull_request'
continue-on-error: true
- name: 📢 Publish code coverage results to codecov.io
run: ./tools/publish-CodeCov.ps1 -CodeCovToken "${{ env.codecov_token }}" -PathToCodeCoverage "${{ runner.temp }}/_artifacts/coverageResults" -Name "${{ runner.os }} Coverage Results" -Flags "${{ runner.os }}"
shell: pwsh
timeout-minutes: 3
continue-on-error: true
if: env.codecov_token != ''
functional_testing:
name: 🧪 Functional testing
needs: build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
container: mcr.microsoft.com/dotnet/sdk:8.0-jammy
- os: ubuntu-22.04
container: mcr.microsoft.com/dotnet/sdk:9.0-noble
- os: ubuntu-22.04
container: mcr.microsoft.com/dotnet/sdk:8.0
- os: ubuntu-22.04
container: mcr.microsoft.com/dotnet/sdk:9.0
- os: macos-14
container: ""
# This uses a matrix value for the container; macOS will have an empty string, which means no container.
container:
image: ${{ matrix.container }}
# GitHub Actions will ignore an empty image automatically.
steps:
- name: Show .NET SDK info
shell: pwsh
run: dotnet --info
- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
name: deployables-Windows
path: deployables
- name: Set up git username and email address
shell: pwsh
run: |
git config --global init.defaultBranch main
git config --global user.name ci
git config --global user.email [email protected]
- name: Consume NB.GV from .NET build
shell: bash
run: >
PkgFileName=$(ls deployables/Nerdbank.GitVersioning.*nupkg)
NBGV_NuGetPackageVersion=$([[ $PkgFileName =~ Nerdbank.GitVersioning\.(.*)\.nupkg ]] && echo "${BASH_REMATCH[1]}")
echo "<configuration><packageSources><add key='local' value='deployables' /></packageSources></configuration>" > nuget.config &&
dotnet new classlib -o lib &&
cd lib &&
echo '{"version":"42.42"}' > version.json &&
git init &&
git add version.json &&
git commit -m "Initial commit" &&
mkdir lib && cd lib &&
for l in c# f# vb;
do
echo Testing language $l &&
dotnet new classlib -lang=$l &&
dotnet add package nerdbank.gitversioning -v $NBGV_NuGetPackageVersion &&
dotnet pack -c debug /p:TreatWarningsAsErrors=false &&
ls bin/debug/lib.42.42.1*.nupkg 1> /dev/null 2>&1 &&
rm -r *
if [ $? -ne 0 ]; then exit 1; fi
done
- name: Consume Cake.GitVersioning
shell: bash
run: >
PkgFileName=$(ls deployables/Cake.GitVersioning.*nupkg)
NBGV_NuGetPackageVersion=$([[ $PkgFileName =~ Cake.GitVersioning\.(.*)\.nupkg ]] && echo "${BASH_REMATCH[1]}")
echo $NBGV_NuGetPackageVersion
mkdir caketest &&
cd caketest &&
git init &&
dotnet new tool-manifest &&
dotnet tool install Cake.Tool
echo "#addin nuget:?package=Cake.GitVersioning&version=${NBGV_NuGetPackageVersion}&prerelease=true"
echo "#addin nuget:?package=Cake.GitVersioning&version=${NBGV_NuGetPackageVersion}&prerelease=true" > build.cake
echo "Information(GitVersioningGetVersion().Version.ToString());" >> build.cake
dotnet cake
- name: Use nbgv dotnet CLI tool
shell: bash
run: >
echo DOTNET_ROOT=$DOTNET_ROOT
PkgFileName=$(ls deployables/Nerdbank.GitVersioning.*nupkg)
NBGV_NuGetPackageVersion=$([[ $PkgFileName =~ Nerdbank.GitVersioning\.(.*)\.nupkg ]] && echo "${BASH_REMATCH[1]}")
dotnet tool install nbgv --tool-path . --version $NBGV_NuGetPackageVersion --add-source deployables-Windows &&
./nbgv get-version -f json -p lib &&
./nbgv get-version -f json -p lib | grep 42.42.1
perf_testing:
name: 🫏 Performance testing
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
repoDir: '~/git'
- os: windows-2022
repoDir: '${USERPROFILE}/source/repos'
- os: macos-14
repoDir: '~/git'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
submodules: true
- name: Install .NET SDK
uses: actions/setup-dotnet@v2
with:
global-json-file: global.json
- name: Show .NET SDK info
run: dotnet --info
- name: Clone test repos
shell: bash
run: |
mkdir -p ${{ matrix.repoDir }}
git clone https://github.com/xunit/xunit ${{ matrix.repoDir }}/xunit
git clone https://github.com/gimlichael/Cuemon ${{ matrix.repoDir }}/Cuemon
git clone https://github.com/kerryjiang/SuperSocket ${{ matrix.repoDir }}/SuperSocket
git clone https://github.com/dotnet/Nerdbank.GitVersioning ${{ matrix.repoDir }}/Nerdbank.GitVersioning
- name: Build in Release mode
run: dotnet build -c Release
working-directory: test/Nerdbank.GitVersioning.Benchmarks
- name: Run benchmarks (packed)
run: dotnet run -c Release -f net9.0 --no-build -- --filter '*GetVersionBenchmarks*' --artifacts ${{ runner.temp }}/_artifacts//benchmarks/packed/${{ matrix.os }}
working-directory: test/Nerdbank.GitVersioning.Benchmarks
- name: Unpack Git repositories
shell: bash
run: |
cd ${{ matrix.repoDir }}/xunit
git unpack-objects < .git/objects/pack/*.pack
cd ${{ matrix.repoDir }}/Cuemon
git unpack-objects < .git/objects/pack/*.pack
cd ${{ matrix.repoDir }}/SuperSocket
git unpack-objects < .git/objects/pack/*.pack
cd ${{ matrix.repoDir }}/Nerdbank.GitVersioning
git unpack-objects < .git/objects/pack/*.pack
- name: Run benchmarks (unpacked)
run: dotnet run -c Release -f net9.0 --no-build -- --filter '*GetVersionBenchmarks*' --artifacts ${{ runner.temp }}/_artifacts//benchmarks/unpacked/${{ matrix.os }}
working-directory: test/Nerdbank.GitVersioning.Benchmarks
- name: Publish benchmarks artifacts
uses: actions/upload-artifact@v4
with:
name: benchmarks-${{ matrix.os }}
path: ${{ runner.temp }}/_artifacts/benchmarks