-
Notifications
You must be signed in to change notification settings - Fork 7
699 lines (575 loc) · 20.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
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
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
name: Build
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
permissions:
id-token: write
contents: read
env:
CI: true
# don't print dotnet logo
DOTNET_NOLOGO: true
# disable telemetry (reduces dotnet tool output in logs)
DOTNET_CLI_TELEMETRY_OPTOUT: true
jobs:
build-cli:
name: Build CLI (${{ matrix.rid }})
runs-on: ubuntu-latest
strategy:
# let us get failures from other jobs even if one fails
fail-fast: false
# should be the full list of supported RIDs with customizations expressed via the parameters under each item
matrix:
include:
- rid: win-x64
- rid: linux-x64
- rid: linux-musl-x64
- rid: osx-x64
- rid: linux-arm64
- rid: win-arm64
- rid: osx-arm64
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
submodules: true
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
- name: Build Bicep.sln
run: dotnet build --configuration release
- name: Publish Bicep
run: dotnet publish --configuration release --self-contained true -p:PublishTrimmed=true -p:PublishSingleFile=true -p:TrimmerDefaultAction=copyused -p:SuppressTrimAnalysisWarnings=true -r ${{ matrix.rid }} ./src/Bicep.Cli/Bicep.Cli.csproj
- name: Upload Bicep
uses: actions/upload-artifact@v4
with:
name: bicep-release-${{ matrix.rid }}
path: ./src/Bicep.Cli/bin/release/net6.0/${{ matrix.rid }}/publish/*
if-no-files-found: error
- name: Upload Bicep project assets file
uses: actions/upload-artifact@v4
with:
name: bicep-project-assets-${{ matrix.rid }}
path: ./src/Bicep.Cli/obj/project.assets.json
if-no-files-found: error
build-nugets:
name: Build NuGet Packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
submodules: true
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
- name: Pack
run: dotnet pack --configuration release
- name: Upload Packages
uses: actions/upload-artifact@v4
with:
name: bicep-nupkg-any
path: out/*
if-no-files-found: error
build-langserver:
name: Build Language Server
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
submodules: true
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
- name: Publish Language Server
run: dotnet publish --configuration release ./src/Bicep.LangServer/Bicep.LangServer.csproj
- name: Upload Language Server
uses: actions/upload-artifact@v4
with:
name: Bicep.LangServer
path: ./src/Bicep.LangServer/bin/release/net6.0/publish/*
if-no-files-found: error
# needed to generate notice file
- name: Upload Language Server project assets file
uses: actions/upload-artifact@v4
with:
name: Bicep.LangServer.ProjAssets
path: ./src/Bicep.LangServer/obj/project.assets.json
build-vscode-ext:
name: Build VSCode Extension
runs-on: ${{ matrix.os }}
needs: build-langserver
strategy:
fail-fast: false
matrix:
os:
- windows-latest
- ubuntu-latest
- macos-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
submodules: true
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 16
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
- name: npm ci
run: npm ci
working-directory: ./src/vscode-bicep
# we don't run this step on official builds
- name: Enable params
run: npm run params
working-directory: ./src/vscode-bicep
- name: Run lint
run: npm run lint
working-directory: ./src/vscode-bicep
- name: Run unit tests
run: npm run test:unit
working-directory: ./src/vscode-bicep
- name: Run snapshot tests
run: npm run test:snapshot
working-directory: ./src/vscode-bicep
- name: Download Language Server
uses: actions/download-artifact@v4
with:
name: Bicep.LangServer
path: ./src/vscode-bicep/bicepLanguageServer
- name: Download Language Server project assets file
if: runner.os == 'Linux'
uses: actions/download-artifact@v4
with:
name: Bicep.LangServer.ProjAssets
path: ./src/vscode-bicep-notice/inputs
- name: npm list -a --json
if: runner.os == 'Linux'
run: npm list -a --json > ../vscode-bicep-notice/inputs/npm-list.json
working-directory: ./src/vscode-bicep
- name: Generate VSIX notice
if: runner.os == 'Linux'
run: dotnet build --configuration Release ./src/vscode-bicep-notice/vscode-bicep-notice.proj
- name: Build prod
run: npm run build:prod
working-directory: ./src/vscode-bicep
- name: Build E2E tests
run: npm run build:e2e
working-directory: ./src/vscode-bicep
- name: Run E2E tests
run: npm run test:e2e
if: runner.os != 'Linux'
working-directory: ./src/vscode-bicep
# In headless Linux CI machines xvfb is required to run VS Code, so need a separate path for Linux.
- name: Run E2E tests (Linux)
run: xvfb-run -a npm run test:e2e
if: runner.os == 'Linux'
working-directory: ./src/vscode-bicep
- name: Show extension logs of E2E tests
run: cat ./bicep.log
if: always()
working-directory: ./src/vscode-bicep
- name: Upload Code Coverage
uses: codecov/codecov-action@v4
with:
flags: typescript
directory: ./src/vscode-bicep/coverage
- name: Create VSIX
run: npm run package
if: runner.os == 'Linux'
working-directory: ./src/vscode-bicep
- name: Upload VSIX
uses: actions/upload-artifact@v4
if: runner.os == 'Linux'
with:
name: vscode-bicep.vsix
path: ./src/vscode-bicep/vscode-bicep.vsix
if-no-files-found: error
build-vs-ext:
name: Build Visual Studio Extension
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
submodules: true
# needed by the GenerateNotice package
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Build Bicep.sln
run: msbuild Bicep.sln /restore -property:Configuration=Release /v:m /bl:./src/binlog/bicep_build.binlog
- name: Upload Bicep.sln build binlog
uses: actions/upload-artifact@v4
with:
name: build-binlog-files
path: ./src/binlog/bicep_build.binlog
if-no-files-found: error
- name: Build BicepInVisualStudio.sln
run: msbuild src/vs-bicep/BicepInVisualStudio.sln /restore -property:Configuration=Release /v:m /bl:./src/binlog/bicep_in_visual_studio_build.binlog
- name: Upload Bicep.sln build binlog
uses: actions/upload-artifact@v4
with:
name: build-binlog-files
path: ./src/binlog/bicep_in_visual_studio_build.binlog
if-no-files-found: error
- name: Upload BicepLanguageServerClient VSIX
uses: actions/upload-artifact@v4
with:
name: Bicep.VSLanguageServerClient.Vsix.vsix
path: ./src/vs-bicep/Bicep.VSLanguageServerClient.Vsix/bin/Release/vs-bicep.vsix
if-no-files-found: error
- name: Run bicep in visual studio unit tests
uses: microsoft/[email protected]
with:
testAssembly: src/vs-bicep/Bicep.VSLanguageServerClient.UnitTests/bin/Release/net472/Bicep.VSLanguageServerClient.UnitTests.dll
runInParallel: true
# Temporary workaround to force a green build - VS tests are flaky
# Proper fix tracked under https://github.com/Azure/bicep/issues/8078
continue-on-error: true
- name: Install bicep in Visual Studio
run: ./src/vs-bicep/Install.cmd
- name: Run bicep in visual studio integration tests
uses: microsoft/[email protected]
with:
testAssembly: src/vs-bicep/Bicep.VSLanguageServerClient.IntegrationTests/bin/Release/net472/Bicep.VSLanguageServerClient.IntegrationTests.dll
runInParallel: false
# Temporary workaround to force a green build - VS tests are flaky
# Proper fix tracked under https://github.com/Azure/bicep/issues/8078
continue-on-error: true
build-windows-setup:
name: Build Windows Setup
runs-on: windows-latest
needs: build-cli
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
submodules: true
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
- name: Download Bicep CLI
uses: actions/download-artifact@v4
with:
name: bicep-release-win-x64
path: ./src/installer-win/bicep
- name: Download Bicep CLI project assets file
uses: actions/download-artifact@v4
with:
name: bicep-project-assets-win-x64
path: ./src/installer-win/bicep
- name: Build Windows Installer
run: dotnet build --configuration release ./src/installer-win/installer.proj
- name: Upload Windows Installer
uses: actions/upload-artifact@v4
with:
name: bicep-setup-win-x64
path: ./src/installer-win/bin/release/net6.0/bicep-setup-win-x64.exe
if-no-files-found: error
build-cli-nugets:
name: Build CLI NuGet Packages (${{ matrix.rid }})
runs-on: ${{ matrix.os }}
needs:
- build-cli
- build-nugets
env:
RuntimeSuffix: ${{ matrix.rid }}
strategy:
fail-fast: false
# should be the full list of RIDs that we support in the CLI
matrix:
include:
- os: windows-latest
rid: win-x64
- os: ubuntu-latest
rid: linux-x64
- os: macos-latest
rid: osx-x64
- os: ubuntu-latest
rid: win-arm64
runTests: false
- os: ubuntu-latest
rid: linux-arm64
runTests: false
- os: ubuntu-latest
rid: osx-arm64
runTests: false
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
submodules: true
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 16
- name: npm ci
if: matrix.runTests
run: npm ci
working-directory: ./src/Bicep.MSBuild.E2eTests
- name: Compile
if: matrix.runTests
run: npm run compile
working-directory: ./src/Bicep.MSBuild.E2eTests
- name: Run lint
if: matrix.runTests
run: npm run lint
working-directory: ./src/Bicep.MSBuild.E2eTests
- name: Download Bicep CLI
uses: actions/download-artifact@v4
with:
name: bicep-release-${{ matrix.rid }}
path: ./src/Bicep.Cli.Nuget/tools
- name: Download Bicep CLI project assets file
uses: actions/download-artifact@v4
with:
name: bicep-project-assets-${{ matrix.rid }}
path: ./src/Bicep.Cli.Nuget/tools
- name: Download .Net Packages
uses: actions/download-artifact@v4
with:
name: bicep-nupkg-any
path: ./src/Bicep.MSBuild.E2eTests/examples/local-packages
- name: Build CLI Package
run: dotnet build --configuration release /p:RuntimeSuffix=${{ matrix.rid }} ./src/Bicep.Cli.Nuget/nuget.proj
- name: Upload CLI Package
uses: actions/upload-artifact@v4
with:
name: bicep-nupkg-${{ matrix.rid }}
path: ./src/Bicep.Cli.Nuget/*.nupkg
if-no-files-found: error
- name: Download CLI Package
if: matrix.runTests
uses: actions/download-artifact@v4
with:
name: bicep-nupkg-${{ matrix.rid }}
path: ./src/Bicep.MSBuild.E2eTests/examples/local-packages
- name: Run E2E tests
if: matrix.runTests
run: npm run test
working-directory: ./src/Bicep.MSBuild.E2eTests
build-playground:
name: Build Playground
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
submodules: true
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 14
- name: npm ci
run: npm ci
working-directory: ./src/playground
- name: Run lint
run: npm run lint
working-directory: ./src/playground
- name: Build
run: npm run package
working-directory: ./src/playground
- name: Upload
uses: actions/upload-artifact@v4
with:
name: playground
path: ./src/playground/dist/*
if-no-files-found: error
build-highlight-libs:
name: Build Highlight Libraries
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
submodules: true
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 16
- name: TextMate Grammar
run: |
npm ci
npm run lint
npm test
working-directory: ./src/textmate
- name: HighlightJs Grammar
run: |
npm ci
npm run lint
npm test
working-directory: ./src/highlightjs
- name: Monarch Grammar
run: |
npm ci
npm run lint
npm test
working-directory: ./src/monarch
test-bicep:
name: Test Bicep (${{ matrix.rid }})
runs-on: ${{ matrix.os }}
needs: build-cli
strategy:
# let us get failures from other jobs even if one fails
fail-fast: false
# should be the full list of supported RIDs with customizations expressed via the parameters under each item
matrix:
include:
- os: windows-latest
rid: win-x64
- os: ubuntu-latest
rid: linux-x64
- os: ubuntu-latest
rid: linux-musl-x64
- os: macos-latest
rid: osx-x64
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
submodules: true
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
- name: Test
run: dotnet test --configuration release --logger trx --blame --collect:"XPlat Code Coverage" --settings ./.github/workflows/codecov.runsettings --results-directory ./TestResults/
- name: Upload Test Results
uses: actions/upload-artifact@v4
if: always()
with:
name: Bicep.TestResults.${{ matrix.rid }}
path: ./TestResults/**/*.trx
if-no-files-found: error
- name: Download Bicep CLI
uses: actions/download-artifact@v4
with:
name: bicep-release-${{ matrix.rid }}
path: ./src/Bicep.Cli.E2eTests/src/temp/bicep-cli
- name: Make Bicep CLI executable
if: runner.os != 'Windows'
run: chmod +x ./src/Bicep.Cli.E2eTests/src/temp/bicep-cli/bicep
- name: Run Bicep E2E Tests
if: matrix.rid != 'linux-musl-x64'
run: npm ci && npm test
env:
BICEP_CLI_EXECUTABLE: ../../../Bicep.Cli.E2eTests/src/temp/bicep-cli/bicep
working-directory: ./src/Bicep.Cli.E2eTests
- name: Run Bicep E2E Tests (linux-musl-x64)
if: matrix.rid == 'linux-musl-x64'
uses: docker://mcr.microsoft.com/azure-cli:latest
with:
entrypoint: sh
args: -c "apk add --update nodejs npm && npm ci --prefix ./src/Bicep.Cli.E2eTests && npm test --prefix ./src/Bicep.Cli.E2eTests"
env:
BICEP_CLI_EXECUTABLE: ../../../Bicep.Cli.E2eTests/src/temp/bicep-cli/bicep
- name: Upload Code Coverage
uses: codecov/codecov-action@v4
with:
flags: dotnet
can-run-live-tests:
name: Check secret access
runs-on: ubuntu-latest
outputs:
access_verified: ${{ steps.check-access.outputs.verified }}
steps:
- id: check-access
env:
SECRET_TO_CHECK: ${{ secrets.SECRET_TO_CHECK }}
if: env.SECRET_TO_CHECK != ''
run: echo '::set-output name=verified::true'
test-cli-live:
name: Test CLI (live) (${{ matrix.runtime.rid }}) (${{ matrix.environment }})
strategy:
fail-fast: false
matrix:
environment: [prod, ff]
runtime:
# should be the list of RIDs that correspond to OSs supported by GitHub hosted runners
- os: windows-latest
rid: win-x64
- os: ubuntu-latest
rid: linux-x64
- os: macos-latest
rid: osx-x64
runs-on: ${{ matrix.runtime.os }}
needs:
- build-cli
- can-run-live-tests
if: needs.can-run-live-tests.outputs.access_verified == 'true'
env:
BICEP_SPN_PASSWORD_FF: ${{ secrets.BICEP_SPN_PASSWORD_FF }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 16
- name: Download Bicep CLI
uses: actions/download-artifact@v4
with:
name: bicep-release-${{ matrix.runtime.rid }}
path: ./src/Bicep.Cli.E2eTests/src/temp/bicep-cli
- name: Make Bicep CLI executable
if: runner.os != 'Windows'
run: chmod +x ./src/Bicep.Cli.E2eTests/src/temp/bicep-cli/bicep
- name: Az CLI login
uses: azure/login@v2
if: matrix.environment == 'prod'
with:
client-id: ${{ secrets.LIVE_TEST_CLIENT_ID_PROD }}
tenant-id: ${{ secrets.LIVE_TEST_TENANT_ID_PROD }}
subscription-id: ${{ secrets.LIVE_TEST_SUBSCRIPTION_ID_PROD }}
- name: Run Bicep Live E2E Tests (${{ matrix.environment }})
run: npm ci && npm run test:live:${{ matrix.environment }}
env:
BICEP_CLI_EXECUTABLE: ../../../Bicep.Cli.E2eTests/src/temp/bicep-cli/bicep
working-directory: ./src/Bicep.Cli.E2eTests
test-cli-live-linux-musl-x64:
name: Test CLI (live) (linux-musl-x64) (${{ matrix.environment }})
strategy:
matrix:
environment:
- prod
- ff
runs-on: ubuntu-latest
container:
# The azure-cli image is based on Alpine linux which uses musl libc.
image: mcr.microsoft.com/azure-cli:latest
needs:
- build-cli
- can-run-live-tests
if: needs.can-run-live-tests.outputs.access_verified == 'true'
env:
BICEP_SPN_PASSWORD_FF: ${{ secrets.BICEP_SPN_PASSWORD_FF }}
steps:
- uses: actions/checkout@v4
# Cannot use actions/setup-node@v4 for linux-musl-x64
- name: Setup Node.js
run: apk add --update nodejs npm
- name: Download Bicep CLI
uses: actions/download-artifact@v4
with:
name: bicep-release-linux-musl-x64
path: ./src/Bicep.Cli.E2eTests/src/temp/bicep-cli
- name: Make Bicep CLI executable
run: chmod +x ./src/Bicep.Cli.E2eTests/src/temp/bicep-cli/bicep
- name: Az CLI login
uses: azure/login@v2
if: matrix.environment == 'prod'
with:
client-id: ${{ secrets.LIVE_TEST_CLIENT_ID_PROD }}
tenant-id: ${{ secrets.LIVE_TEST_TENANT_ID_PROD }}
subscription-id: ${{ secrets.LIVE_TEST_SUBSCRIPTION_ID_PROD }}
- name: Run Bicep Live E2E Tests (${{ matrix.environment }})
run: npm ci && npm run test:live:${{ matrix.environment }}
env:
BICEP_CLI_EXECUTABLE: ../../../Bicep.Cli.E2eTests/src/temp/bicep-cli/bicep
working-directory: ./src/Bicep.Cli.E2eTests