/
config.yml
1421 lines (1220 loc) · 56.8 KB
/
config.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
##############
# Yaml Anchors
##############
# Don't run cli jobs on main branches
filters_ignore_main: &filters_ignore_main
filters:
branches:
ignore:
- main
# cli cluster param used to run test suites against docker/kubernetes tests
param_cli_cluster_backend: ¶m_cli_cluster_backend
cli-cluster-backend:
description: "Kurtosis cluster backend for the cli to use. Must be one of 'docker', 'kubernetes'"
type: enum
enum: ["docker", "kubernetes"]
# Install go version 1.19 to run our integration tests on the minimal version we support
steps_install_go: &steps_install_go
- run: |
wget https://go.dev/dl/go<< pipeline.parameters.go-version >>.linux-amd64.tar.gz
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf go<< pipeline.parameters.go-version >>.linux-amd64.tar.gz
# Steps to prepare a job for Kubernetes testing (with K3S K8S distribution)
steps_prepare_testing_k8s_k3s: &steps_prepare_testing_k8s_k3s
steps:
- run:
name: Install K3D and create the K3D/K3S cluster on Docker
command: |
curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash
k3d cluster create --servers 1 --no-lb --wait --verbose
- run:
name: Load Kurtosis images into the K3S cluster
# First load the image into Docker and then import the images into K3S by taking the image from Docker
command: |
kurtosis_version="$(./scripts/get-docker-tag.sh)"
docker load -i "<< pipeline.parameters.workspace-with-cli-binary-and-images-mountpoint >>/<< pipeline.parameters.core-server-image-filename >>"
docker load -i "<< pipeline.parameters.workspace-with-cli-binary-and-images-mountpoint >>/<< pipeline.parameters.engine-server-image-filename >>"
docker load -i "<< pipeline.parameters.workspace-with-cli-binary-and-images-mountpoint >>/<< pipeline.parameters.file-artifacts-expander-image-filename >>"
k3d image import "kurtosistech/core:$kurtosis_version" "kurtosistech/engine:$kurtosis_version" "kurtosistech/files-artifacts-expander:$kurtosis_version"
# Edit the Kurtosis config file in order to have K3S cluster configuration
- run:
name: Add K3S cluster config in Kurtosis config file
command: |
KURTOSIS_CONFIG_FILEPATH=$($KURTOSIS_BINPATH config path)
cat \<< EOF > "$KURTOSIS_CONFIG_FILEPATH"
config-version: 2
should-send-metrics: true
kurtosis-clusters:
docker:
type: docker
k3d-k3s-default:
type: kubernetes
config:
kubernetes-cluster-name: k3d-k3s-default
storage-class: standard
enclave-size-in-megabytes: 2048
EOF
# Set the K3S cluster with some previous steps to force this cluster type in the cluster-setting file. This save us to start the engine with the cluster set command
# because we are going to start it on the next step
- run:
name: Set K3S Kurtosis cluster
command: |
KURTOSIS_CLUSTER_SETTING_FILEPATH="<< pipeline.parameters.kurtosis-cluster-setting-abs-filepath >>"
echo -n "k3d-k3s-default" > "$KURTOSIS_CLUSTER_SETTING_FILEPATH"
echo "Kurtosis cluster-setting file content: $(cat $KURTOSIS_CLUSTER_SETTING_FILEPATH)"
${KURTOSIS_BINPATH} cluster set k3d-k3s-default --cli-log-level trace
- run:
name: Start Kurtosis engine in K8s backend
command: |
${KURTOSIS_BINPATH} engine start --enclave-pool-size 2
- run:
name: Run Kurtosis gateway
command: "${KURTOSIS_BINPATH} gateway"
background: true
# Steps to prepare a job for Docker testing
steps_prepare_testing_docker: &steps_prepare_testing_docker
steps:
- run: |
docker load -i "<< pipeline.parameters.workspace-with-cli-binary-and-images-mountpoint >>/<< pipeline.parameters.core-server-image-filename >>"
docker load -i "<< pipeline.parameters.workspace-with-cli-binary-and-images-mountpoint >>/<< pipeline.parameters.engine-server-image-filename >>"
docker load -i "<< pipeline.parameters.workspace-with-cli-binary-and-images-mountpoint >>/<< pipeline.parameters.file-artifacts-expander-image-filename >>"
- run: "${KURTOSIS_BINPATH} engine start --cli-log-level trace"
# Run steps to dump kurtosis enclaves from docker
run_dump_kurtosis_enclaves: &run_dump_kurtosis_enclaves
run: |
cd /tmp
output_dirname="enclave-dumps"
mkdir "${output_dirname}"
# We exclude "WARN" and "INFO" messages because otherwise they'll pollute the STDOUT grab
# We can remove this tedious exclusion when https://github.com/kurtosis-tech/kurtosis/issues/399 is implemented
for enclave_uuid in $("${KURTOSIS_BINPATH}" enclave ls | grep -v "WARN" | grep -v "INFO" | grep -v "UUID" | awk '{print $1}'); do
"${KURTOSIS_BINPATH}" enclave dump "${enclave_uuid}" "${output_dirname}/${enclave_uuid}"
done
# Verify that we actually dumped enclaves by ensuring the number of dumped enclaves is greater than 0 (if not, it's a bug in this dumping logic)
num_dumped_enclaves="$(find "${output_dirname}" -mindepth 1 -maxdepth 1 -type d | wc -l)"
[ "${num_dumped_enclaves}" -gt 0 ]
zip -r "${output_dirname}.zip" "${output_dirname}"
# If the only changes are to the docs subdirectory or to Markdown files, we can optimize and skip any code-building/code-testing
# `git diff --exit-code` returns 0 exit code if no changes, and 1 if changes
abort_job_if_only_docs_changes: &abort_job_if_only_docs_changes
run: |
if git --no-pager diff --exit-code origin/main...HEAD -- . ':!docs' ':!*.md'; then
circleci-agent step halt
fi
##############
# CircleCI
##############
version: 2.1
orbs:
npm-publisher: uraway/npm-publisher@0.2.0
kurtosis-docs-checker: kurtosis-tech/docs-checker@0.2.6
slack: circleci/slack@4.10.1
executors:
ubuntu_vm:
machine:
# This custom CircleCi Ubuntu image has a pre-installed Docker, so we are not using the CircleCI remote Docker when we
# initiate this machine. More here: https://discuss.circleci.com/t/linux-machine-executor-images-2022-january-q1-update/42831
image: ubuntu-2004:2023.10.1
parameters:
go-version:
type: string
default: "1.19.10"
container-engine-lib-build-cache-key-prefix:
type: string
default: "go-mod-v1" # Can bump this version to bust the cache
# To upgrade the Docker Engine version, see which versions are supported at: https://circleci.com/docs/2.0/building-docker-images/#docker-version
docker-engine-version:
type: string
default: 20.10.7
api-go-version:
type: string
default: "1.19.10"
# Separate (and newer) than the API version because we want lots of people to be able to use the Kurtosis API and the API doesn't need to be
# the same version as the server
rust-version:
type: string
default: 1.68.2
api-node-version:
type: string
default: 16.13.0
core-server-build-cache-key-prefix:
type: string
default: "core-server-go-mod-v1" # Can bump this version to bust the cache
engine-server-build-cache-key-prefix:
type: string
default: "engine-server-go-mod-v1" # Can bump this version to bust the cache
workspace-with-cli-binary-and-images-mountpoint:
type: string
default: "/tmp/workspace"
# The dirpath where CLI dist subdirectories are found, relative to the workspace root
cli-dist-home-relative-dirpath:
type: string
default: "cli/cli/dist"
# The filepath where the Linux AMD 64 CLI binary can be found, relative to the cli-dist-home-relative-dirpath
cli-linux-amd-64-binary-relative-filepath:
type: string
default: "cli_linux_amd64_v1/kurtosis"
# The key that the CLI build cache will get
# We can bump the version here if we ever need to bust the cache
cli-build-cache-key-prefix:
type: string
default: "cli-go-mod-v1"
generate-kurtosis-version-script-path:
type: string
default: "scripts/generate-kurtosis-version.sh"
core-server-image-filename:
type: string
default: "core-server-image.tgz"
file-artifacts-expander-image-filename:
type: string
default: "file-artifacts-expander-image.tgz"
engine-server-image-filename:
type: string
default: "engine-server-image.tgz"
startosis-test-script-file-relative-path:
type: string
default: "internal_testsuites/starlark/ci_tests/simple_no_arg_test/startosis_simple_script.star"
starlark-test-args-file-test-main-star-relative-path:
type: string
default: "internal_testsuites/starlark/ci_tests/simple_arg_test/main.star"
starlark-test-args-file-test-args-json-relative-path:
type: string
default: "internal_testsuites/starlark/ci_tests/simple_arg_test/args.json"
starlark-test-args-file-url:
type: string
default: "https://raw.githubusercontent.com/kurtosis-tech/sample-startosis-load/main/args.json"
rendertemplate-cli-test-template-relative-path:
type: string
default: "internal_testsuites/resources/render_template_cli_test/template.txt"
dockerimport-cli-dotenv-relative-path:
type: string
default: "internal_testsuites/resources/docker_import_cli_test/.env"
dockerimport-cli-dockerfile-relative-path:
type: string
default: "internal_testsuites/resources/docker_import_cli_test/docker-compose.yml"
rendertemplate-cli-test-data-json-relative-path:
type: string
default: "internal_testsuites/resources/render_template_cli_test/data.json"
kurtosis-cluster-setting-abs-filepath:
type: string
default: "/home/circleci/.local/share/kurtosis/cluster-setting"
# NOTE: Because CircleCI jobs run on separate machines from each other, we duplicate steps (like checkout) between jobs. This is because doing the "correct" DRY
# refactoring of, "one job for checkout, one job for build Docker image, etc." would require a) persisting files between jobs and b) persisting Docker images between
# jobs. Both are annoying (saving/loading workspaces require re-downloading the workspace over the network, and there doesn't seem to be a good way to do Docker
# images), so we run everything inside a single job.
# See also: https://discuss.circleci.com/t/can-docker-images-be-preserved-between-jobs-in-a-workflow-without-a-manual-load-save/23388/12
jobs:
# -- build jobs ------------------------------------------
build_container_engine_lib:
docker:
- image: "cimg/go:<< pipeline.parameters.go-version >>"
# Done on 2022-05-15, when the job was 1m30s and CircleCI insights showed that we were maxing out the 'medium' class CPUs
resource_class: large
steps:
- checkout
- <<: *abort_job_if_only_docs_changes
# Cache our dependencies
- restore_cache:
keys:
- << pipeline.parameters.container-engine-lib-build-cache-key-prefix >>-{{ checksum "container-engine-lib/go.sum" }}
- run: |
container-engine-lib/scripts/build.sh
- save_cache:
key: << pipeline.parameters.container-engine-lib-build-cache-key-prefix >>-{{ checksum "container-engine-lib/go.sum" }}
paths:
- "/home/circleci/go/pkg/mod" # Go module cache on the cimg/go image, as reported by "go env GOMODCACHE"
- "/home/circleci/.cache/go-build" # Go build cache on the cimg/go image, as reported by "go env GOCACHE"
build_contexts_config_store:
docker:
- image: "cimg/go:<< pipeline.parameters.go-version >>"
steps:
- checkout
- <<: *abort_job_if_only_docs_changes
- run: contexts-config-store/scripts/build.sh
build_grpc_file_transfer:
docker:
- image: "cimg/go:<< pipeline.parameters.go-version>>"
steps:
- checkout
- <<: *abort_job_if_only_docs_changes
- run: grpc-file-transfer/scripts/build.sh
build_metrics_library:
docker:
- image: "cimg/go:<< pipeline.parameters.go-version>>"
steps:
- checkout
- <<: *abort_job_if_only_docs_changes
- run: metrics-library/scripts/build.sh
build_name_generator:
docker:
- image: "cimg/go:<< pipeline.parameters.go-version>>"
steps:
- checkout
- <<: *abort_job_if_only_docs_changes
- run: name_generator/scripts/build.sh
build_kurtosis_api_golang:
docker:
- image: "cimg/go:<< pipeline.parameters.api-go-version>>"
steps:
- checkout
- <<: *abort_job_if_only_docs_changes
# !!!!!!!!!! NOTE: We should NOT use our private Go repos here, because this API code will get published publicly !!!!!!!!
- run: api/golang/scripts/build.sh
build_kurtosis_api_typescript:
docker:
- image: "cimg/node:<< pipeline.parameters.api-node-version>>"
steps:
- checkout
- <<: *abort_job_if_only_docs_changes
- run: api/typescript/scripts/build.sh
build_files_artifacts_expander:
docker:
- image: "cimg/go:<< pipeline.parameters.go-version >>"
steps:
- checkout
- <<: *abort_job_if_only_docs_changes
# Generate Kurtosis Version
- run: "<<pipeline.parameters.generate-kurtosis-version-script-path>>"
- setup_remote_docker:
version: "<< pipeline.parameters.docker-engine-version>>"
- run: |
core/files_artifacts_expander/scripts/build.sh
source core/files_artifacts_expander/scripts/_constants.env
version_to_publish="$(./scripts/get-docker-tag.sh)"
image_name_with_version="${IMAGE_ORG_AND_REPO}:${version_to_publish}"
echo "Version that will be persisted to workspace: ${version_to_publish}"
docker save -o << pipeline.parameters.file-artifacts-expander-image-filename >> "${image_name_with_version}"
- persist_to_workspace:
root: .
paths:
- "<< pipeline.parameters.file-artifacts-expander-image-filename >>"
- "<< pipeline.parameters.starlark-test-args-file-test-main-star-relative-path >>"
- "<< pipeline.parameters.starlark-test-args-file-test-args-json-relative-path >>"
- "<< pipeline.parameters.starlark-test-args-file-url >>"
build_core_launcher:
docker:
- image: "cimg/go:<< pipeline.parameters.go-version >>"
steps:
- checkout
- <<: *abort_job_if_only_docs_changes
# Generate Kurtosis Version
- run: "<<pipeline.parameters.generate-kurtosis-version-script-path>>"
- run: |
core/launcher/scripts/build.sh
build_api_container_server:
docker:
- image: "cimg/go:<< pipeline.parameters.go-version >>"
steps:
- checkout
- <<: *abort_job_if_only_docs_changes
# Install proto compiler. To compile startosis proto files on the fly, the APIC needs `protoc`
- run: |
sudo apt update
sudo apt install protobuf-compiler
# Generate Kurtosis Version
- run: "<<pipeline.parameters.generate-kurtosis-version-script-path>>"
- setup_remote_docker:
version: "<< pipeline.parameters.docker-engine-version>>"
# Cache our dependencies
- restore_cache:
keys:
- << pipeline.parameters.core-server-build-cache-key-prefix>>-{{ checksum "core/server/go.sum" }}
- run: |
core/server/scripts/build.sh
source core/server/scripts/_constants.env
version_to_publish="$(./scripts/get-docker-tag.sh)"
image_name_with_version="${IMAGE_ORG_AND_REPO}:${version_to_publish}"
echo "Version that will be persisted to workspace: ${version_to_publish}"
docker save -o << pipeline.parameters.core-server-image-filename >> "${image_name_with_version}"
- save_cache:
key: << pipeline.parameters.core-server-build-cache-key-prefix>>-{{ checksum "core/server/go.sum" }}
paths:
- "/home/circleci/go/pkg/mod" # Go module cache on the cimg/go image, as reported by "go env GOMODCACHE"
- "/home/circleci/.cache/go-build" # Go build cache on the cimg/go image, as reported by "go env GOCACHE"
- persist_to_workspace:
root: .
paths:
- "<< pipeline.parameters.core-server-image-filename >>"
build_engine_launcher:
docker:
- image: "cimg/go:<< pipeline.parameters.go-version >>"
steps:
- checkout
- <<: *abort_job_if_only_docs_changes
# Generate Kurtosis Version
- run: "<<pipeline.parameters.generate-kurtosis-version-script-path>>"
- run: |
engine/launcher/scripts/build.sh
build_engine_server:
docker:
- image: "cimg/go:<< pipeline.parameters.go-version >>"
steps:
- checkout
- <<: *abort_job_if_only_docs_changes
# Generate Kurtosis Version
- run: "<<pipeline.parameters.generate-kurtosis-version-script-path>>"
- setup_remote_docker:
version: "<< pipeline.parameters.docker-engine-version>>"
# Cache our dependencies
- restore_cache:
keys:
- << pipeline.parameters.engine-server-build-cache-key-prefix>>-{{ checksum "engine/server/go.sum" }}
- run: |
engine/server/scripts/build.sh
source engine/server/scripts/_constants.env
version_to_publish="$(./scripts/get-docker-tag.sh)"
image_name_with_version="${IMAGE_ORG_AND_REPO}:${version_to_publish}"
echo "Version that will be persisted to workspace: ${version_to_publish}"
docker save -o << pipeline.parameters.engine-server-image-filename >> "${image_name_with_version}"
- save_cache:
key: << pipeline.parameters.engine-server-build-cache-key-prefix>>-{{ checksum "engine/server/go.sum" }}
paths:
- "/home/circleci/go/pkg/mod" # Go module cache on the cimg/go image, as reported by "go env GOMODCACHE"
- "/home/circleci/.cache/go-build" # Go build cache on the cimg/go image, as reported by "go env GOCACHE"
- persist_to_workspace:
root: .
paths:
- "<< pipeline.parameters.engine-server-image-filename >>"
build_cli:
docker:
- image: "docker/tilt-releaser@sha256:31e51c6441faa5021a20ebe84cf974145d2975f792dd880a5d1c2fa578818458"
resource_class: large
steps:
- checkout
- <<: *abort_job_if_only_docs_changes
#- run: sudo apt-get update -y && sudo apt-get install -y musl-dev && sudo apt-get install -y gcc-aarch64-linux-gnu && sudo apt-get install -y g++-aarch64-linux-gnu
# Generate Kurtosis Version
- run: "<<pipeline.parameters.generate-kurtosis-version-script-path>>"
# Install goreleaser
# we need to update the apt key, otherwise imports fails due to unrecognized key
- run: |
echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | tee /etc/apt/sources.list.d/goreleaser.list
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
apt update
apt install -y goreleaser
# Cache our dependencies
- restore_cache:
keys:
- << pipeline.parameters.cli-build-cache-key-prefix >>-{{ checksum "cli/cli/go.sum" }}
- run: |
cli/cli/scripts/build.sh true
- save_cache:
key: << pipeline.parameters.cli-build-cache-key-prefix >>-{{ checksum "cli/cli/go.sum" }}
paths:
- "/go/pkg/mod" # Go module cache for the Goreleaser image, as reported by "go env GOMODCACHE"
- "/root/.cache/go-build" # Go build cache for the Goreleaser image, as reported by "go env GOCACHE"
- persist_to_workspace:
root: .
paths:
- "./<< pipeline.parameters.cli-dist-home-relative-dirpath >>"
- "./<< pipeline.parameters.startosis-test-script-file-relative-path >>"
build_golang_testsuite:
executor: ubuntu_vm
parameters:
<<: *param_cli_cluster_backend
steps:
- checkout
- <<: *abort_job_if_only_docs_changes
- attach_workspace:
at: "<< pipeline.parameters.workspace-with-cli-binary-and-images-mountpoint >>"
- <<: *steps_install_go
# We call Kurtosis a bunch later, so add it to the PATH so we can call it easily
- run: |
echo 'export KURTOSIS_BINPATH="<< pipeline.parameters.workspace-with-cli-binary-and-images-mountpoint >>/<< pipeline.parameters.cli-dist-home-relative-dirpath >>/<< pipeline.parameters.cli-linux-amd-64-binary-relative-filepath >>"' >> "${BASH_ENV}"
#Run config init to avoid metrics consent prompt when execute engine start command,
#We do not send metrics from CI to not dirty the metrics data
- run: "${KURTOSIS_BINPATH} analytics disable"
- when:
condition:
and:
- equal: [ "kubernetes", << parameters.cli-cluster-backend >> ]
<<: *steps_prepare_testing_k8s_k3s
- when:
condition:
equal: [ "docker", << parameters.cli-cluster-backend >> ]
<<: *steps_prepare_testing_docker
# Run the testsuite for kubernetes and docker, but don't fail the job immediately so that we can upload the enclave dump
- when:
condition:
equal: [ "kubernetes", << parameters.cli-cluster-backend >> ]
steps:
- run: |
if ! ./internal_testsuites/golang/scripts/test.sh kubernetes; then
touch /tmp/testsuite-failed
fi
- when:
condition:
equal: [ "docker", << parameters.cli-cluster-backend >> ]
steps:
- run: |
if ! ./internal_testsuites/golang/scripts/test.sh; then
touch /tmp/testsuite-failed
fi
# TODO TODO TODO DELETE THIS HACK!!!!!
# First reason (only for K8s):
# As of 2022-11-18, 'enclave dump' in Kubernetes in CircleCI (but not locally) takes 30s to run per enclave, and "suceeds"
# but without dumping anything! To avoid our CI runs getting an extra 15 minutes added on, we're only dumping enclaves in Docker
# Second reason:
# As of 2023-07-26, stop enclave calls were replaced by destroy enclave calls because doing so improve the velocity of the entire K8s test suite by 6min
# We can't run enclave dumps if the the enclaves are not running at the moment, but we could enable it once the centralized logs feature is added on Kurtosis
# because we could use enclave-dumps again (it will be calling the centralize logs component instead of getting the logs form the containers)
# TODO UNCOMMENT THIS WHEN WE FIX THE BUG ABOVE!!!
# Dump enclave data so we can debug any issues that arise
# - <<: *run_dump_kurtosis_enclaves
# TODO UNCOMMENT THIS WHEN WE FIX THE BUG ABOVE!!!
#- store_artifacts:
# path: /tmp/enclave-dumps.zip
# destination: enclave-dumps.zip
# Finally, fail the job if the testsuite failed
- run: "! [ -f /tmp/testsuite-failed ]"
build_typescript_testsuite:
executor: ubuntu_vm
parameters:
<<: *param_cli_cluster_backend
steps:
- checkout
- <<: *abort_job_if_only_docs_changes
- attach_workspace:
at: "<< pipeline.parameters.workspace-with-cli-binary-and-images-mountpoint >>"
# We call Kurtosis a bunch later, so add it to the PATH so we can call it easily
- run: |
echo 'export KURTOSIS_BINPATH="<< pipeline.parameters.workspace-with-cli-binary-and-images-mountpoint >>/<< pipeline.parameters.cli-dist-home-relative-dirpath >>/<< pipeline.parameters.cli-linux-amd-64-binary-relative-filepath >>"' >> "${BASH_ENV}"
#Run install Yarn because TypeScript tests are managed with Yarn package manager
- run: npm install -g yarn
#Run config init to avoid metrics consent prompt when execute engine start command,
#We do not send metrics from CI to not dirty the metrics data
- run: "${KURTOSIS_BINPATH} analytics disable"
- when:
condition:
and:
- equal: [ "kubernetes", << parameters.cli-cluster-backend >> ]
<<: *steps_prepare_testing_k8s_k3s
- when:
condition:
equal: [ "docker", << parameters.cli-cluster-backend >> ]
<<: *steps_prepare_testing_docker
# Run the testsuite for either docker or kubernetes, but don't fail the job immediately so that we can upload the enclave dump
- when:
condition:
equal: [ "kubernetes", << parameters.cli-cluster-backend >> ]
steps:
- run: |
if ! ./internal_testsuites/typescript/scripts/test.sh kubernetes; then
touch /tmp/testsuite-failed
fi
- when:
condition:
equal: [ "docker", << parameters.cli-cluster-backend >> ]
steps:
- run: |
if ! ./internal_testsuites/typescript/scripts/test.sh; then
touch /tmp/testsuite-failed
fi
# TODO TODO TODO DELETE THIS HACK!!!!!
# As of 2022-11-18, 'enclave dump' in Kubernetes in CircleCI (but not locally) takes 30s to run per enclave, and "suceeds"
# but without dumping anything! To avoid our CI runs getting an extra 15 minutes added on, we're only dumping enclaves in Docker
- when:
condition:
equal: [ "docker", << parameters.cli-cluster-backend >> ]
steps:
<<: *run_dump_kurtosis_enclaves
# TODO UNCOMMENT THIS WHEN WE FIX THE BUG ABOVE!!!
# Dump enclave data so we can debug any issues that arise
# - <<: *run_dump_kurtosis_enclaves
- store_artifacts:
path: /tmp/enclave-dumps.zip
destination: enclave-dumps.zip
- store_artifacts:
path: /tmp/enclave-dumps.zip
destination: enclave-dumps.zip
# Finally, fail the job if the testsuite failed
- run: "! [ -f /tmp/testsuite-failed ]"
test_old_enclave_continuity:
executor: ubuntu_vm
steps:
- checkout
- <<: *abort_job_if_only_docs_changes
# Set up Kurtosis
- attach_workspace:
at: "<< pipeline.parameters.workspace-with-cli-binary-and-images-mountpoint >>"
- <<: *steps_install_go
- run: |
echo "deb [trusted=yes] https://apt.fury.io/kurtosis-tech/ /" | sudo tee /etc/apt/sources.list.d/kurtosis.list
sudo apt update
sudo apt install kurtosis-cli
# We don't send metrics to avoid polluting our logs
- run: kurtosis analytics disable
# Start up an enclave with some services inside
- run: kurtosis enclave add --name running-old-enclave
- run: kurtosis enclave add --name stopped-old-enclave
- run: kurtosis service add running-old-enclave test-datastore-one kurtosistech/example-datastore-server
- run: kurtosis service add stopped-old-enclave test-datastore-two kurtosistech/example-datastore-server
- run: kurtosis enclave stop stopped-old-enclave
- run: kurtosis engine stop
- run: |
echo 'export KURTOSIS_BINPATH="<< pipeline.parameters.workspace-with-cli-binary-and-images-mountpoint >>/<< pipeline.parameters.cli-dist-home-relative-dirpath >>/<< pipeline.parameters.cli-linux-amd-64-binary-relative-filepath >>"' >> "${BASH_ENV}"
docker load -i "<< pipeline.parameters.workspace-with-cli-binary-and-images-mountpoint >>/<< pipeline.parameters.core-server-image-filename >>"
docker load -i "<< pipeline.parameters.workspace-with-cli-binary-and-images-mountpoint >>/<< pipeline.parameters.engine-server-image-filename >>"
docker load -i "<< pipeline.parameters.workspace-with-cli-binary-and-images-mountpoint >>/<< pipeline.parameters.file-artifacts-expander-image-filename >>"
# Make sure we can still interact with the old enclaves
- run: "${KURTOSIS_BINPATH} enclave ls"
- run: "${KURTOSIS_BINPATH} enclave inspect running-old-enclave"
- run: "${KURTOSIS_BINPATH} service add running-old-enclave test-service httpd --ports http=80"
- run: "${KURTOSIS_BINPATH} enclave stop running-old-enclave"
- run: "${KURTOSIS_BINPATH} enclave inspect stopped-old-enclave"
# Ensure enclaves still work
- run: "${KURTOSIS_BINPATH} clean -a"
- run: "${KURTOSIS_BINPATH} engine stop"
# Ensure everything got cleaned up successfully
- run:
name: "Verify only the engine container remains after the clean"
command: |
if ! [ "$(docker container ls -a | tail -n+2 | wc -l)" -eq 0 ]; then
docker container ls -a
false
fi
- run:
name: "Verify Kurtosis cleaned up all its volumes (except for the log storage volume, so we can persist service logs)"
command: |
if ! [ $(docker volume ls | grep -v kurtosis-logs-collector-vol | grep -v kurtosis-logs-db-vol | tail -n+2 | wc -l ) -eq 1 ]; then
docker volume ls
false
fi
- run:
name: "Verify Kurtosis cleaned up all its networks"
command: |
builtin_network_ids=(
"$(docker network ls --quiet --filter "name=host")"
"$(docker network ls --quiet --filter "name=bridge")"
"$(docker network ls --quiet --filter "name=none")"
)
if ! [ $(docker network ls | grep -v -f <(printf "%s\n" "${builtin_network_ids[@]}") | tail -n+2 | wc -l) -eq 0 ]; then
docker network ls
false
fi
test_basic_cli_functionality:
executor: ubuntu_vm
parameters:
<<: *param_cli_cluster_backend
steps:
- checkout
- <<: *abort_job_if_only_docs_changes
# Set up Kurtosis
- attach_workspace:
at: "<< pipeline.parameters.workspace-with-cli-binary-and-images-mountpoint >>"
- <<: *steps_install_go
- run: |
echo "deb [trusted=yes] https://apt.fury.io/kurtosis-tech/ /" | sudo tee /etc/apt/sources.list.d/kurtosis.list
sudo apt update
sudo apt install kurtosis-cli
# We don't send metrics to avoid polluting our logs
- run: |
echo 'export KURTOSIS_BINPATH="<< pipeline.parameters.workspace-with-cli-binary-and-images-mountpoint >>/<< pipeline.parameters.cli-dist-home-relative-dirpath >>/<< pipeline.parameters.cli-linux-amd-64-binary-relative-filepath >>"' >> "${BASH_ENV}"
- run: "${KURTOSIS_BINPATH} analytics disable"
# When backend is 'kubernetes' install kubernetes and start a Kurtosis gateway
- when:
condition:
and:
- equal: [ "kubernetes", << parameters.cli-cluster-backend >> ]
<<: *steps_prepare_testing_k8s_k3s
- when:
condition:
equal: [ "docker", << parameters.cli-cluster-backend >> ]
<<: *steps_prepare_testing_docker
# Basic service add & rm
- run: |
${KURTOSIS_BINPATH} enclave add --name test-enclave
- run: "${KURTOSIS_BINPATH} service add test-enclave test1 httpd --ports http=80"
- run: "${KURTOSIS_BINPATH} service rm test-enclave test1"
- run: "${KURTOSIS_BINPATH} service add test-enclave test1 httpd --ports http=80"
- run: "${KURTOSIS_BINPATH} service add test-enclave test2 httpd --ports http=80"
# Service stop and start
- run: "${KURTOSIS_BINPATH} service stop test-enclave test1"
- run: "${KURTOSIS_BINPATH} service start test-enclave test1"
# Service inspect
- run: "${KURTOSIS_BINPATH} service inspect test-enclave test1"
# Service Exec
# Emulates GitHub Actions
- run: "${KURTOSIS_BINPATH} service exec test-enclave test1 'echo hello'"
- run: "! ${KURTOSIS_BINPATH} service exec test-enclave test1 'echo hello; exit 1'"
# File commands
- run: "${KURTOSIS_BINPATH} files rendertemplate test-enclave << pipeline.parameters.rendertemplate-cli-test-template-relative-path >> << pipeline.parameters.rendertemplate-cli-test-data-json-relative-path >> ./rendered --name rendered-file"
- run: "${KURTOSIS_BINPATH} files download test-enclave rendered-file ."
- run: "${KURTOSIS_BINPATH} files storeservice test-enclave test1 /usr/local/apache2/conf/httpd.conf --name stored-file"
- run: "${KURTOSIS_BINPATH} files download test-enclave stored-file ."
# Module inside an enclave
- run: "${KURTOSIS_BINPATH} enclave ls"
- run: "${KURTOSIS_BINPATH} enclave inspect test-enclave"
# Execute simple startosis script in new enclave
- run: "${KURTOSIS_BINPATH} run --enclave test-enclave << pipeline.parameters.workspace-with-cli-binary-and-images-mountpoint >>/<< pipeline.parameters.startosis-test-script-file-relative-path >>"
# Execute Simple Starlark Script to test --args-file
- run: "${KURTOSIS_BINPATH} run --enclave args-file-test << pipeline.parameters.workspace-with-cli-binary-and-images-mountpoint >>/<< pipeline.parameters.starlark-test-args-file-test-main-star-relative-path >> --args-file << pipeline.parameters.workspace-with-cli-binary-and-images-mountpoint >>/<< pipeline.parameters.starlark-test-args-file-test-args-json-relative-path >>"
# Execute Simple Starlark Script to test --args-file from URL
- run: "${KURTOSIS_BINPATH} run --enclave args-file-from-url-test << pipeline.parameters.workspace-with-cli-binary-and-images-mountpoint >>/<< pipeline.parameters.starlark-test-args-file-test-main-star-relative-path >> --args-file << pipeline.parameters.starlark-test-args-file-url >>"
# Execute github starlark module
- run: "${KURTOSIS_BINPATH} run --enclave test-datastore github.com/kurtosis-tech/datastore-army-package '{\"num_datastores\": 2}'"
# Execute port print
- run: "${KURTOSIS_BINPATH} port print test-datastore datastore-0 grpc"
# Stop test-datastore enclave
- run: "${KURTOSIS_BINPATH} enclave stop test-datastore"
# Ensure we can still inspect stopped enclaves
- run: "${KURTOSIS_BINPATH} enclave stop test-enclave"
- run: "${KURTOSIS_BINPATH} enclave inspect test-enclave"
# Clean all before compose import to free resources
- run: "${KURTOSIS_BINPATH} clean -a"
# Execute docker compose import
- run: "${KURTOSIS_BINPATH} import --enclave test-import --env << pipeline.parameters.dockerimport-cli-dotenv-relative-path >> << pipeline.parameters.dockerimport-cli-dockerfile-relative-path >>"
# Execute engine functions
- run: "${KURTOSIS_BINPATH} engine stop"
- run: "${KURTOSIS_BINPATH} engine stop"
- run: "${KURTOSIS_BINPATH} engine start"
- run: "${KURTOSIS_BINPATH} engine start"
- run: "${KURTOSIS_BINPATH} engine restart"
- run: "${KURTOSIS_BINPATH} engine restart"
- run: "${KURTOSIS_BINPATH} engine status"
# Test APIC restart
- when:
condition:
equal: [ "docker", << parameters.cli-cluster-backend >> ]
steps:
- run:
name: Test APIC restart
command: |
${KURTOSIS_BINPATH} enclave add -n test-apic-restart
${KURTOSIS_BINPATH} enclave inspect --full-uuids test-apic-restart > /tmp/inspect_output.txt
inspect_output_uuid_line=$(grep "^UUID:" /tmp/inspect_output.txt)
enclave_uuid=$(echo ${inspect_output_uuid_line:17:54})
${KURTOSIS_BINPATH} service add test-apic-restart service-test kurtosistech/example-datastore-server
apic_container_id=$(docker ps --filter "label=com.kurtosistech.container-type=api-container" --filter "label=com.kurtosistech.enclave-id=$(echo $enclave_uuid)" --format "{{.ID}}")
docker container restart $(echo $apic_container_id)
${KURTOSIS_BINPATH} service rm test-apic-restart service-test
# Test APIC idempotent runs restart
- when:
condition:
equal: [ "docker", << parameters.cli-cluster-backend >> ]
steps:
- run:
name: Test APIC idempotent restart
command: |
${KURTOSIS_BINPATH} enclave add -n test-apic-idempotent-restart
${KURTOSIS_BINPATH} run github.com/kurtosis-tech/datastore-army-package --enclave test-apic-idempotent-restart
${KURTOSIS_BINPATH} enclave inspect --full-uuids test-apic-idempotent-restart > /tmp/inspect_output2.txt
inspect_output_uuid_line=$(grep "^UUID:" /tmp/inspect_output2.txt)
enclave_uuid=$(echo ${inspect_output_uuid_line:17:54})
apic_container_id=$(docker ps --filter "label=com.kurtosistech.container-type=api-container" --filter "label=com.kurtosistech.enclave-id=$(echo $enclave_uuid)" --format "{{.ID}}")
docker container restart $(echo $apic_container_id)
${KURTOSIS_BINPATH} run github.com/kurtosis-tech/datastore-army-package --enclave test-apic-idempotent-restart > /tmp/output_idempotent_runs.txt
number_skipped_instructions=$(grep -o -i SKIPPED /tmp/output_idempotent_runs.txt | wc -l )
if [ $number_skipped_instructions -ne 7 ]; then exit 1; fi
# Clean all at the end
- run: "${KURTOSIS_BINPATH} clean -a"
# Ensure Kubernetes resources clean up successfully
- when:
condition:
equal: [ "kubernetes", << parameters.cli-cluster-backend >> ]
steps:
- run:
name: "Install kubectl"
# Install kubectl and move it to the /usr/local/bin in order to make it accesible from the PATH
command: |
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/local/bin
- run:
name: "Verify no kurtosis pods are running after clean and stopping the engine"
command: |
kurtosis_pods=$(kubectl -- get pods --all-namespaces --selector=kurtosistech.com/app-id=kurtosis)
if ! [ $(echo "${kurtosis_pods}" | grep -f <(printf "%s\n" "Running") | wc -l) -eq 0 ]; then
echo "${kurtosis_pods}"
false
fi
# Ensure Docker resources cleaned up successfully
- when:
condition:
equal: [ "docker", << parameters.cli-cluster-backend >> ]
steps:
- run:
name: "Verify only the engine container and logs aggregator remains after the clean"
command: |
if ! [ "$(docker container ls -a | tail -n+2 | wc -l)" -eq 2 ]; then
docker container ls -a
false
fi
- run:
name: "Verify Kurtosis cleaned up all its volumes (except for the log storage volume, so we can persist service logs)"
command: |
if ! [ $(docker volume ls | grep -v kurtosis-logs-collector-vol | grep -v kurtosis-logs-db-vol | tail -n+2 | wc -l) -eq 1 ]; then
docker volume ls
false
fi
- run:
name: "Verify Kurtosis cleaned up all its networks"
command: |
builtin_network_ids=(
"$(docker network ls --quiet --filter "name=host")"
"$(docker network ls --quiet --filter "name=bridge")"
"$(docker network ls --quiet --filter "name=none")"
)
if ! [ $(docker network ls | grep -v -f <(printf "%s\n" "${builtin_network_ids[@]}") | tail -n+2 | wc -l) -eq 0 ]; then
docker network ls
false
fi
test_ci_for_failure:
executor: ubuntu_vm
parameters:
<<: *param_cli_cluster_backend
steps:
- checkout
- <<: *abort_job_if_only_docs_changes
# Set up Kurtosis
- attach_workspace:
at: "<< pipeline.parameters.workspace-with-cli-binary-and-images-mountpoint >>"
- <<: *steps_install_go
# We don't send metrics to avoid polluting our logs
- run: |
echo 'export KURTOSIS_BINPATH="<< pipeline.parameters.workspace-with-cli-binary-and-images-mountpoint >>/<< pipeline.parameters.cli-dist-home-relative-dirpath >>/<< pipeline.parameters.cli-linux-amd-64-binary-relative-filepath >>"' >> "${BASH_ENV}"
- run: "${KURTOSIS_BINPATH} analytics disable"
# When backend is 'kubernetes' install kubernetes and start a Kurtosis gateway
- when:
condition:
and:
- equal: [ "kubernetes", << parameters.cli-cluster-backend >> ]
<<: *steps_prepare_testing_k8s_k3s
- when:
condition:
equal: [ "docker", << parameters.cli-cluster-backend >> ]
<<: *steps_prepare_testing_docker
# adding same enclave fails
- run: "${KURTOSIS_BINPATH} enclave add --name test-enclave"
- run: "! ${KURTOSIS_BINPATH} service add --name test-encalve"
# running a broken package fails
- run: "! ${KURTOSIS_BINPATH} run github.com/kurtosis-tech/datastore-army-package@25ecb4c271f870d6fdf8745169a142519e49aab8"
# -- End build jobs ---------------------------------------
# -- Publish jobs --------------------------------------------
publish_kurtosis_sdk_rust:
docker:
- image: "cimg/rust:<< pipeline.parameters.rust-version>>"
steps:
- slack/notify:
channel: engineering
event: fail
# You can preview this template and know more about templates here: https://github.com/CircleCI-Public/slack-orb/wiki#templates
template: basic_fail_1
- checkout
- run: |
cd api/rust/
cargo publish
publish_kurtosis_api_typescript:
docker:
- image: "cimg/node:<< pipeline.parameters.api-node-version>>"
steps:
- slack/notify:
channel: engineering
event: fail
# You can preview this template and know more about templates here: https://github.com/CircleCI-Public/slack-orb/wiki#templates
template: basic_fail_1
- checkout
- run: api/typescript/scripts/build.sh
- npm-publisher/publish-from-package-version:
package-path: api/typescript
publish-token-variable: NPMJS_AUTH_TOKEN
publish_files_artifacts_expander_image:
docker:
- image: "cimg/go:<< pipeline.parameters.go-version >>"
steps:
- slack/notify:
channel: engineering
event: fail
# You can preview this template and know more about templates here: https://github.com/CircleCI-Public/slack-orb/wiki#templates
template: basic_fail_1
- checkout
- setup_remote_docker:
version: "<< pipeline.parameters.docker-engine-version>>"
- run: echo "${DOCKER_PASSWORD}" | docker login -u ${DOCKER_USERNAME} --password-stdin
- run: |
skip_docker_image_building=true
core/files_artifacts_expander/scripts/build.sh "${skip_docker_image_building}"
- run: |
skip_docker_image_building=true