-
Notifications
You must be signed in to change notification settings - Fork 13
1032 lines (856 loc) · 36.9 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
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
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
name: CI
on:
push:
branches:
- master
pull_request:
types: [ opened, synchronize, reopened ]
workflow_dispatch:
workflow_call:
inputs:
ref:
description: "The commit SHA to build"
required: false
type: string
jobs:
preflight:
name: preflight
runs-on: ubuntu-20.04
outputs:
ref: ${{ steps.get-commit.outputs.ref }}
version: ${{ steps.get-version.outputs.version }}
rust-profile: ${{ steps.rust-profile.outputs.rust-profile }}
jetsocat-build-matrix: ${{ steps.setup-matrix.outputs.jetsocat-build-matrix }}
gateway-build-matrix: ${{ steps.setup-matrix.outputs.gateway-build-matrix }}
agent-build-matrix: ${{ steps.setup-matrix.outputs.agent-build-matrix }}
steps:
- name: Setup matrix
id: setup-matrix
shell: pwsh
run: |
$Jobs = @()
$Archs = @( 'x86_64', 'arm64' )
$Platforms = @( 'linux', 'windows' )
$Platforms | ForEach-Object {
$Runner = switch ($_) { 'windows' { 'windows-2022' } 'linux' { 'ubuntu-20.04' } }
foreach ($Arch in $Archs) {
if ($Arch -Eq 'arm64' -And $_ -Eq 'windows') {
continue
}
$Jobs += @{
arch = $Arch
os = $_
runner = $Runner }
}
}
$GatewayMatrix = ConvertTo-JSON $Jobs -Compress
echo "gateway-build-matrix=$GatewayMatrix" >> $Env:GITHUB_OUTPUT
$Jobs = @()
$Platforms | ForEach-Object {
$Runner = switch ($_) { 'windows' { 'windows-2022' } 'linux' { 'ubuntu-20.04' } }
foreach ($Arch in $Archs) {
$Jobs += @{
arch = $Arch
os = $_
runner = $Runner }
}
}
$AgentMatrix = ConvertTo-JSON $Jobs -Compress
echo "agent-build-matrix=$AgentMatrix" >> $Env:GITHUB_OUTPUT
$Jobs = @()
$Platforms += 'macos'
$Platforms | ForEach-Object {
$Runner = switch ($_) { 'windows' { 'windows-2022' } 'macos' { 'macos-14' } 'linux' { 'ubuntu-20.04' } }
foreach ($Arch in $Archs) {
$Jobs += @{
arch = $Arch
os = $_
runner = $Runner }
}
}
$JetsocatMatrix = ConvertTo-JSON $Jobs -Compress
echo "jetsocat-build-matrix=$JetsocatMatrix" >> $Env:GITHUB_OUTPUT
## The SHA to build might be passed via workflow_call, otherwise the current commit is used
- name: Get commit
id: get-commit
shell: pwsh
run: |
$Ref = '${{ inputs.ref }}'
if (-Not $Ref) {
$Ref = '${{ github.sha }}'
}
echo "ref=$Ref" >> $Env:GITHUB_OUTPUT
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
with:
ref: ${{ steps.get-commit.outputs.ref }}
- name: Get version
id: get-version
shell: pwsh
run: |
$Version = Get-Content VERSION -TotalCount 1
echo "version=$Version" >> $Env:GITHUB_OUTPUT
- name: Check formatting
run: |
cargo fmt --all -- --check
if ! [ $? -eq 0 ] ; then
echo "::error::Bad formatting, please run 'cargo +stable fmt --all'"
exit 1
fi
- name: Configure rust profile
id: rust-profile
shell: pwsh
run: |
$CargoProfile = "release"
if ("${{ github.ref }}" -Eq "refs/heads/master") {
echo "::notice::Building production profile"
$CargoProfile = "production"
}
echo "rust-profile=$CargoProfile" >> $Env:GITHUB_OUTPUT
- name: Upload version artifact
uses: actions/upload-artifact@v4
with:
name: version
path: VERSION
tests:
name: tests [${{ matrix.os }} ${{ matrix.arch }}]
runs-on: ${{ matrix.runner }}
needs: preflight
strategy:
matrix:
arch: [ x86_64 ]
os: [ windows, linux ]
include:
- os: windows
runner: windows-2022
- os: linux
runner: ubuntu-20.04
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
with:
ref: ${{ needs.preflight.outputs.ref }}
- name: Configure Linux runner
if: matrix.os == 'linux'
run: |
sudo apt-get update
sudo apt-get -o Acquire::Retries=3 install libsystemd-dev
- name: Tests
shell: pwsh
env:
AWS_LC_SYS_NO_ASM: true
run: ./ci/tlk.ps1 test -Platform ${{ matrix.os }} -Architecture ${{ matrix.arch }} -CargoProfile 'dev'
check-dependencies:
name: Check no ${{ matrix.banned }} in ${{ matrix.package }} [${{ matrix.target }}]
runs-on: ubuntu-latest
needs: preflight
strategy:
fail-fast: false
matrix:
banned: [ aws-lc-rs ]
target: [ x86_64-unknown-linux-gnu, x86_64-pc-windows-msvc ]
package: [ devolutions-gateway, jetsocat ]
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
with:
ref: ${{ needs.preflight.outputs.ref }}
- name: Check
shell: pwsh
run: ./ci/check-crate-is-not-in-the-tree.ps1 -Package '${{ matrix.package }}' -UnwantedDependency '${{ matrix.banned }}' -Target '${{ matrix.target }}'
jetsocat:
name: jetsocat [${{ matrix.os }} ${{ matrix.arch }}]
runs-on: ${{ matrix.runner }}
needs: preflight
strategy:
matrix:
include: ${{ fromJson(needs.preflight.outputs.jetsocat-build-matrix) }}
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
with:
ref: ${{ needs.preflight.outputs.ref }}
- name: Configure Linux runner
if: matrix.os == 'linux'
run: |
sudo apt-get update
sudo apt-get -o Acquire::Retries=3 install python3-wget python3-setuptools
# We need a newer version of GCC because aws-lc-rs rejects versions affected
# by this bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95189
# These lines can be safely removed once we switch to ubuntu-22.04 runner.
sudo apt install gcc-10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 60
- name: Configure Linux (arm) runner
if: matrix.os == 'linux' && matrix.arch == 'arm64'
run: |
sudo dpkg --add-architecture arm64
sudo apt-get -o Acquire::Retries=3 install -qy binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu g++-aarch64-linux-gnu qemu-user
rustup target add aarch64-unknown-linux-gnu
echo "STRIP_EXECUTABLE=aarch64-linux-gnu-strip" >> $GITHUB_ENV
- name: Configure Windows runner
if: runner.os == 'Windows'
shell: pwsh
run: |
# NASM is required by aws-lc-rs (used as rustls crypto backend)
choco install nasm
# We need to add the NASM binary folder to the PATH manually.
Write-Output "$Env:ProgramFiles\NASM" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
# libclang / LLVM is a requirement for AWS LC.
# https://aws.github.io/aws-lc-rs/requirements/windows.html#libclang--llvm
$VSINSTALLDIR = $(vswhere.exe -latest -requires Microsoft.VisualStudio.Component.VC.Llvm.Clang -property installationPath)
Write-Output "LIBCLANG_PATH=$VSINSTALLDIR\VC\Tools\Llvm\x64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
# Install Visual Studio Developer PowerShell Module for cmdlets such as Enter-VsDevShell
Install-Module VsDevShell -Force
- name: Configure Windows (arm) runner
if: runner.os == 'Windows' && matrix.arch == 'arm64'
shell: pwsh
run: |
rustup target add aarch64-pc-windows-msvc
- name: Configure macOS (intel) runner
if: matrix.os == 'macos' && matrix.arch == 'x86_64'
run: |
sudo rm -rf /Library/Developer/CommandLineTools
rustup target add x86_64-apple-darwin
- name: Build
id: build
shell: pwsh
run: |
$StagingPath = Join-Path $Env:RUNNER_TEMP "staging"
$TargetOutputPath = Join-Path $StagingPath ${{ matrix.os }} ${{ matrix.arch }}
$ExecutableFileName = 'jetsocat_${{ runner.os }}_${{ needs.preflight.outputs.version }}_${{ matrix.arch }}'
if ($Env:RUNNER_OS -eq "Windows") {
$ExecutableFileName = "$($ExecutableFileName).exe"
$Env:CARGO_NO_DEFAULT_FEATURES = "true"
$Env:CARGO_FEATURES = "native-tls"
}
$Env:TARGET_OUTPUT_PATH = $TargetOutputPath
$Env:JETSOCAT_EXECUTABLE = Join-Path $TargetOutputPath $ExecutableFileName
$Env:CARGO_PACKAGE = "jetsocat"
./ci/tlk.ps1 build -Product jetsocat -Platform ${{ matrix.os }} -Architecture ${{ matrix.arch }} -CargoProfile ${{ needs.preflight.outputs.rust-profile }}
echo "staging-path=$StagingPath" >> $Env:GITHUB_OUTPUT
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: jetsocat-${{ matrix.os }}-${{ matrix.arch }}
path: ${{ steps.build.outputs.staging-path }}
jetsocat-merge:
name: jetsocat merge artifacts
runs-on: ubuntu-latest
needs: [preflight, jetsocat]
steps:
- name: Merge Artifacts
uses: actions/upload-artifact/merge@v4
with:
name: jetsocat
pattern: jetsocat-*
delete-merged: true
jetsocat-lipo:
name: jetsocat macos universal
runs-on: ubuntu-20.04
needs: [preflight, jetsocat, jetsocat-merge]
steps:
- uses: actions/download-artifact@v4
with:
name: jetsocat
- name: Configure runner
run: |
wget -q https://github.com/awakecoding/llvm-prebuilt/releases/download/v2021.2.4/cctools-x86_64-ubuntu-20.04.tar.xz
tar -xf cctools-x86_64-ubuntu-20.04.tar.xz -C /tmp
sudo mv /tmp/cctools-x86_64-ubuntu-20.04/bin/lipo /usr/local/bin
rm -r cctools-x86_64-ubuntu-20.04.tar.xz
- name: Lipo
shell: pwsh
run: |
$OutputPath = Join-Path "macos" "universal"
New-Item -ItemType Directory -Path $OutputPath | Out-Null
$Binaries = Get-ChildItem -Recurse -Path "macos" -Filter "jetsocat_*" | Foreach-Object { $_.FullName } | Select -Unique
$LipoCmd = $(@('lipo', '-create', '-output', (Join-Path -Path $OutputPath -ChildPath "jetsocat_macOS_${{ needs.preflight.outputs.version }}_universal")) + $Binaries) -Join ' '
Write-Host $LipoCmd
Invoke-Expression $LipoCmd
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: jetsocat
path: .
overwrite: true
devolutions-gateway-web-ui:
name: devolutions-gateway-web-ui
runs-on: ubuntu-latest
needs: preflight
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
with:
ref: ${{ needs.preflight.outputs.ref }}
- name: Check out Devolutions/actions
uses: actions/checkout@v4
with:
repository: Devolutions/actions
ref: v1
token: ${{ secrets.DEVOLUTIONSBOT_TOKEN }}
path: ./.github/workflows
- name: Get npm cache directory
id: npm-cache
run: |
"dir=$(npm config get cache)" >> $Env:GITHUB_OUTPUT
shell: pwsh
working-directory: webapp
- uses: actions/cache@v4
with:
key: ${{ runner.os }}-node-${{ hashFiles('webapp/package-lock.json') }}
path: ${{ steps.npm-cache.outputs.dir }}
restore-keys: |
${{ runner.os }}-node-
- name: Setup .npmrc config file
uses: ./.github/workflows/npmrc-setup
with:
npm_token: ${{ secrets.ARTIFACTORY_NPM_TOKEN }}
- name: Install NPM dependencies
working-directory: webapp
run: npm ci
- name: Configure runner
shell: pwsh
run: npm install -g @angular/cli
- name: Build
shell: pwsh
working-directory: webapp
run: npm run build
- name: Check webapp
shell: pwsh
working-directory: webapp
run: npm run check
- uses: actions/upload-artifact@v4
with:
name: webapp-client
path: webapp/client/
devolutions-gateway-player:
name: Recording Player
runs-on: ubuntu-latest
needs: preflight
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
with:
ref: ${{ needs.preflight.outputs.ref }}
- name: Checkout Devolutions/actions
uses: actions/checkout@v4
with:
repository: Devolutions/actions
ref: v1
token: ${{ secrets.DEVOLUTIONSBOT_TOKEN }}
path: ./.github/workflows
- name: Setup .npmrc config file
uses: ./.github/workflows/npmrc-setup
with:
npm_token: ${{ secrets.ARTIFACTORY_NPM_TOKEN }}
- name: Install Biome
run: npm install -g @biomejs/biome
- name: Check
working-directory: webapp/player-project
run: biome check ./src
- name: Install NPM dependencies
working-directory: webapp/player-project
run: npm install
- name: Build
working-directory: webapp/player-project
run: npm run build
- uses: actions/upload-artifact@v4
with:
name: webapp-player
path: webapp/player
devolutions-gateway-powershell:
name: devolutions-gateway-powershell
runs-on: ubuntu-latest
needs: preflight
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
with:
ref: ${{ needs.preflight.outputs.ref }}
- name: Install Pester
id: prepare
shell: pwsh
run: Install-Module Pester -RequiredVersion 5.6.0
- name: Build module
shell: pwsh
run: |
./powershell/build.ps1
$PSModuleName = "DevolutionsGateway"
$PSModuleVersion = "${{ needs.preflight.outputs.version }}"
$PSModuleOutputPath = Join-Path "powershell" "package" $PSModuleName
$PSStagingPath = Join-Path "powershell-staging" "PowerShell"
New-Item -Path $PSStagingPath -ItemType Directory | Out-Null
$PSModuleZipFilePath = Join-Path $PSStagingPath "$PSModuleName-ps-$PSModuleVersion.zip"
Compress-Archive -Path $PSModuleOutputPath -Destination $PSModuleZipFilePath
- name: Pester tests
shell: pwsh
run: |
./powershell/run-tests.ps1
- uses: actions/upload-artifact@v4
with:
name: devolutions-gateway-powershell
path: powershell-staging
devolutions-gateway:
name: devolutions-gateway [${{ matrix.os }} ${{ matrix.arch }}]
runs-on: ${{ matrix.runner }}
needs: [preflight, devolutions-gateway-powershell, devolutions-gateway-web-ui]
if: always() # The webapp can’t be build without secrets that we don’t provide for PRs coming from forks.
strategy:
matrix:
include: ${{ fromJson(needs.preflight.outputs.gateway-build-matrix) }}
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
with:
ref: ${{ needs.preflight.outputs.ref }}
- name: Download webapp-client
uses: actions/download-artifact@v4
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
with:
name: webapp-client
path: webapp/client
- name: Download devolutions-gateway-player
uses: actions/download-artifact@v4
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
with:
name: webapp-player
path: webapp/player
- name: Download devolutions-gateway-powershell
uses: actions/download-artifact@v4
with:
name: devolutions-gateway-powershell
path: powershell-staging
- name: Download Cadeau
shell: pwsh
run: |
$Platform = @{'windows'='win'; 'linux'='linux'}['${{ matrix.os }}']
$Arch = @{'x86_64'='x64';'arm64'='arm64'}['${{ matrix.arch }}']
./ci/download-cadeau.ps1 -Platform $Platform -Architecture $Arch
- name: Load dynamic variables
id: load-variables
shell: pwsh
run: |
$PackageVersion = "${{ needs.preflight.outputs.version }}"
$StagingPath = Join-Path $Env:RUNNER_TEMP "staging"
$TargetOutputPath = Join-Path $StagingPath ${{ matrix.os }} ${{ matrix.arch }}
$ExecutableFileName = "DevolutionsGateway_${{ runner.os }}_${PackageVersion}_${{ matrix.arch }}"
if ($Env:RUNNER_OS -eq "Windows") {
$ExecutableFileName = "$($ExecutableFileName).exe"
$PackageFileName = "DevolutionsGateway-${{ matrix.arch }}-${PackageVersion}.msi"
$DGatewayPackage = Join-Path $TargetOutputPath $PackageFileName
echo "dgateway-package=$DGatewayPackage" >> $Env:GITHUB_OUTPUT
}
$DGatewayExecutable = Join-Path $TargetOutputPath $ExecutableFileName
echo "staging-path=$StagingPath" >> $Env:GITHUB_OUTPUT
echo "target-output-path=$TargetOutputPath" >> $Env:GITHUB_OUTPUT
echo "dgateway-executable=$DGatewayExecutable" >> $Env:GITHUB_OUTPUT
- name: Configure Linux runner
if: matrix.os == 'linux'
run: |
sudo apt-get update
sudo apt-get -o Acquire::Retries=3 install python3-wget python3-setuptools libsystemd-dev dh-make
# We need a newer version of GCC because aws-lc-rs rejects versions affected
# by this bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95189
# These lines can be safely removed once we switch to ubuntu-22.04 runner.
sudo apt install gcc-10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 60
- name: Configure Linux (arm) runner
if: matrix.os == 'linux' && matrix.arch == 'arm64'
run: |
sudo dpkg --add-architecture arm64
sudo apt-get -o Acquire::Retries=3 install -qy binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu g++-aarch64-linux-gnu qemu-user
rustup target add aarch64-unknown-linux-gnu
echo "STRIP_EXECUTABLE=aarch64-linux-gnu-strip" >> $GITHUB_ENV
- name: Install fpm
if: matrix.os == 'Linux'
run: sudo gem install --no-document fpm
- name: Configure Windows runner
if: matrix.os == 'windows'
run: |
# https://github.com/actions/runner-images/issues/9667
choco uninstall wixtoolset
choco install wixtoolset --version 3.14.0 --allow-downgrade --no-progress --force
# WiX is installed on Windows runners but not in the PATH
Write-Output "C:\Program Files (x86)\WiX Toolset v3.14\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
# NASM is required by aws-lc-rs (used as rustls crypto backend)
choco install nasm
# We need to add the NASM binary folder to the PATH manually.
Write-Output "$Env:ProgramFiles\NASM" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Build
shell: pwsh
env:
TARGET_OUTPUT_PATH: ${{ steps.load-variables.outputs.target-output-path }}
DGATEWAY_EXECUTABLE: ${{ steps.load-variables.outputs.dgateway-executable }}
CARGO_PACKAGE: devolutions-gateway
run: ./ci/tlk.ps1 build -Product gateway -Platform ${{ matrix.os }} -Architecture ${{ matrix.arch }} -CargoProfile ${{ needs.preflight.outputs.rust-profile }}
- name: Add msbuild to PATH
if: matrix.os == 'windows'
uses: microsoft/setup-msbuild@v2
- name: Package
shell: pwsh
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
env:
TARGET_OUTPUT_PATH: ${{ steps.load-variables.outputs.target-output-path }}
DGATEWAY_EXECUTABLE: ${{ steps.load-variables.outputs.dgateway-executable }}
run: |
if ($Env:RUNNER_OS -eq "Windows") {
$Env:DGATEWAY_PACKAGE = "${{ steps.load-variables.outputs.dgateway-package }}"
$Env:DGATEWAY_LIB_XMF_PATH = Join-Path "native-libs" "xmf.dll" | Resolve-Path
$PSStagingPath = Join-Path (Get-Location) "powershell-staging"
$PSModuleOutputPath = Join-Path $PSStagingPath "DevolutionsGateway"
$PSModuleZipFilePath = Get-ChildItem -Path "$PSStagingPath/PowerShell" "*-ps-*.zip" | Select-Object -First 1
Expand-Archive -Path $PSModuleZipFilePath -Destination $PSStagingPath
$Env:DGATEWAY_PSMODULE_PATH = $PSModuleOutputPath
} else {
$Env:DGATEWAY_LIB_XMF_PATH = Join-Path "native-libs" "libxmf.so" | Resolve-Path
}
$Env:DGATEWAY_WEBCLIENT_PATH = Join-Path "webapp" "client" | Resolve-Path
$Env:DGATEWAY_WEBPLAYER_PATH = Join-Path "webapp" "player" | Resolve-Path
./ci/tlk.ps1 package -Product gateway -Platform ${{ matrix.os }} -Architecture ${{ matrix.arch }} -CargoProfile ${{ needs.preflight.outputs.rust-profile }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: devolutions-gateway-${{ matrix.os }}-${{ matrix.arch }}
path: ${{ steps.load-variables.outputs.staging-path }}
devolutions-gateway-merge:
name: devolutions gateway merge artifacts
runs-on: ubuntu-latest
needs: [preflight, devolutions-gateway]
if: always() # The job is skipped for PRs coming from forks because the devolutions-gateway job would have been skipped (if always() wasn’t used). Another GitHub action oddity.
steps:
- name: Merge Artifacts
uses: actions/upload-artifact/merge@v4
with:
name: devolutions-gateway
pattern: devolutions-gateway-*
delete-merged: true
devolutions-agent:
name: devolutions-agent [${{ matrix.os }} ${{ matrix.arch }}]
runs-on: ${{ matrix.runner }}
needs: [preflight]
strategy:
matrix:
include: ${{ fromJson(needs.preflight.outputs.agent-build-matrix) }}
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
with:
ref: ${{ needs.preflight.outputs.ref }}
- name: Load dynamic variables
id: load-variables
shell: pwsh
run: |
$PackageVersion = "${{ needs.preflight.outputs.version }}"
$StagingPath = Join-Path $Env:RUNNER_TEMP "staging"
$SymbolsPath = Join-Path $Env:RUNNER_TEMP "symbols"
New-Item -ItemType Directory $StagingPath
New-Item -ItemType Directory $SymbolsPath
$TargetOutputPath = Join-Path $StagingPath ${{ matrix.os }} ${{ matrix.arch }}
$ExecutableFileName = "DevolutionsAgent_${{ runner.os }}_${PackageVersion}_${{ matrix.arch }}"
if ($Env:RUNNER_OS -eq "Windows") {
$ExecutableFileName = "$($ExecutableFileName).exe"
$PackageFileName = "DevolutionsAgent-${{ matrix.arch }}-${PackageVersion}.msi"
$DAgentPackage = Join-Path $TargetOutputPath $PackageFileName
echo "dagent-package=$DAgentPackage" >> $Env:GITHUB_OUTPUT
$DAgentDesktopAgentOutputPath = Join-Path $TargetOutputPath "DesktopAgent"
echo "dagent-desktop-agent-output-path=$DAgentDesktopAgentOutputPath" >> $Env:GITHUB_OUTPUT
$DAgentPedmShellExtDll = Join-Path $TargetOutputPath "DevolutionsPedmShellExt.dll"
echo "dagent-pedm-shell-ext-dll=$DAgentPedmShellExtDll" >> $Env:GITHUB_OUTPUT
$DAgentPedmShellExtMsix = Join-Path $TargetOutputPath "DevolutionsPedmShellExt.msix"
echo "dagent-pedm-shell-ext-msix=$DAgentPedmShellExtMsix" >> $Env:GITHUB_OUTPUT
$DAgentSessionExecutable = Join-Path $TargetOutputPath "DevolutionsSession.exe"
echo "dagent-session-executable=$DAgentSessionExecutable" >> $Env:GITHUB_OUTPUT
}
$DAgentExecutable = Join-Path $TargetOutputPath $ExecutableFileName
echo "staging-path=$StagingPath" >> $Env:GITHUB_OUTPUT
echo "symbols-path=$SymbolsPath" >> $Env:GITHUB_OUTPUT
echo "target-output-path=$TargetOutputPath" >> $Env:GITHUB_OUTPUT
echo "dagent-executable=$DAgentExecutable" >> $Env:GITHUB_OUTPUT
- name: Configure Linux runner
if: matrix.os == 'linux'
run: |
sudo apt-get update
sudo apt-get -o Acquire::Retries=3 install python3-wget python3-setuptools libsystemd-dev dh-make
# We need a newer version of GCC because aws-lc-rs rejects versions affected
# by this bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95189
# These lines can be safely removed once we switch to ubuntu-22.04 runner.
sudo apt install gcc-10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 60
- name: Configure Linux (arm) runner
if: matrix.os == 'linux' && matrix.arch == 'arm64'
run: |
sudo dpkg --add-architecture arm64
sudo apt-get -o Acquire::Retries=3 install -qy binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu g++-aarch64-linux-gnu qemu-user
rustup target add aarch64-unknown-linux-gnu
echo "STRIP_EXECUTABLE=aarch64-linux-gnu-strip" >> $GITHUB_ENV
- name: Install fpm
if: matrix.os == 'Linux'
run: sudo gem install --no-document fpm
- name: Configure Windows runner
if: matrix.os == 'windows'
run: |
# https://github.com/actions/runner-images/issues/9667
choco uninstall wixtoolset
choco install wixtoolset --version 3.14.0 --allow-downgrade --force
# Devolutions PEDM needs MakeAppx.exe
Write-Output "C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x64" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
# WiX is installed on Windows runners but not in the PATH
Write-Output "C:\Program Files (x86)\WiX Toolset v3.14\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
# NASM is required by aws-lc-rs (used as rustls crypto backend)
choco install nasm
# We need to add the NASM binary folder to the PATH manually.
Write-Output "$Env:ProgramFiles\NASM" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Configure Windows (arm) runner
if: runner.os == 'Windows' && matrix.arch == 'arm64'
shell: pwsh
run: |
rustup target add aarch64-pc-windows-msvc
- name: Add msbuild to PATH
if: matrix.os == 'windows'
uses: microsoft/setup-msbuild@v2
- name: Build
shell: pwsh
env:
TARGET_OUTPUT_PATH: ${{ steps.load-variables.outputs.target-output-path }}
DAGENT_EXECUTABLE: ${{ steps.load-variables.outputs.dagent-executable }}
CARGO_PACKAGE: devolutions-agent
run: |
if ($Env:RUNNER_OS -eq "Windows") {
$Env:DAGENT_DESKTOP_AGENT_OUTPUT_PATH = "${{ steps.load-variables.outputs.dagent-desktop-agent-output-path }}"
$Env:DAGENT_PEDM_SHELL_EXT_DLL = "${{ steps.load-variables.outputs.dagent-pedm-shell-ext-dll }}"
$Env:DAGENT_PEDM_SHELL_EXT_MSIX = "${{ steps.load-variables.outputs.dagent-pedm-shell-ext-msix }}"
$Env:DAGENT_SESSION_EXECUTABLE = "${{ steps.load-variables.outputs.dagent-session-executable }}"
}
./ci/tlk.ps1 build -Product agent -Platform ${{ matrix.os }} -Architecture ${{ matrix.arch }} -CargoProfile ${{ needs.preflight.outputs.rust-profile }}
- name: Package
shell: pwsh
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
env:
TARGET_OUTPUT_PATH: ${{ steps.load-variables.outputs.target-output-path }}
DAGENT_EXECUTABLE: ${{ steps.load-variables.outputs.dagent-executable }}
run: |
if ($Env:RUNNER_OS -eq "Windows") {
$Env:DAGENT_PACKAGE = "${{ steps.load-variables.outputs.dagent-package }}"
$Env:DAGENT_DESKTOP_AGENT_OUTPUT_PATH = "${{ steps.load-variables.outputs.dagent-desktop-agent-output-path }}"
$Env:DAGENT_PEDM_SHELL_EXT_DLL = "${{ steps.load-variables.outputs.dagent-pedm-shell-ext-dll }}"
$Env:DAGENT_PEDM_SHELL_EXT_MSIX = "${{ steps.load-variables.outputs.dagent-pedm-shell-ext-msix }}"
$Env:DAGENT_SESSION_EXECUTABLE = "${{ steps.load-variables.outputs.dagent-session-executable }}"
}
./ci/tlk.ps1 package -Product agent -Platform ${{ matrix.os }} -Architecture ${{ matrix.arch }} -CargoProfile ${{ needs.preflight.outputs.rust-profile }}
- name: Upload artifacts
if: matrix.arch != 'arm64'
uses: actions/upload-artifact@v4
with:
name: devolutions-agent-${{ matrix.os }}-${{ matrix.arch }}
path: ${{ steps.load-variables.outputs.staging-path }}
devolutions-agent-merge:
name: devolutions agent merge artifacts
runs-on: ubuntu-latest
needs: [preflight, devolutions-agent]
steps:
- name: Merge Artifacts
uses: actions/upload-artifact/merge@v4
with:
name: devolutions-agent
pattern: devolutions-agent-*
delete-merged: true
dotnet-utils-tests:
name: .NET utils tests
runs-on: windows-2022
needs: preflight
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
with:
ref: ${{ needs.preflight.outputs.ref }}
- name: Tests
shell: pwsh
run: |
Set-PSDebug -Trace 1
dotnet test utils/dotnet/GatewayUtils.sln
winapi-sanitizer-tests:
name: Windows API sanitizer tests
runs-on: windows-2022
needs: preflight
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
with:
ref: ${{ needs.preflight.outputs.ref }}
- name: Prepare runner
shell: pwsh
run: |
$VSInstallationPath = $(vswhere.exe -latest -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
Write-Host "VCToolsInstallDir = $VSInstallationPath"
Get-ChildItem "$VSInstallationPath"
$toolsPath = "$VSInstallationPath\VC\Tools\MSVC"
Write-Host "toolsPath = $toolsPath"
Get-ChildItem "$toolsPath"
$firstItem = Get-ChildItem "$toolsPath" | Select-Object -Last 1
$binPath = "$toolsPath\$($firstItem.Name)\bin\Hostx64\x64"
Write-Host "binPath = $binPath"
Get-ChildItem "$binPath"
$asanDllPath = "$binPath\clang_rt.asan_dynamic-x86_64.dll"
Write-Host "asanDllPath = $asanDllPath"
New-Item -ItemType Directory ".\target\x86_64-pc-windows-msvc\debug\"
Copy-Item -Path "$asanDllPath" -Destination .\target\x86_64-pc-windows-msvc\debug\
rustup toolchain install nightly
- name: Run tests
shell: pwsh
run: |
$Env:RUSTFLAGS="-Zsanitizer=address"
cargo +nightly test --target x86_64-pc-windows-msvc -p win-api-wrappers -p devolutions-pedm
winapi-miri:
name: Windows API miri tests [${{ matrix.os }}][${{ matrix.mode }}]
runs-on: ${{ matrix.runner }}
needs: preflight
strategy:
fail-fast: false
matrix:
os:
- windows
- linux
mode:
- stacked-borrow
- tree-borrows
include:
- os: windows
runner: windows-latest
- os: linux
runner: ubuntu-latest
- mode: tree-borrows
miriflags: -Zmiri-tree-borrows
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
with:
ref: ${{ needs.preflight.outputs.ref }}
- name: Prepare runner
run: |
rustup toolchain install nightly --component miri
- name: Run tests
shell: pwsh
run: |
$Env:MIRIFLAGS = "${{ matrix.miriflags }}"
cargo +nightly test -p win-api-wrappers
success:
name: Success
runs-on: ubuntu-latest
if: always()
needs:
- tests
- check-dependencies
- jetsocat-lipo
- devolutions-gateway-powershell
- devolutions-gateway-player
- devolutions-gateway
- devolutions-gateway-merge
- devolutions-agent-merge
- dotnet-utils-tests
- winapi-sanitizer-tests
- winapi-miri
steps:
- name: Check success
shell: pwsh
run: |
$results = '${{ toJSON(needs.*.result) }}' | ConvertFrom-Json
$succeeded = $($results | Where { $_ -Ne "success" }).Count -Eq 0
exit $(if ($succeeded) { 0 } else { 1 })
upload-git-log:
name: Upload git-log output
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/master' }}
needs:
- success
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
with:
ref: ${{ needs.preflight.outputs.ref }}
fetch-depth: 10
- name: Generate git-log.txt
shell: pwsh
run: git log --max-count=10 > ./git-log.txt
- name: Upload git-log.txt
uses: actions/upload-artifact@v4
with:
name: git-log
path: ./git-log.txt
onedrive:
name: OneDrive
runs-on: ubuntu-20.04
if: ${{ github.ref == 'refs/heads/master' }}
needs:
- preflight # required for needs.preflight.outputs
- upload-git-log
steps:
- name: Check out Devolutions/actions
uses: actions/checkout@v4
with:
repository: Devolutions/actions
ref: v1
token: ${{ secrets.DEVOLUTIONSBOT_TOKEN }}
path: ./.github/workflows
## Fetch current date and time
- name: Get current timestamp
id: timestamp
run: echo "timestamp=$(date +'%Y%m%d%H%M')" >> $GITHUB_OUTPUT
## Devolutions Toolbox is required for OneDrive uploading
- name: Install Devolutions Toolbox
uses: ./.github/workflows/toolbox-install
with:
github_token: ${{ secrets.DEVOLUTIONSBOT_TOKEN }}
## Download back the artifacts produced by the other jobs
- uses: actions/download-artifact@v4
with:
name: jetsocat
path: ${{ runner.temp }}/artifacts_raw
- uses: actions/download-artifact@v4
with:
name: devolutions-gateway
path: ${{ runner.temp }}/artifacts_raw
- uses: actions/download-artifact@v4
with:
name: devolutions-agent
path: ${{ runner.temp }}/artifacts_raw
- uses: actions/download-artifact@v4
with:
name: git-log
path: ${{ runner.temp }}/artifacts_raw
## Do the actual upload :tada:
- name: Prepare upload
id: prepare
shell: pwsh
run: |
$version="${{ needs.preflight.outputs.version }}"
$ref="${{ needs.preflight.outputs.ref }}"
$shortRef=$ref.Substring(0, 8)
$sourceFolder = "${{ runner.temp }}/artifacts_raw"
$destinationFolder = "${{ runner.temp }}/artifacts"
Write-Host "version = $version"