-
Notifications
You must be signed in to change notification settings - Fork 0
1267 lines (1207 loc) · 51.3 KB
/
build_test.yml
File metadata and controls
1267 lines (1207 loc) · 51.3 KB
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-and-test
on: [push]
permissions:
contents: read
pull-requests: read
env:
REGISTRY_DOCS_IMAGE: kitsudaiki/ainari_docs
AINARI_ADMIN_ID: asdf
AINARI_ADMIN_NAME: asdf
AINARI_ADMIN_PASSPHRASE: asdfasdf
RUSTFLAGS: "-Dwarnings"
jobs:
# ansible-lint:
# name: "Lint ansible playbook"
# runs-on: ubuntu-latest
# env:
# FORCE_COLOR: 1
# steps:
# - uses: earthly/actions-setup@43211c7a0eae5344d6d79fb4aaf209c8f8866203
# with:
# version: v0.8.0
# - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
# -
# name: Run check
# run: earthly --ci +ansible-lint
clippy-check:
name: cargo clippy
runs-on: ubuntu-24.04
steps:
-
name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler gcc ssh curl pkg-config libssl-dev libsqlite3-dev
sudo curl https://sh.rustup.rs -sSf | sh -s -- -y
-
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
-
name: Run Clippy
run: cargo clippy --all-targets --all-features
rustfmt-check:
name: cargo fmt
runs-on: ubuntu-latest
steps:
-
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
-
uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48
with:
components: rustfmt
-
name: Rustfmt Check
uses: actions-rust-lang/rustfmt@559aa3035a47390ba96088dffa783b5d26da9326
flake8-check:
name: "flake8 check"
runs-on: ubuntu-latest
env:
FORCE_COLOR: 1
steps:
-
uses: earthly/actions-setup@b81a8e082d9fae6174210cfc6e54bd2feb124d94
with:
version: "latest"
-
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
-
name: Run check
run: earthly --ci +flake8
check-for-executables:
name: "Detect binary executables"
runs-on: ubuntu-latest
steps:
-
name: checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
-
name: Run binary files check script
run: |
git ls-tree -r HEAD --name-only | while read filename; do
# Check if the file is a binary
if [[ $(file -b --mime-encoding "$filename") == binary ]] && file -b "$filename" | grep -q "executable"; then
echo "Binary file found: $filename"
exit 1
fi
done
exit 0
commit-lint:
name: "Lint commits"
runs-on: ubuntu-latest
steps:
-
name: checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
-
name: lint commits
uses: wagoid/commitlint-github-action@7f0a61df502599e1f1f50880aaa7ec1e2c0592f2
detect-sectets:
name: "Detect secrets"
runs-on: ubuntu-latest
env:
FORCE_COLOR: 1
steps:
-
name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y git python3 python3-venv python3-pip
-
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
-
name: Run check
run: |
python3 -m venv venv
source venv/bin/activate
pip3 install detect-secrets
git ls-files -z | xargs -0 detect-secrets-hook --baseline .secrets.baseline
build_python_package:
name: "Build SDK python-package"
needs: [ clippy-check, rustfmt-check, flake8-check, check-for-executables, commit-lint, detect-sectets ]
runs-on: ubuntu-latest
env:
FORCE_COLOR: 1
steps:
-
name: Set helm-version as environment variable
run: |
if [[ ${GITHUB_REF#} == refs/tags/* ]]; then \
echo "PYTHON_PACKAGE_VERSION=$(echo ${GITHUB_REF#refs/tags/} | sed 's/^v//')" | sed 's#/#\-#' >> $GITHUB_ENV; \
else \
echo "PYTHON_PACKAGE_VERSION=0.0.0" | sed 's#/#\-#' >> $GITHUB_ENV; \
fi
-
name: Checkout repository
run: |
# use manually clone, because with the "actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332" action the name of the
# branch can not be read by the git commands, which is necessary for the build-script
git clone https://github.com/kitsudaiki/${GITHUB_REPOSITORY#*/}.git
cd ${GITHUB_REPOSITORY#*/}
git checkout ${GITHUB_REF#refs/heads/}
-
name: Install dependencies for SDK
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler wget gzip python3 python3-pip python3-wheel
-
name: Build python package
run: |
cd ${GITHUB_REPOSITORY#*/}/src/sdk/python/ainari_sdk
python3 setup.py bdist_wheel --universal
-
name: Copy files
run: |
mkdir /tmp/ainari_python_build_result
cd ${GITHUB_REPOSITORY#*/}/src/sdk/python/ainari_sdk/dist
ls -l
cp ./ainari_sdk-$PYTHON_PACKAGE_VERSION-py2.py3-none-any.whl /tmp/ainari_python_build_result/
-
name: Create artifact
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b
with:
name: ainari_python_build_result
path: /tmp/ainari_python_build_result
retention-days: 1
build_helm_package:
name: "Build Helm package"
needs: [ clippy-check, rustfmt-check, flake8-check, check-for-executables, commit-lint, detect-sectets ]
runs-on: ubuntu-latest
env:
FORCE_COLOR: 1
steps:
-
name: Set helm-version as environment variable
run: |
if [[ ${GITHUB_REF#} == refs/tags/* ]]; then \
echo "HELM_VERSION=$(echo ${GITHUB_REF#refs/tags/} | sed 's/^v//')" | sed 's#/#\-#' >> $GITHUB_ENV; \
else \
echo "HELM_VERSION=0.0.0" | sed 's#/#\-#' >> $GITHUB_ENV; \
fi
-
name: Checkout repository
run: |
# use manually clone, because with the "actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332" action the name of the
# branch can not be read by the git commands, which is necessary for the build-script
git clone https://github.com/kitsudaiki/${GITHUB_REPOSITORY#*/}.git
cd ${GITHUB_REPOSITORY#*/}
git checkout ${GITHUB_REF#refs/heads/}
-
name: Build helm chart
run: |
cd ${GITHUB_REPOSITORY#*/}/deploy/k8s/ainari
helm package --version $HELM_VERSION .
-
name: Copy files
run: |
mkdir /tmp/ainari_helm_build_result
cd ${GITHUB_REPOSITORY#*/}
cp ./deploy/k8s/ainari/ainari-$HELM_VERSION.tgz /tmp/ainari_helm_build_result/
-
name: Create artifact
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b
with:
name: ainari_helm_build_result
path: /tmp/ainari_helm_build_result
retention-days: 1
build_ainari_debug:
name: "Compile ainari (debug)"
needs: [ clippy-check, rustfmt-check, flake8-check, check-for-executables, commit-lint, detect-sectets ]
runs-on: ubuntu-latest
env:
FORCE_COLOR: 1
steps:
-
name: Install dependencies for SDK
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler gcc ssh curl pkg-config libssl-dev libsqlite3-dev
sudo curl https://sh.rustup.rs -sSf | sh -s -- -y
-
name: Checkout repository
run: |
# use manually clone, because with the "actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332" action the name of the
# branch can not be read by the git commands, which is necessary for the build-script
git clone https://github.com/kitsudaiki/${GITHUB_REPOSITORY#*/}.git
cd ${GITHUB_REPOSITORY#*/}
git checkout ${GITHUB_REF#refs/heads/}
git submodule init
git submodule update --recursive
-
name: Compile ainari
run: |
cd ${GITHUB_REPOSITORY#*/}
cargo build
-
name: Copy files
run: |
mkdir -p /tmp/ainari_debug_build_result/ainari/
cd ${GITHUB_REPOSITORY#*/}
cp ./target/debug/sakura /tmp/ainari_debug_build_result/ainari/
cp ./target/debug/miko /tmp/ainari_debug_build_result/ainari/
cp ./target/debug/ryokan /tmp/ainari_debug_build_result/ainari/
cp ./target/debug/hanami /tmp/ainari_debug_build_result/ainari/
cp ./target/debug/torii /tmp/ainari_debug_build_result/ainari/
cp ./target/debug/omamori /tmp/ainari_debug_build_result/ainari/
cp ./target/debug/onsen /tmp/ainari_debug_build_result/ainari/
-
name: Create artifact
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b
with:
name: ainari_debug_build_result
path: /tmp/ainari_debug_build_result
retention-days: 1
build_ainarictl:
name: "Compile CLI"
needs: [ clippy-check, rustfmt-check, flake8-check, check-for-executables, commit-lint, detect-sectets ]
runs-on: ubuntu-latest
env:
FORCE_COLOR: 1
steps:
-
uses: earthly/actions-setup@b81a8e082d9fae6174210cfc6e54bd2feb124d94
with:
version: "latest"
-
name: Checkout repository
run: |
# use manually clone, because with the "actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332" action the name of the
# branch can not be read by the git commands, which is necessary for the build-script
git clone https://github.com/kitsudaiki/${GITHUB_REPOSITORY#*/}.git
cd ${GITHUB_REPOSITORY#*/}
git checkout ${GITHUB_REF#refs/heads/}
git submodule init
git submodule update --recursive
-
name: Compile code
run: |
cd ${GITHUB_REPOSITORY#*/}
earthly --artifact +compile-cli/tmp/ainarictl ./builds/
-
name: Copy files
run: |
mkdir /tmp/ainarictl_build_result
cd ${GITHUB_REPOSITORY#*/}
cp -r builds/ainarictl /tmp/ainarictl_build_result/
-
name: Create artifact
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b
with:
name: ainarictl_build_result
path: /tmp/ainarictl_build_result
retention-days: 1
cargo_tests:
name: "Cargo Test"
needs: [ clippy-check, rustfmt-check, flake8-check, check-for-executables, commit-lint, detect-sectets ]
runs-on: ubuntu-latest
env:
FORCE_COLOR: 1
steps:
-
uses: earthly/actions-setup@b81a8e082d9fae6174210cfc6e54bd2feb124d94
with:
version: "latest"
-
name: Checkout repository
run: |
# use manually clone, because with the "actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332" action the name of the
# branch can not be read by the git commands, which is necessary for the build-script
git clone https://github.com/kitsudaiki/${GITHUB_REPOSITORY#*/}.git
cd ${GITHUB_REPOSITORY#*/}
git checkout ${GITHUB_REF#refs/heads/}
git submodule init
git submodule update --recursive
-
name: Compile code
run: |
cd ${GITHUB_REPOSITORY#*/}
earthly +test-ainari
sdk_api_tests:
name: "SDK-API-Tests"
needs: [ cargo_tests, build_ainari_debug, build_ainarictl, build_helm_package, build_python_package ]
runs-on: ubuntu-24.04
steps:
-
name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y openssl libsqlite3-0
-
name: Set python-version as environment variable
run: |
if [[ ${GITHUB_REF#} == refs/tags/* ]]; then \
echo "PYTHON_PACKAGE_VERSION=$(echo ${GITHUB_REF#refs/tags/} | sed 's/^v//')" | sed 's#/#\-#' >> $GITHUB_ENV; \
else \
echo "PYTHON_PACKAGE_VERSION=0.0.0" | sed 's#/#\-#' >> $GITHUB_ENV; \
fi
-
name: Checkout repository
run: |
# use manually clone, because with the "actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332" action the name of the
# branch can not be read by the git commands, which is necessary for the build-script
git clone https://github.com/kitsudaiki/${GITHUB_REPOSITORY#*/}.git
cd ${GITHUB_REPOSITORY#*/}
git checkout ${GITHUB_REF#refs/heads/}
git submodule init
git submodule update --recursive
-
name: Get artifact
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
name: ainari_python_build_result
path: /tmp/ainari_python_build_result
-
name: Get artifact
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
name: ainari_debug_build_result
path: /tmp/ainari_debug_build_result
-
name: Install dependencies for SDK
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler wget gzip python3 python3-pip
cd /tmp/ainari_python_build_result
ls -l
pip3 install -U ainari_sdk-$PYTHON_PACKAGE_VERSION-py2.py3-none-any.whl
-
name: Download mnist-files
run: |
cd /tmp/
wget https://storage.googleapis.com/cvdf-datasets/mnist/train-images-idx3-ubyte.gz
wget https://storage.googleapis.com/cvdf-datasets/mnist/train-labels-idx1-ubyte.gz
wget https://storage.googleapis.com/cvdf-datasets/mnist/t10k-images-idx3-ubyte.gz
wget https://storage.googleapis.com/cvdf-datasets/mnist/t10k-labels-idx1-ubyte.gz
gzip -d train-images-idx3-ubyte.gz
gzip -d train-labels-idx1-ubyte.gz
gzip -d t10k-images-idx3-ubyte.gz
gzip -d t10k-labels-idx1-ubyte.gz
-
name: run Sakura in background
run: |
cd ${GITHUB_REPOSITORY#*/}
export INTERNAL_API_KEY=test-internal-api-key && export SAKURA_REGISTRATION_KEY=sakura-key && export ONSEN_REGISTRATION_KEY=onsen-key
chmod +x /tmp/ainari_debug_build_result/ainari/hanami
chmod +x /tmp/ainari_debug_build_result/ainari/miko
chmod +x /tmp/ainari_debug_build_result/ainari/ryokan
chmod +x /tmp/ainari_debug_build_result/ainari/sakura
chmod +x /tmp/ainari_debug_build_result/ainari/torii
chmod +x /tmp/ainari_debug_build_result/ainari/omamori
chmod +x /tmp/ainari_debug_build_result/ainari/onsen
mkdir -p builds/binaries
sudo cp -r ./example_configs/ainari /etc/ainari
sudo chmod 777 -R /etc/ainari
/tmp/ainari_debug_build_result/ainari/hanami &
/tmp/ainari_debug_build_result/ainari/miko &
/tmp/ainari_debug_build_result/ainari/ryokan &
/tmp/ainari_debug_build_result/ainari/torii &
/tmp/ainari_debug_build_result/ainari/omamori &
# sleep to make sure, that hanami is started before sakura starts
sleep 10
/tmp/ainari_debug_build_result/ainari/sakura &
/tmp/ainari_debug_build_result/ainari/onsen &
# BINARY_PID=$!
# trap "kill $BINARY_PID" EXIT
-
name: Sleep for 15 seconds
uses: jakejarvis/wait-action@919fc193e07906705e5b7a50f90ea9e74d20b2b0
with:
time: '15s'
-
name: Run test
run: |
cd ${GITHUB_REPOSITORY#*/}/testing/python_sdk_api
mkdir -p test_dir
cp sdk_api_test.py test_dir/
cp test_values.py test_dir/
cp csv_test.csv test_dir/
cd test_dir
/usr/bin/python3 sdk_api_test.py
cli_api_tests:
name: "CLI-API-Tests"
needs: [ cargo_tests, build_ainari_debug, build_ainarictl, build_helm_package, build_python_package ]
runs-on: ubuntu-24.04
steps:
-
name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y openssl libsqlite3-0
-
name: Checkout repository
run: |
# use manually clone, because with the "actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332" action the name of the
# branch can not be read by the git commands, which is necessary for the build-script
git clone https://github.com/kitsudaiki/${GITHUB_REPOSITORY#*/}.git
cd ${GITHUB_REPOSITORY#*/}
git checkout ${GITHUB_REF#refs/heads/}
git submodule init
git submodule update --recursive
-
name: Get artifact
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
name: ainari_debug_build_result
path: /tmp/ainari_debug_build_result
-
name: Get artifact
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
name: ainarictl_build_result
path: /tmp/ainarictl_build_result
-
name: Build local docker-image
run: |
chmod +x /tmp/ainarictl_build_result/ainarictl
cp /tmp/ainarictl_build_result/ainarictl ${GITHUB_REPOSITORY#*/}/testing/go_cli_api/
-
name: Download mnist-files
run: |
cd /tmp/
wget https://storage.googleapis.com/cvdf-datasets/mnist/train-images-idx3-ubyte.gz
wget https://storage.googleapis.com/cvdf-datasets/mnist/train-labels-idx1-ubyte.gz
wget https://storage.googleapis.com/cvdf-datasets/mnist/t10k-images-idx3-ubyte.gz
wget https://storage.googleapis.com/cvdf-datasets/mnist/t10k-labels-idx1-ubyte.gz
gzip -d train-images-idx3-ubyte.gz
gzip -d train-labels-idx1-ubyte.gz
gzip -d t10k-images-idx3-ubyte.gz
gzip -d t10k-labels-idx1-ubyte.gz
-
name: run Sakura in background
run: |
cd ${GITHUB_REPOSITORY#*/}
export INTERNAL_API_KEY=test-internal-api-key && export SAKURA_REGISTRATION_KEY=sakura-key && export ONSEN_REGISTRATION_KEY=onsen-key
chmod +x /tmp/ainari_debug_build_result/ainari/hanami
chmod +x /tmp/ainari_debug_build_result/ainari/miko
chmod +x /tmp/ainari_debug_build_result/ainari/ryokan
chmod +x /tmp/ainari_debug_build_result/ainari/sakura
chmod +x /tmp/ainari_debug_build_result/ainari/torii
chmod +x /tmp/ainari_debug_build_result/ainari/omamori
chmod +x /tmp/ainari_debug_build_result/ainari/onsen
mkdir -p builds/binaries
sudo cp -r ./example_configs/ainari /etc/ainari
sudo chmod 777 -R /etc/ainari
/tmp/ainari_debug_build_result/ainari/hanami &
/tmp/ainari_debug_build_result/ainari/miko &
/tmp/ainari_debug_build_result/ainari/ryokan &
/tmp/ainari_debug_build_result/ainari/torii &
/tmp/ainari_debug_build_result/ainari/omamori &
# sleep to make sure, that hanami is started before sakura starts
sleep 10
/tmp/ainari_debug_build_result/ainari/sakura &
/tmp/ainari_debug_build_result/ainari/onsen &
# BINARY_PID=$!
# trap "kill $BINARY_PID" EXIT
-
name: Sleep for 15 seconds
uses: jakejarvis/wait-action@919fc193e07906705e5b7a50f90ea9e74d20b2b0
with:
time: '15s'
-
name: Run test
run: |
export PATH=$PATH:/usr/local/go/bin
cd ${GITHUB_REPOSITORY#*/}/testing/go_cli_api
export AINARI_ADDRESS=http://127.0.0.1:11417
export AINARI_USER=asdf
export AINARI_PASSPHRASE=asdfasdf
export TRAIN_INPUTS=/tmp/train-images-idx3-ubyte
export TRAIN_LABELS=/tmp/train-labels-idx1-ubyte
export REQUEST_INPUTS=/tmp/t10k-images-idx3-ubyte
export REQUEST_LABELS=/tmp/t10k-labels-idx1-ubyte
./cli_test.sh
python_version_test:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }}
needs: [ cargo_tests, build_ainari_debug, build_ainarictl, build_helm_package, build_python_package ]
strategy:
fail-fast: false
matrix:
python_version:
- { tag: "python-3_10", name: "Python 3.10", version: "3.10", runs-on: "ubuntu-22.04" }
- { tag: "python-3_11", name: "Python 3.11", version: "3.11", runs-on: "ubuntu-22.04" }
- { tag: "python-3_12", name: "Python 3.12", version: "3.12", runs-on: "ubuntu-24.04" }
runs-on: ${{ matrix.python_version.runs-on }}
name: "${{ matrix.python_version.name }}"
outputs:
python-3_10: ${{ steps.status.outputs.python-3_10 }}
python-3_11: ${{ steps.status.outputs.python-3_11 }}
python-3_12: ${{ steps.status.outputs.python-3_12 }}
steps:
-
name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y openssl libsqlite3-0
-
name: Set python-version as environment variable
run: |
if [[ ${GITHUB_REF#} == refs/tags/* ]]; then \
echo "PYTHON_PACKAGE_VERSION=$(echo ${GITHUB_REF#refs/tags/} | sed 's/^v//')" | sed 's#/#\-#' >> $GITHUB_ENV; \
else \
echo "PYTHON_PACKAGE_VERSION=0.0.0" | sed 's#/#\-#' >> $GITHUB_ENV; \
fi
-
name: Checkout repository
run: |
# use manually clone, because with the "actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332" action the name of the
# branch can not be read by the git commands, which is necessary for the build-script
git clone https://github.com/kitsudaiki/${GITHUB_REPOSITORY#*/}.git
cd ${GITHUB_REPOSITORY#*/}
git checkout ${GITHUB_REF#refs/heads/}
git submodule init
git submodule update --recursive
-
name: Get artifact
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
name: ainari_python_build_result
path: /tmp/ainari_python_build_result
-
name: Get artifact
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
name: ainari_debug_build_result
path: /tmp/ainari_debug_build_result
-
name: Install dependencies for SDK
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler wget gzip python3 python3-pip
cd /tmp/ainari_python_build_result
ls -l
pip3 install -U ainari_sdk-$PYTHON_PACKAGE_VERSION-py2.py3-none-any.whl
-
name: Download mnist-files
run: |
cd /tmp/
wget https://storage.googleapis.com/cvdf-datasets/mnist/train-images-idx3-ubyte.gz
wget https://storage.googleapis.com/cvdf-datasets/mnist/train-labels-idx1-ubyte.gz
wget https://storage.googleapis.com/cvdf-datasets/mnist/t10k-images-idx3-ubyte.gz
wget https://storage.googleapis.com/cvdf-datasets/mnist/t10k-labels-idx1-ubyte.gz
gzip -d train-images-idx3-ubyte.gz
gzip -d train-labels-idx1-ubyte.gz
gzip -d t10k-images-idx3-ubyte.gz
gzip -d t10k-labels-idx1-ubyte.gz
-
name: run Sakura in background
run: |
cd ${GITHUB_REPOSITORY#*/}
export INTERNAL_API_KEY=test-internal-api-key && export SAKURA_REGISTRATION_KEY=sakura-key && export ONSEN_REGISTRATION_KEY=onsen-key
chmod +x /tmp/ainari_debug_build_result/ainari/hanami
chmod +x /tmp/ainari_debug_build_result/ainari/miko
chmod +x /tmp/ainari_debug_build_result/ainari/ryokan
chmod +x /tmp/ainari_debug_build_result/ainari/sakura
chmod +x /tmp/ainari_debug_build_result/ainari/torii
chmod +x /tmp/ainari_debug_build_result/ainari/omamori
chmod +x /tmp/ainari_debug_build_result/ainari/onsen
mkdir -p builds/binaries
sudo cp -r ./example_configs/ainari /etc/ainari
sudo chmod 777 -R /etc/ainari
/tmp/ainari_debug_build_result/ainari/hanami &
/tmp/ainari_debug_build_result/ainari/miko &
/tmp/ainari_debug_build_result/ainari/ryokan &
/tmp/ainari_debug_build_result/ainari/torii &
/tmp/ainari_debug_build_result/ainari/omamori &
# sleep to make sure, that hanami is started before sakura starts
sleep 10
/tmp/ainari_debug_build_result/ainari/sakura &
/tmp/ainari_debug_build_result/ainari/onsen &
# BINARY_PID=$!
# trap "kill $BINARY_PID" EXIT
-
name: Sleep for 15 seconds
uses: jakejarvis/wait-action@919fc193e07906705e5b7a50f90ea9e74d20b2b0
with:
time: '15s'
-
name: Install python
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f
with:
python-version: "${{ matrix.python_version.version }}"
-
name: Install ainari-sdk
run: |
cd /tmp/ainari_python_build_result
ls -l
pip install -U ainari_sdk-$PYTHON_PACKAGE_VERSION-py2.py3-none-any.whl
-
name: Print installed python-version
run: |
python --version
-
name: Print installed pip-packages
run: |
pip list
-
name: Run test
run: |
cd ${GITHUB_REPOSITORY#*/}/testing/python_sdk_api
mkdir -p test_dir
cp sdk_api_test.py test_dir/
cp test_values.py test_dir/
cp csv_test.csv test_dir/
cd test_dir
python sdk_api_test.py
# -
# name: Get log-output for debugging
# id: docker_log
# if: ${{ always() }}
# run: docker logs hanami
-
name: Update Result
id: status
if: ${{ always() }}
run: echo "${{ matrix.python_version.tag }}=${{ job.status }}" >> $GITHUB_OUTPUT
docker_build:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' || github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
name: "Build"
needs: [ sdk_api_tests, cli_api_tests ]
strategy:
fail-fast: false
matrix:
builds:
- { component: "hanami", platform: "linux/amd64", runner: "ubuntu-24.04", regitry: "kitsudaiki/hanami" }
- { component: "hanami", platform: "linux/arm64", runner: "ubuntu-24.04-arm", regitry: "kitsudaiki/hanami" }
- { component: "miko", platform: "linux/amd64", runner: "ubuntu-24.04", regitry: "kitsudaiki/miko" }
- { component: "miko", platform: "linux/arm64", runner: "ubuntu-24.04-arm", regitry: "kitsudaiki/miko" }
- { component: "ryokan", platform: "linux/amd64", runner: "ubuntu-24.04", regitry: "kitsudaiki/ryokan" }
- { component: "ryokan", platform: "linux/arm64", runner: "ubuntu-24.04-arm", regitry: "kitsudaiki/ryokan" }
- { component: "sakura", platform: "linux/amd64", runner: "ubuntu-24.04", regitry: "kitsudaiki/sakura" }
- { component: "sakura", platform: "linux/arm64", runner: "ubuntu-24.04-arm", regitry: "kitsudaiki/sakura" }
- { component: "torii", platform: "linux/amd64", runner: "ubuntu-24.04", regitry: "kitsudaiki/torii" }
- { component: "torii", platform: "linux/arm64", runner: "ubuntu-24.04-arm", regitry: "kitsudaiki/torii" }
- { component: "omamori", platform: "linux/amd64", runner: "ubuntu-24.04", regitry: "kitsudaiki/omamori" }
- { component: "omamori", platform: "linux/arm64", runner: "ubuntu-24.04-arm", regitry: "kitsudaiki/omamori" }
- { component: "onsen", platform: "linux/amd64", runner: "ubuntu-24.04", regitry: "kitsudaiki/onsen" }
- { component: "onsen", platform: "linux/arm64", runner: "ubuntu-24.04-arm", regitry: "kitsudaiki/onsen" }
- { component: "dashboard", platform: "linux/amd64", runner: "ubuntu-24.04", regitry: "kitsudaiki/ainari_dashboard" }
- { component: "dashboard", platform: "linux/arm64", runner: "ubuntu-24.04-arm", regitry: "kitsudaiki/ainari_dashboard" }
runs-on: ${{ matrix.builds.runner }}
steps:
-
name: Prepare
run: |
platform=${{ matrix.builds.platform }}
echo "PLATFORM_PAIR_COMPONENT=${platform//\//-}" >> $GITHUB_ENV
-
name: Checkout repository
run: |
# use manually clone, because with the "actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332" action the name of the
# branch can not be read by the git commands, which is necessary for the build-script
git clone https://github.com/kitsudaiki/${GITHUB_REPOSITORY#*/}.git
cd ${GITHUB_REPOSITORY#*/}
git checkout ${GITHUB_REF#refs/heads/}
git submodule init
git submodule update --recursive
-
name: Docker meta
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81
with:
images: ${{ matrix.builds.regitry }}
-
name: Set up QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db
-
name: Login to Docker Hub
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Check location
run: |
pwd
cd ainari
ls -l
-
name: Build and push by digest
id: build
uses: docker/build-push-action@5176d81f87c23d6fc96624dfdbcd9f3830bbe445
with:
context: ./ainari
file: ./ainari/dockerfiles/Dockerfile_${{ matrix.builds.component }}
platforms: ${{ matrix.builds.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ matrix.builds.regitry }},push-by-digest=true,name-canonical=true,push=true
-
name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
-
name: Upload digest
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b
with:
name: digests-${{ matrix.builds.component }}-${{ env.PLATFORM_PAIR_COMPONENT }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
docker_merge:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' || github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
name: "Merge and push Docker-images"
runs-on: ubuntu-24.04
needs: [ docker_build ]
strategy:
fail-fast: false
matrix:
builds:
- { component: "hanami", regitry: "kitsudaiki/hanami" }
- { component: "miko", regitry: "kitsudaiki/miko" }
- { component: "ryokan", regitry: "kitsudaiki/ryokan" }
- { component: "sakura", regitry: "kitsudaiki/sakura" }
- { component: "torii", regitry: "kitsudaiki/torii" }
- { component: "omamori", regitry: "kitsudaiki/omamori" }
- { component: "onsen", regitry: "kitsudaiki/onsen" }
- { component: "dashboard", regitry: "kitsudaiki/ainari_dashboard" }
steps:
-
name: Set branch name as environment variable
run: |
if [[ ${GITHUB_REF#} == refs/tags/* ]]; then \
echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/tags/} | sed 's/^v//')" | sed 's#/#\-#' >> $GITHUB_ENV; \
else \
echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" | sed 's#/#\-#' >> $GITHUB_ENV; \
fi
-
name: Check docker-tag
run: echo "Docker-tag=$BRANCH_NAME"
-
name: Download digests
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
path: /tmp/digests
pattern: digests-${{ matrix.builds.component }}-*
merge-multiple: true
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db
-
name: Docker meta
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81
with:
images: ${{ matrix.builds.regitry }}
-
name: Login to Docker Hub
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create -t ${{ matrix.builds.regitry }}:${{ env.BRANCH_NAME }} \
$(printf '${{ matrix.builds.regitry }}@sha256:%s ' *)
-
name: Inspect image
run: |
docker buildx imagetools inspect ${{ matrix.builds.regitry }}:${{ env.BRANCH_NAME }}
kubernetes_test:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' || github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
needs: [ docker_merge ]
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
kubernetes_version:
- { tag: "kubernetes-1_30", name: "Kubernetes 1.30", version: "1.30.12"}
- { tag: "kubernetes-1_31", name: "Kubernetes 1.31", version: "1.31.8"}
- { tag: "kubernetes-1_32", name: "Kubernetes 1.32", version: "1.32.4"}
- { tag: "kubernetes-1_33", name: "Kubernetes 1.33", version: "1.33.0"}
name: "${{ matrix.kubernetes_version.name }}"
outputs:
kubernetes-1_30: ${{ steps.status.outputs.kubernetes-1_30 }}
kubernetes-1_31: ${{ steps.status.outputs.kubernetes-1_31 }}
kubernetes-1_32: ${{ steps.status.outputs.kubernetes-1_32 }}
kubernetes-1_33: ${{ steps.status.outputs.kubernetes-1_33 }}
env:
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
steps:
-
name: Set branch name as environment variable
run: |
if [[ ${GITHUB_REF#} == refs/tags/* ]]; then \
echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/tags/} | sed 's/^v//')" | sed 's#/#\-#' >> $GITHUB_ENV; \
else \
echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" | sed 's#/#\-#' >> $GITHUB_ENV; \
fi
-
name: Set python-version as environment variable
run: |
if [[ ${GITHUB_REF#} == refs/tags/* ]]; then \
echo "PYTHON_PACKAGE_VERSION=$(echo ${GITHUB_REF#refs/tags/} | sed 's/^v//')" | sed 's#/#\-#' >> $GITHUB_ENV; \
else \
echo "PYTHON_PACKAGE_VERSION=0.0.0" | sed 's#/#\-#' >> $GITHUB_ENV; \
fi
-
name: Set helm-version as environment variable
run: |
if [[ ${GITHUB_REF#} == refs/tags/* ]]; then \
echo "HELM_VERSION=$(echo ${GITHUB_REF#refs/tags/} | sed 's/^v//')" | sed 's#/#\-#' >> $GITHUB_ENV; \
else \
echo "HELM_VERSION=0.0.0" | sed 's#/#\-#' >> $GITHUB_ENV; \
fi
-
name: Get artifact
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
name: ainari_python_build_result
path: /tmp/ainari_python_build_result
-
name: Install dependencies for SDK
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler wget gzip python3 python3-pip
cd /tmp/ainari_python_build_result
ls -l
pip3 install -U ainari_sdk-$PYTHON_PACKAGE_VERSION-py2.py3-none-any.whl
-
name: Check docker-tag
run: echo "Docker-tag=$BRANCH_NAME"
-
name: Checkout repository
run: |
# use manually clone, because with the "actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332" action the name of the
# branch can not be read by the git commands, which is necessary for the build-script
git clone https://github.com/kitsudaiki/${GITHUB_REPOSITORY#*/}.git
cd ${GITHUB_REPOSITORY#*/}
git checkout ${GITHUB_REF#refs/heads/}
git submodule init
git submodule update --recursive
-
name: Get helm-chart artifact
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
name: ainari_helm_build_result
path: /tmp/ainari_helm_build_result
-
name: Install dependencies for SDK
run: |
sudo snap install helm --classic
sudo snap install kubectl --classic
-
name: Install k3s without traefik
run: |
sudo curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--disable traefik" INSTALL_K3S_VERSION=v${{ matrix.kubernetes_version.version }}+k3s1 sh -
-
name: Sleep for 60 seconds
uses: jakejarvis/wait-action@919fc193e07906705e5b7a50f90ea9e74d20b2b0
with:
time: '60s'
-
name: Install nginx ingress controller
run: |
sudo chmod -R +r /etc/rancher/k3s
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.8.1/deploy/static/provider/baremetal/deploy.yaml
sleep 15
cat <<EOF > ingress-nginx-controller-loadbalancer.yaml
---
apiVersion: v1
kind: Service
metadata:
name: ingress-nginx-controller-loadbalancer
namespace: ingress-nginx
spec:
selector:
app.kubernetes.io/component: controller
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/name: ingress-nginx
ports:
- name: http
port: 80
protocol: TCP
targetPort: 80
- name: https
port: 443
protocol: TCP
targetPort: 443
type: LoadBalancer
EOF
cat ingress-nginx-controller-loadbalancer.yaml
kubectl apply -f ingress-nginx-controller-loadbalancer.yaml
sleep 15
-
name: Install cert-manager in kubernetes_test
run: |
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
helm repo add jetstack https://charts.jetstack.io
helm repo update
kubectl create namespace cert-manager
helm install cert-manager jetstack/cert-manager --namespace cert-manager --set installCRDs=true
-
name: Create wireguard-configs
run: |
sudo apt-get install -y wireguard-tools
pip3 install jinja2
cd ${GITHUB_REPOSITORY#*/}/deploy/k8s
python3 wg_gen.py --namespace default
-
name: Label nodes
run: |
kubectl label nodes --all hanami-node=true
kubectl label nodes --all miko-node=true
kubectl label nodes --all ryokan-node=true
kubectl label nodes --all sakura-node=true