-
Notifications
You must be signed in to change notification settings - Fork 33
1051 lines (893 loc) · 36.7 KB
/
build-develop.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: Build-develop
on:
workflow_dispatch:
pull_request:
branches:
- develop
push:
branches:
- develop
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
CTEST_OUTPUT_ON_FAILURE: 1
CONAN_NON_INTERACTIVE: 1
CONAN_REVISIONS_ENABLED: 1
jobs:
unit-tests-mac:
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{github.workspace}}/build
- name: Python Setup
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Get Conan
id: conan
uses: turtlebrowser/get-conan@main
with:
version: 1.64.1
- name: Setup OSX Environment
run: echo "SDKROOT=$(xcrun --sdk macosx --show-sdk-path)" >> $GITHUB_ENV
- name: Setup Conan Cache
uses: actions/cache@v4
with:
path: ${{github.workspace}}/build/conan_home/
key: conan-${{ runner.os }}-${{ hashFiles('conanfile.py', '*/conanfile.py') }}
restore-keys: conan-${{ runner.os }}-
- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
working-directory: ${{github.workspace}}/build
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: PKG_CONFIG_PATH=${{github.workspace}}/local/lib/pkgconfig cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE -- -j 2
- name: Test
working-directory: ${{github.workspace}}/build
shell: bash
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C $BUILD_TYPE
unit-tests-linux:
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-latest
outputs:
version_number: ${{ env.VERSION }}
commit_hash: ${{ env.COMMIT }}
steps:
- uses: actions/checkout@v4
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{github.workspace}}/build
- name: Get Conan
# You may pin to the exact commit or the version.
# uses: turtlebrowser/get-conan@4dc7e6dd45c8b1e02e909979d7cfc5ebba6ddbe2
id: conan
uses: turtlebrowser/get-conan@main
with:
version: 1.64.1
- name: linux package install
run: |
sudo apt-get update
sudo apt-get install --yes --no-install-recommends jq
- name: Setup Conan Cache
uses: actions/cache@v4
with:
path: ${{github.workspace}}/build/conan_home/
key: conan-${{ runner.os }}-${{ hashFiles('conanfile.py', '*/conanfile.py') }}
restore-keys: conan-${{ runner.os }}-
- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
working-directory: ${{github.workspace}}/build
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: PKG_CONFIG_PATH=${{github.workspace}}/local/lib/pkgconfig cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
- name: Get VERSION
id: build
run: |
echo "VERSION=`cat ${{github.workspace}}/build/VERSION`" >> $GITHUB_ENV
echo "::set-output name=version::$(cat ${{github.workspace}}/build/VERSION)"
echo "COMMIT=`git rev-parse --short HEAD`" >> $GITHUB_ENV
- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE -- -j 2
- name: Test
working-directory: ${{github.workspace}}/build
shell: bash
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C $BUILD_TYPE
build-win64:
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: windows-2019
outputs:
version_number: ${{ env.VERSION }}
steps:
- uses: actions/checkout@v4
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{github.workspace}}\build
- name: Get Conan
# You may pin to the exact commit or the version.
# uses: turtlebrowser/get-conan@4dc7e6dd45c8b1e02e909979d7cfc5ebba6ddbe2
id: conan
uses: turtlebrowser/get-conan@main
with:
version: 1.64.1
- name: Setup Conan Cache
uses: actions/cache@v4
with:
path: ${{github.workspace}}/build/conan_home/
key: conan-${{ runner.os }}-${{ hashFiles('conanfile.py', '*/conanfile.py') }}
restore-keys: conan-${{ runner.os }}-
- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
working-directory: ${{github.workspace}}\build
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: PKG_CONFIG_PATH=${{github.workspace}}\local\lib\pkgconfig cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
- name: Get VERSION
shell: pwsh
id: build
run: |
$text = Get-Content ${{github.workspace}}\build\VERSION -Raw
echo "VERSION=$text" >> $env:GITHUB_ENV
- name: Build
working-directory: ${{github.workspace}}\build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE -- -m
# TODO: Fix unit tests for windows platform
#- name: Test
# working-directory: ${{github.workspace}}/build
# shell: bash
# # Execute tests defined by the CMake configuration.
# # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
# run: ctest -C $BUILD_TYPE
- name: Debug artifacts
shell: pwsh
run: |
Get-ChildItem -Force ${{github.workspace}}
Get-ChildItem -Force ${{github.workspace}}\build
Get-ChildItem -Force ${{github.workspace}}\build\bin
- name: Persist to workspace
uses: actions/upload-artifact@v4
with:
name: windows-build
path: |
${{github.workspace}}\build\bin\pktvisor-reader.exe
${{github.workspace}}\build\bin\pktvisord.exe
${{github.workspace}}\golang\pkg\client\version.go
retention-days: 1
build-cli-win64:
needs: [ build-win64 ]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Attach to workspace
uses: actions/download-artifact@v4
with:
name: windows-build
- name: Debug artifacts
shell: bash
run: |
ls -lha
- name: Debug artifacts
shell: bash
run: |
ls -lha
mv src pktvisor-src
cp -rpf golang/pkg/client/version.go .
ls -lha
- name: Build pktvisor-cli
uses: ./.github/actions/build-go
with:
context: "."
goos: windows
file: "./Dockerfile"
- name: Debug artifacts
shell: bash
run: |
mv ./pktvisor-cli pktvisor-cli.exe
mv ./build/bin/pktvisord.exe ./pktvisord.exe
mv ./build/bin/pktvisor-reader.exe ./pktvisor-reader.exe
ls -lha
- name: compacting windows binary
run: |
zip pktvisor-win64.zip pktvisor-cli.exe pktvisor-reader.exe pktvisord.exe
ls -lha
package-amd64:
needs: [ unit-tests-linux ]
runs-on: ubuntu-latest
# if this is a push into one of our main branches (rather than just a pull request), we will also package
if: github.event_name != 'pull_request'
outputs:
version_number: ${{ env.VERSION }}
steps:
- uses: actions/checkout@v4
- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/build
- name: Setup Conan Cache
uses: actions/cache@v4
with:
path: ${{github.workspace}}/build/conan_home/
key: conan-${{ runner.os }}-${{ hashFiles('conanfile.py', '*/conanfile.py') }}
restore-keys: conan-${{ runner.os }}-
- name: Build pktvisord + push symbol to bugsplat.com
uses: ./.github/actions/build-cpp
with:
context: "."
build_type: "Release"
asan: "OFF"
bugsplat_key: ${{secrets.BUGSPLAT_KEY}}
bugsplat_symbol_url: ${{secrets.BUGSPLAT_SYMBOL_URL}}
bugsplat: "true"
file: "./Dockerfile"
- name: Build pktvisor-cli
uses: ./.github/actions/build-go
with:
context: "."
file: "./Dockerfile"
- name: Debug artifacts
run: ls -lha .
- name: Get VERSION
id: build
run: |
echo "VERSION=${{needs.unit-tests-linux.outputs.version_number}}" >> $GITHUB_ENV
echo "::set-output name=version::$(echo env.VERSION)"
- name: Generate ref tag (develop)
run: |
echo "REF_TAG=latest-develop" >> $GITHUB_ENV
echo "PRERELEASE=true" >> $GITHUB_ENV
echo "DRAFT=false" >> $GITHUB_ENV
- name: Debug ref tag
run: echo ${{ env.REF_TAG }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.ORB_DOCKERHUB_USERNAME }}
password: ${{ secrets.ORB_DOCKERHUB_TOKEN }}
- name: Replace token
run: |
sed -i -e "s/CP_TOKEN/${{ secrets.CRASHPAD_TOKEN }}/g" docker/run.sh
- name: Replace escape url
run: |
REPLACE=${{ secrets.BUGSPLAT_CP_URL }}
ESCAPED_REPLACE=$(printf '%s\n' "$REPLACE" | sed -e 's/[\/&]/\\&/g')
sed -i -e "s/CP_URL/$ESCAPED_REPLACE/g" docker/run.sh
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Build + push - pktvisor (multi-arch)
env:
IMAGE_NAME1: orbcommunity/pktvisor
IMAGE_NAME2: ghcr.io/orb-community/pktvisor
uses: docker/build-push-action@v3
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./docker/Dockerfile.crashhandler
platforms: linux/amd64
tags: ${{ env.IMAGE_NAME1 }}:${{ needs.unit-tests-linux.outputs.version_number }} , ${{ env.IMAGE_NAME1 }}:${{ env.REF_TAG }} , ${{ env.IMAGE_NAME2 }}:amd64-${{needs.unit-tests-linux.outputs.commit_hash}}
outputs: type=docker,dest=/tmp/amd64.tar
- name: Load image
env:
IMAGE_NAME1: orbcommunity/pktvisor
IMAGE_NAME2: ghcr.io/orb-community/pktvisor
run: |
docker load --input /tmp/amd64.tar
docker image ls -a
docker push ${{ env.IMAGE_NAME2 }}:amd64-${{needs.unit-tests-linux.outputs.commit_hash}}
docker push ${{ env.IMAGE_NAME1 }}:${{ env.REF_TAG }}
docker push ${{ env.IMAGE_NAME1 }}:${{ needs.unit-tests-linux.outputs.version_number }}
build-app-image-x64:
needs: [ package-amd64 ]
runs-on: ubuntu-latest
#if: github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v4
- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/build
- name: Get Conan
id: conan
uses: turtlebrowser/get-conan@main
with:
version: 1.64.1
- name: Configure CMake to generate VERSION
shell: bash
working-directory: ${{github.workspace}}/build
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
- name: Get VERSION
id: build
run: |
echo "VERSION=`cat ${{github.workspace}}/build/VERSION`" >> $GITHUB_ENV
echo "::set-output name=version::$(cat ${{github.workspace}}/build/VERSION)"
- name: Debug version
run: |
echo ${{ env.VERSION }}
echo ${{ steps.build.outputs.version }}
- name: Generate ref tag (develop)
run: |
echo "REF_TAG=latest-develop" >> $GITHUB_ENV
echo "PRERELEASE=true" >> $GITHUB_ENV
echo "DRAFT=false" >> $GITHUB_ENV
- name: Prepare version file
run: |
cp -rpf golang/pkg/client/version.go .
- name: Build pktvisor-cli
uses: ./.github/actions/build-go
with:
context: "."
file: "./Dockerfile"
- name: Debug and Rename artifacts
run: |
ls -lha .
mv pktvisor-cli pktvisor-cli-linux-x86_64-${{ env.VERSION }}
- name: Upload pktvisor-cli artifact
env:
BINARY_NAME: pktvisor-cli-linux-x86_64-${{ env.VERSION }}
uses: actions/upload-artifact@v4
with:
name: ${{ env.BINARY_NAME }}
path: ${{github.workspace}}/${{ env.BINARY_NAME }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.ORB_DOCKERHUB_USERNAME }}
password: ${{ secrets.ORB_DOCKERHUB_TOKEN }}
- name: Build + push - pktvisor-prom-write
env:
IMAGE_NAME: orbcommunity/pktvisor-prom-write
working-directory: ${{github.workspace}}/centralized_collection/prometheus/docker-grafana-agent
run: |
docker build . --file Dockerfile --build-arg PKTVISOR_TAG=${{ env.REF_TAG }} --tag ${{ env.IMAGE_NAME }}:${{ env.VERSION }} --tag ${{ env.IMAGE_NAME }}:${{ env.REF_TAG }}
docker push -a ${{ env.IMAGE_NAME }}
- name: Generate AppImage
env:
IMAGE_NAME: orbcommunity/pktvisor
working-directory: ${{github.workspace}}/appimage
run: |
DEV_IMAGE="${{ env.IMAGE_NAME }}:${{ env.VERSION }}" DEV_MODE=t make pktvisor-x86_64.AppImage
mv pktvisor-x86_64.AppImage pktvisor-x86_64-${{ env.VERSION }}.AppImage
- name: Upload AppImage artifact
uses: actions/upload-artifact@v4
with:
name: pktvisor-x86_64-${{ env.VERSION }}.AppImage
path: ${{github.workspace}}/appimage/pktvisor-x86_64-${{ env.VERSION }}.AppImage
build-orb-agent:
needs: [ package-amd64, unit-tests-mac ]
runs-on: ubuntu-latest
steps:
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.BOT_TOKEN }}
repository: orb-community/orb
event-type: build-agent
client-payload: '{"branch_name": "develop"}'
spinup-amd64-runner:
needs: [ package-amd64, unit-tests-mac ]
runs-on: ubuntu-latest
outputs:
runner_token: ${{ steps.token.outputs.runner }}
# if: github.event_name != 'pull_request'
if: false # This job will never run
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Generate runner token
id: token
run: |
sleep 3
curl -X POST -H "authorization: Bearer ${{ secrets.BOT_TOKEN }}" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/orb-community/pktvisor/actions/runners/registration-token -o token.json
echo "::set-output name=runner::$(cat token.json | jq .token --raw-output )"
cat token.json
- name: Get short commit hash to a variable
id: commit_hash
run: |
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- name: Inject runner token in user_data.sh
run: |
cd .github/hosted-runner/amd64/
ESCAPED_REPLACE_RUNNER_TOKEN=$(printf '%s\n' "${{ steps.token.outputs.runner }}" | sed -e 's/[\/&]/\\&/g')
sed -i -e "s/RUNNER_TOKEN/$ESCAPED_REPLACE_RUNNER_TOKEN/g" user_data.sh
ESCAPED_REPLACE_RUNNER_NAME=$(printf '%s\n' "AMD64-${{ steps.commit_hash.outputs.sha_short }}" | sed -e 's/[\/&]/\\&/g')
sed -i -e "s/AMD64_RUNNER/$ESCAPED_REPLACE_RUNNER_NAME/g" user_data.sh
- name: Inject AWS key
run: |
cd .github/hosted-runner/amd64/
ESCAPED_REPLACE_KEY_ID=$(printf '%s\n' "${{ secrets.AWS_ACCESS_KEY_ID }}" | sed -e 's/[\/&]/\\&/g')
sed -i -e "s/AWSID/$ESCAPED_REPLACE_KEY_ID/g" vars.tf
ESCAPED_REPLACE_ACCESS_KEY=$(printf '%s\n' "${{ secrets.AWS_SECRET_ACCESS_KEY }}" | sed -e 's/[\/&]/\\&/g')
sed -i -e "s/AWSSECRET/$ESCAPED_REPLACE_ACCESS_KEY/g" vars.tf
ESCAPED_REPLACE_ENVIRONMENT=$(printf '%s\n' "${{ needs.package-amd64.outputs.branch_name }}-${{ steps.commit_hash.outputs.sha_short }}-tests" | sed -e 's/[\/&]/\\&/g')
sed -i -e "s/ENVIRONMENT/$ESCAPED_REPLACE_ENVIRONMENT/g" vars.tf
- name: setup terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.1.7
terraform_wrapper: false
- name: Terraform Init
run: |
cd .github/hosted-runner/amd64/
terraform init -input=false
- name: Terraform plan
run: |
cd .github/hosted-runner/amd64/
terraform plan -out=tfplan
- name: Terraform apply
run: |
cd .github/hosted-runner/amd64/
terraform apply -auto-approve tfplan
- name: Terraform output
run: |
cd .github/hosted-runner/amd64/
terraform output -raw ip > ip.txt
- name: Persist IP to workspace
uses: actions/upload-artifact@v4
with:
name: ip
path: |
.github/hosted-runner/amd64/ip.txt
retention-days: 1
- name: Persist to workspace
uses: actions/upload-artifact@v4
with:
name: terraform
path: |
.github/hosted-runner/amd64/terraform.tfstate
retention-days: 1
integration-tests:
needs: [ spinup-amd64-runner, package-amd64 ]
runs-on: [self-hosted, linux, x64]
outputs:
commit_hash: ${{ steps.commit_hash.outputs.sha_short }}
# if this is a push into one of our main branches (rather than just a pull request), we will also package
if: github.event_name != 'pull_request'
steps:
- uses: AutoModality/action-clean@v1
- uses: actions/checkout@v4
- name: Locking pktvisor integration test state
run: |
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -u "${{ secrets.QA_AUTH_CREDENTIALS }}" -d "change=pktvisor-dev&state=active" https://qa.ops.orb.live/api.php
- name: Debug version
run: |
echo ${{ env.VERSION }}
echo ${{ needs.package-amd64.outputs.version_number }}
- name: Prepare test config
run: |
cd ./automated_tests/
mv test_config.ini.tpl test_config.ini
- name: commit hash
id: commit_hash
run: |
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Test
continue-on-error: true
run: |
cd ./automated_tests/
python3.8 -m venv behave_pktvisor
source behave_pktvisor/bin/activate
sudo pip3 install -r requirements.txt
sudo pip3 install -r requirements.txt
sudo behavex -t=@smoke --parallel-processes=20 --parallel-scheme=scenario
- name: Copy VERSION file
run: |
sudo chmod 777 ./automated_tests/ -R
echo ${{ needs.package-amd64.outputs.version_number }} > ./automated_tests/output/VERSION
- name: Persist to workspace
uses: actions/upload-artifact@v4
with:
name: workspace
path: |
./automated_tests/
!./automated_tests/behave_pktvisor
retention-days: 1
- name: Unlocking pktvisor integration test state
run: |
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -u "${{ secrets.QA_AUTH_CREDENTIALS }}" -d "change=pktvisor-dev&state=inactive" https://qa.ops.orb.live/api.php
upload-qa-artifact:
needs: [ integration-tests ]
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
- name: Attach to workspace
uses: actions/download-artifact@v4
with:
name: workspace
- name: debug files
run: |
ls -lha
- name: Upload pktvisor report to qa host
uses: appleboy/scp-action@master
with:
host: qa.ops.orb.live
username: root
key: ${{ secrets.RUNNER_SSH_KEY }}
port: 2022
source: "./output/*"
target: "/usr/share/nginx/html/test_data/pktvisor/develop/${{ needs.integration-tests.outputs.commit_hash }}/pktvisor/python-test"
remove-github-runner-amd64:
continue-on-error: true
needs: [ spinup-amd64-runner , upload-qa-artifact ]
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
- name: Attach to workspace
uses: actions/download-artifact@v4
with:
name: ip
- name: Get runner ip
id: address
run: |
ls -lha
echo "::set-output name=ip::$(cat ip.txt)"
- name: Executing remote ssh commands on runner
uses: appleboy/ssh-action@master
with:
host: ${{ steps.address.outputs.ip }}
username: ubuntu
key: ${{ secrets.RUNNER_SSH_KEY }}
port: 22
script: |
cd /actions-runner
sudo chmod 777 . -R
./config.sh remove --token ${{ needs.spinup-amd64-runner.outputs.runner_token }}
remove-amd64-runner:
needs: [ remove-github-runner-amd64 ]
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Attach to workspace
uses: actions/download-artifact@v4
with:
name: terraform
path: .github/hosted-runner/amd64/
- name: Inject AWS key
run: |
cd .github/hosted-runner/amd64/
ESCAPED_REPLACE_KEY_ID=$(printf '%s\n' "${{ secrets.AWS_ACCESS_KEY_ID }}" | sed -e 's/[\/&]/\\&/g')
sed -i -e "s/AWSID/$ESCAPED_REPLACE_KEY_ID/g" vars.tf
ESCAPED_REPLACE_ACCESS_KEY=$(printf '%s\n' "${{ secrets.AWS_SECRET_ACCESS_KEY }}" | sed -e 's/[\/&]/\\&/g')
sed -i -e "s/AWSSECRET/$ESCAPED_REPLACE_ACCESS_KEY/g" vars.tf
- name: setup terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.1.7
- name: Terraform Init
run: |
cd .github/hosted-runner/amd64/
terraform init -input=false
- name: Terraform plan destroy
run: |
cd .github/hosted-runner/amd64/
terraform plan -destroy
continue-on-error: true
- name: Terraform destroy
run: |
cd .github/hosted-runner/amd64/
terraform destroy -auto-approve
spinup-arm64-runner:
needs: [ unit-tests-linux ]
runs-on: ubuntu-latest
outputs:
runner_token: ${{ steps.token.outputs.runner }}
if: github.event_name != 'pull_request'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get branch name
shell: bash
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV
- name: Generate runner token
id: token
run: |
curl -X POST -H "authorization: Bearer ${{ secrets.BOT_TOKEN }}" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/orb-community/pktvisor/actions/runners/registration-token -o token.json
echo "::set-output name=runner::$(cat token.json | jq .token --raw-output )"
cat token.json
- name: commit hash
id: commit_hash
run: |
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- name: Inject runner token in user_data.sh
run: |
cd .github/hosted-runner/arm64/
ESCAPED_REPLACE_RUNNER_TOKEN=$(printf '%s\n' "${{ steps.token.outputs.runner }}" | sed -e 's/[\/&]/\\&/g')
sed -i -e "s/RUNNER_TOKEN/$ESCAPED_REPLACE_RUNNER_TOKEN/g" user_data.sh
ESCAPED_REPLACE_RUNNER_NAME=$(printf '%s\n' "ARM64-${{ steps.commit_hash.outputs.sha_short }}" | sed -e 's/[\/&]/\\&/g')
sed -i -e "s/ARM64_RUNNER/$ESCAPED_REPLACE_RUNNER_NAME/g" user_data.sh
- name: Inject AWS key
run: |
cd .github/hosted-runner/arm64/
ESCAPED_REPLACE_KEY_ID=$(printf '%s\n' "${{ secrets.AWS_ACCESS_KEY_ID }}" | sed -e 's/[\/&]/\\&/g')
sed -i -e "s/AWSID/$ESCAPED_REPLACE_KEY_ID/g" vars.tf
ESCAPED_REPLACE_ACCESS_KEY=$(printf '%s\n' "${{ secrets.AWS_SECRET_ACCESS_KEY }}" | sed -e 's/[\/&]/\\&/g')
sed -i -e "s/AWSSECRET/$ESCAPED_REPLACE_ACCESS_KEY/g" vars.tf
ESCAPED_REPLACE_ENVIRONMENT=$(printf '%s\n' "${{ env.BRANCH_NAME }}-${{ steps.commit_hash.outputs.sha_short }}-package" | sed -e 's/[\/&]/\\&/g')
sed -i -e "s/ENVIRONMENT/$ESCAPED_REPLACE_ENVIRONMENT/g" vars.tf
- name: setup terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.1.7
terraform_wrapper: false
- name: Terraform Init
run: |
cd .github/hosted-runner/arm64/
terraform init -input=false
- name: Terraform plan
run: |
cd .github/hosted-runner/arm64/
terraform plan -out=tfplan
- name: Terraform apply
run: |
cd .github/hosted-runner/arm64/
terraform apply -auto-approve tfplan
- name: Terraform output
run: |
cd .github/hosted-runner/arm64/
terraform output -raw ip > ip.txt
- name: Persist IP to workspace
uses: actions/upload-artifact@v4
with:
name: ip-arm
path: |
.github/hosted-runner/arm64/ip.txt
retention-days: 1
- name: Persist to workspace
uses: actions/upload-artifact@v4
with:
name: terraform2
path: |
.github/hosted-runner/arm64/terraform.tfstate
retention-days: 1
package-arm64:
needs: [ unit-tests-linux, spinup-arm64-runner ]
runs-on: [self-hosted, linux, ARM64]
if: github.event_name != 'pull_request'
steps:
- name: cleanup #https://github.com/actions/checkout/issues/211
run: |
sudo chown -R $USER:$USER $GITHUB_WORKSPACE
- name: Checkout
uses: actions/checkout@v4
- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/build
- name: Setup Conan Cache
uses: actions/cache@v4
with:
path: ${{github.workspace}}/build/conan_home/
key: conan-${{ runner.os }}-arm64-${{ hashFiles('conanfile.py', '*/conanfile.py') }}
restore-keys: conan-${{ runner.os }}-arm64-
- name: Build pktvisord + push symbol to bugsplat.com
uses: ./.github/actions/build-cpp
with:
context: "."
build_type: "Release"
asan: "OFF"
bugsplat_key: ${{secrets.BUGSPLAT_KEY}}
bugsplat_symbol_url: ${{secrets.BUGSPLAT_SYMBOL_URL}}
bugsplat: "false"
file: "./Dockerfile"
- name: Build pktvisor-cli
uses: ./.github/actions/build-go
with:
context: "."
file: "./Dockerfile"
goarch: "arm64"
- name: Debug artifacts
run: ls -lha .
- name: Generate ref tag (develop)
if: ${{ env.BRANCH_NAME == 'develop' }}
run: |
echo "REF_TAG=latest-develop" >> $GITHUB_ENV
echo "PRERELEASE=false" >> $GITHUB_ENV
echo "DRAFT=true" >> $GITHUB_ENV
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Replace token
run: |
sed -i -e "s/CP_TOKEN/${{ secrets.CRASHPAD_TOKEN }}/g" docker/run.sh
- name: Replace escape url
run: |
REPLACE=${{ secrets.BUGSPLAT_CP_URL }}
ESCAPED_REPLACE=$(printf '%s\n' "$REPLACE" | sed -e 's/[\/&]/\\&/g')
sed -i -e "s/CP_URL/$ESCAPED_REPLACE/g" docker/run.sh
- name: Build + push - pktvisor (multi-arch)
id: docker_build
env:
IMAGE_NAME: ghcr.io/orb-community/pktvisor
uses: docker/build-push-action@v3
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./docker/Dockerfile.crashhandler
platforms: linux/arm64
tags: ${{ env.IMAGE_NAME }}:arm64-${{needs.unit-tests-linux.outputs.commit_hash}}
outputs: type=docker,dest=/tmp/arm64.tar
- name: Load image
env:
IMAGE_NAME: ghcr.io/orb-community/pktvisor
run: |
docker load --input /tmp/arm64.tar
docker image ls -a
docker push ${{ env.IMAGE_NAME }}:arm64-${{needs.unit-tests-linux.outputs.commit_hash}}
remove-github-runner-arm64:
continue-on-error: true
needs: [ spinup-arm64-runner, package-arm64 ]
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
- name: Attach to workspace
uses: actions/download-artifact@v4
with:
name: ip-arm
- name: Get runner ip
id: address
run: |
ls -lha
echo "::set-output name=ip::$(cat ip.txt)"
- name: Executing remote ssh commands on runner
uses: appleboy/ssh-action@master
with:
host: ${{ steps.address.outputs.ip }}
username: ubuntu
key: ${{ secrets.RUNNER_SSH_KEY }}
port: 22
script: |
cd /actions-runner
sudo chmod 777 . -R
./config.sh remove --token ${{ needs.spinup-arm64-runner.outputs.runner_token }}
remove-arm64-runner:
needs: [ remove-github-runner-arm64 ]
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Attach to workspace
uses: actions/download-artifact@v4
with:
name: terraform2
path: .github/hosted-runner/arm64/
- name: Inject AWS key
run: |
cd .github/hosted-runner/arm64/
ESCAPED_REPLACE_KEY_ID=$(printf '%s\n' "${{ secrets.AWS_ACCESS_KEY_ID }}" | sed -e 's/[\/&]/\\&/g')
sed -i -e "s/AWSID/$ESCAPED_REPLACE_KEY_ID/g" vars.tf
ESCAPED_REPLACE_ACCESS_KEY=$(printf '%s\n' "${{ secrets.AWS_SECRET_ACCESS_KEY }}" | sed -e 's/[\/&]/\\&/g')
sed -i -e "s/AWSSECRET/$ESCAPED_REPLACE_ACCESS_KEY/g" vars.tf
- name: setup terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.1.7
- name: Terraform Init
run: |
cd .github/hosted-runner/arm64/
terraform init -input=false
- name: Terraform plan destroy
run: |
cd .github/hosted-runner/arm64/
terraform plan -destroy
continue-on-error: true
- name: Terraform destroy
run: |
cd .github/hosted-runner/arm64/
terraform destroy -auto-approve
pushing-manifests:
needs: [ unit-tests-linux, remove-github-runner-arm64 ]
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create docker manifest
run: |
docker manifest create ghcr.io/orb-community/pktvisor:latest-develop \
ghcr.io/orb-community/pktvisor:amd64-${{needs.unit-tests-linux.outputs.commit_hash}} \
ghcr.io/orb-community/pktvisor:arm64-${{needs.unit-tests-linux.outputs.commit_hash}}
- name: Push manifest to ghcr.io
run: |
docker manifest push ghcr.io/orb-community/pktvisor:latest-develop
- name: Install skopeo