-
Notifications
You must be signed in to change notification settings - Fork 172
Expand file tree
/
Copy pathMakefile.toml
More file actions
1167 lines (1006 loc) · 40.6 KB
/
Makefile.toml
File metadata and controls
1167 lines (1006 loc) · 40.6 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
# List of top-level tasks intended for use:
#
# - `cargo make dev-flow` or just `cargo make`: runs a full development flow, including fixing format and clippy, building and running tests and generating OpenAPI specs
# - `cargo make wit`: fetches the WIT dependencies based on wit/deps.toml
# - `cargo make check-wit`: deletes then fetches the WIT dependencies based on wit/deps.toml, then checks if it's up-to-date
# - `cargo make build`: builds everything in debug mode
# - `cargo make build-release`: builds everything in release mode. customizable with PLATFORM_OVERRIDE env variable for docker builds
# - `cargo make check`: runs rustfmt and clippy checks without applying any fix
# - `cargo make fix`: runs rustfmt and clippy checks and applies fixes
# - `cargo make unit-tests`: runs unit tests only
# - `cargo make worker-executor-tests`: runs worker executor tests only
# - `cargo make integration-tests`: runs integration tests only
# - `cargo make sharding-tests-debug`: runs sharding integration tests with file logging enabled, also accepts test name filter arguments
# - `cargo make api-tests-http`: runs api integration tests using HTTP API only
# - `cargo make api-tests-grpc`: runs api integration tests using GRPC API only
# - `cargo make test`: runs all unit tests, worker executor tests and integration tests
# - `cargo make check-openapi`: generates openapi spec from the code and checks if it is the same as the one in the openapi directory (for CI)
# - `cargo make generate-openapi`: generates openapi spec from the code and saves it to the openapi directory
# - `cargo make publish`: publishes packages to crates.io
# - `cargo make run`: runs all services locally, requires redis, lnav and nginx
# - `cargo make run-with-login-enabled`: runs all services locally with login enabled, requires redis, lnav and nginx. Also requires oauth2 configuration to be provided.
# - `cargo make check-configs`: generates configs from code deafults and checks if it is up-to-date
# - `cargo make generate-configs`: generates configs from code defaults
# - `cargo make check-unused-deps`: detects unused Cargo dependencies using cargo-udeps (requires nightly)
# - `cargo make elastic-up`: starts elastic, kibana, filebeat (in detached mode) and loads logs into elastic
# - `cargo make elastic-stop`: stops the elastic env
# - `cargo make elastic-down`: stops and removes the elastic env, including all stored data
[config]
default_to_workspace = false # by default, we run cargo commands on top level instead of per member
skip_core_tasks = true # we are not using the predefined cargo-make flows, instead redefine here for more clarity
[env]
JUNIT_OPTS = ""
WORKER_TEST_THREAD_OPTS = ""
AWS_EC2_METADATA_DISABLED = "true"
PROFILE = "dev"
[env.ci]
CARGO_INCREMENTAL = "false"
#CARGO_PROFILE_dev_STRIP = "debuginfo"
#CARGO_PROFILE_test_STRIP = "debuginfo"
JUNIT_OPTS = "--format ctrf --logfile target/ctrf.json"
WORKER_TEST_THREAD_OPTS = ""
PROFILE = "dev-ci"
CI = "true"
# CARGO_LOG="cargo::core::compiler::fingerprint=trace"
[tasks.default]
description = "This is the task that gets executed by 'cargo make' when no task is specified"
run_task = "dev-flow"
[tasks.dev]
description = "Alias to the dev-flow task"
alias = "dev-flow"
[tasks.dev-flow]
description = "Runs a full development flow, including fixing format and clippy, building and running tests"
dependencies = [
"wit",
"fix",
"check",
"build",
# "test"
]
# WIT DEPENDENCIES
[tasks.wit]
description = "Fetches the WIT dependencies based on wit/deps.toml"
run_task = [
{ name = [
"remove-wit-deps",
"wit-golem-wasm",
"wit-golem-common",
"wit-golem-cli",
"wit-test-components",
"wit-sdks",
] },
]
[tasks.wit-golem-wasm]
private = true
script_runner = "@duckscript"
script = """
rm -r golem-wasm/wit/deps
mkdir golem-wasm/wit/deps
cp wit/deps/io golem-wasm/wit/deps
cp wit/deps/clocks golem-wasm/wit/deps
cp wit/deps/golem-1.x golem-wasm/wit/deps
cp wit/deps/golem-core golem-wasm/wit/deps
"""
[tasks.wit-golem-common]
private = true
script_runner = "@duckscript"
script = """
rm -r golem-common/wit/deps
mkdir golem-common/wit/deps
cp wit/deps/io golem-common/wit/deps
cp wit/deps/clocks golem-common/wit/deps
cp wit/deps/golem-1.x golem-common/wit/deps
cp wit/deps/golem-core golem-common/wit/deps
cp wit/deps/golem-agent golem-common/wit/deps
"""
[tasks.wit-sdks]
private = true
script_runner = "@duckscript"
script = """
rm -r sdks/rust/golem-rust/wit/deps
rm -r sdks/ts/wit/deps
mkdir sdks/rust/golem-rust/wit/deps
mkdir sdks/ts/wit/deps
glob_cp wit/deps/**/* sdks/rust/golem-rust/wit/deps
glob_cp sdks/rust/golem-rust/wit/golem-ai/**/* sdks/rust/golem-rust/wit/deps
glob_cp wit/deps/**/* sdks/ts/wit/deps
glob_cp sdks/ts/wit/golem-ai/**/* sdks/ts/wit/deps
"""
[tasks.wit-golem-cli]
private = true
script_runner = "@duckscript"
script = """
rm -r cli/golem-cli/wit/deps
mkdir cli/golem-cli/wit/deps
cp wit/deps/clocks cli/golem-cli/wit/deps
cp wit/deps/io cli/golem-cli/wit/deps
cp wit/deps/golem-1.x cli/golem-cli/wit/deps
cp wit/deps/golem-core cli/golem-cli/wit/deps
cp wit/deps/golem-agent cli/golem-cli/wit/deps
cp wit/deps/logging cli/golem-cli/wit/deps
"""
[tasks.wit-test-components]
private = true
script_runner = "@duckscript"
script = """
components = array
array_push ${components} oplog-processor
for component in ${components}
echo "Updating wit directory for test component ${component}"
rm -r test-components/${component}/wit/deps
mkdir test-components/${component}/wit/deps
glob_cp wit/deps/**/* test-components/${component}/wit/deps
end
"""
[tasks.remove-wit-deps]
private = true
script_runner = "@duckscript"
script = """
rm -rf golem-wasm/wit/deps
rm -rf golem-common/wit/deps
rm -rf cli/golem-cli/wit/deps
"""
[tasks.diff-wit]
private = true
script = "git diff --exit-code wit golem-wasm/wit"
[tasks.check-wit]
run_task = [{ name = ["remove-wit-deps", "wit", "diff-wit"] }]
# BUILD
[tasks.build]
dependencies = ["wit"]
description = "Builds everything in debug mode"
command = "cargo"
args = ["build", "--workspace", "--all-targets"]
[tasks.build-all-bins-including-tests]
dependencies = ["wit"]
description = "Builds all executables in debug mode, including the single-executable golem and all tests"
script_runner = "@duckscript"
script = '''
exec --fail-on-error cargo build --profile %{PROFILE}
exec --fail-on-error cargo test --no-run --profile %{PROFILE}
'''
[tasks.build-bins]
dependencies = ["wit"]
description = "Builds all executables in debug mode"
command = "cargo"
args = [
"build",
"--workspace",
"--bins",
"--exclude",
"integration-tests",
"--exclude",
"golem",
]
[tasks.build-bins-all]
dependencies = ["wit"]
description = "Builds all executables in debug mode, including the single-executable golem"
command = "cargo"
args = ["build", "--workspace", "--bins", "--exclude", "integration-tests"]
[tasks.build-bins-all-non-ci]
private = true
condition = { env_not_set = ["CI"] }
run_task = [{ name = ["build-bins-all"] }]
[tasks.build-bins-non-ci]
private = true
condition = { env_not_set = ["CI"] }
run_task = [{ name = ["build-bins"] }]
[tasks.build-worker-service]
dependencies = ["wit"]
description = "Builds the worker-service"
command = "cargo"
args = ["build", "-p", "golem-worker-service"]
[tasks.build-worker-service-non-ci]
private = true
condition = { env_not_set = ["CI"] }
run_task = [{ name = ["build-worker-service"] }]
[tasks.build-registry-service]
description = "Builds registry service"
command = "cargo"
args = ["build", "-p", "golem-registry-service"]
[tasks.build-registry-service-non-ci]
private = true
condition = { env_not_set = ["CI"] }
run_task = [{ name = ["build-registry-service"] }]
[tasks.build-release]
description = """This is the top-level task that builds everything in release mode. PLATFORM_OVERRIDE env variable can be used
to build for other target than the current one, can be linux/amd64 or linux/arm64. This is used for cross-compiling
for docker images."""
dependencies = [
"wit",
"set-version",
"build-release-default",
"build-release-override-linux-amd64",
"build-release-override-linux-arm64",
]
# There are three variants of build-release, and only one of them will run based on the value of
# the PLATFORM_OVERRIDE environment variable
[tasks.build-release-default]
description = "Build the project in release mode"
condition = { env_not_set = ["PLATFORM_OVERRIDE"] }
command = "cargo"
args = [
"build",
"--workspace",
"--release",
"--exclude",
"integration-tests",
"--exclude",
"golem",
]
[tasks.build-release-override-linux-amd64]
description = "Build the project in release mode with target platform override to linux/amd64"
condition = { env = { "PLATFORM_OVERRIDE" = "linux/amd64" } }
command = "cargo"
args = [
"build",
"--workspace",
"--release",
"--target",
"x86_64-unknown-linux-gnu",
"--exclude",
"integration-tests",
"--exclude",
"golem",
]
[tasks.build-release-override-linux-arm64]
description = "Build the project in release mode with target platform override to linux/arm64"
condition = { env = { "PLATFORM_OVERRIDE" = "linux/arm64" } }
install_crate = "cross"
command = "cross"
args = [
"build",
"--workspace",
"--release",
"--target",
"aarch64-unknown-linux-gnu",
"--exclude",
"integration-tests",
"--exclude",
"golem",
]
[tasks.build-sdk-ts]
description = "Builds the TypeScript SDK if dist or agent_guest.wasm doesn't exist"
cwd = "./sdks/ts"
condition_script = ["test ! -d packages/golem-ts-sdk/dist || test ! -f packages/golem-ts-sdk/wasm/agent_guest.wasm"]
script = '''
pnpm clean
pnpm install
pnpm run build
pnpm run build-agent-template
'''
[tasks.clean-sdk-ts]
description = "Cleans the TypeScript SDK"
cwd = "./sdks/ts"
script = '''
pnpm clean
'''
## ** CHECK **
[tasks.check]
description = "Runs rustfmt and clippy checks without applying any fix"
dependencies = ["wit", "check-clippy", "check-rustfmt"]
[tasks.check-rustfmt]
description = "Runs rustfmt checks without applying any fix"
install_crate = "rustfmt"
command = "cargo"
args = ["fmt", "--all", "--", "--check"]
[tasks.check-clippy]
description = "Runs clippy checks without applying any fix"
install_crate = "clippy"
command = "cargo"
args = ["clippy", "--all-targets", "--", "--no-deps", "-Dwarnings"]
## ** FIX **
[tasks.fix]
description = "Runs rustfmt and clippy checks and applies fixes"
#dependencies = ["wit", "fix-clippy", "fix-rustfmt"]
dependencies = ["fix-clippy", "fix-rustfmt"]
[tasks.fix-rustfmt]
description = "Runs rustfmt checks and applies fixes"
install_crate = "rustfmt"
command = "cargo"
args = ["fmt", "--all"]
[tasks.fix-clippy]
description = "Runs clippy checks and applies fixes"
install_crate = "clippy"
command = "cargo"
args = [
"clippy",
"--all-targets",
"--fix",
"--allow-dirty",
"--allow-staged",
"--",
"--no-deps",
"-Dwarnings",
]
## ** TEST **
[tasks.setup-sdk-overrides]
private = true
script_runner = "@duckscript"
script = """
# NOTE: when we reach a stable phase during a release cycle, then these env vars should be commented
set_env GOLEM_RUST_PATH ${CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY}/sdks/rust/golem-rust
set_env GOLEM_TS_PACKAGES_PATH ${CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY}/sdks/ts/packages
"""
[tasks.test]
description = "Runs all unit tests, worker executor tests and integration tests"
dependencies = [
"unit-tests",
"worker-executor-tests",
"api-tests",
"integration-tests",
]
[tasks.unit-tests]
dependencies = ["setup-sdk-overrides", "wit"]
description = "Runs unit tests only"
script = '''
cargo-test-r run --workspace --lib --exclude golem-wasm-derive -- --nocapture --report-time $JUNIT_OPTS
'''
[tasks.worker-executor-tests]
dependencies = ["wit"]
description = "Runs worker executor tests only"
env = { "WASMTIME_BACKTRACE_DETAILS" = "1", "RUST_BACKTRACE" = "1", "RUST_LOG" = "info" }
command = "cargo"
args = [
"test",
"--package",
"golem-worker-executor",
"--test",
"*",
"--",
"--nocapture",
]
[tasks.worker-executor-tests-misc]
dependencies = ["wit"]
description = "Runs only untagged and rdbms worker-executor-tests"
env = { "RUST_BACKTRACE" = "1", "WASMTIME_BACKTRACE_DETAILS" = "1", "RUST_LOG" = "info", "RUST_TEST_TIME_INTEGRATION" = "5000,30000" }
script = '''
cargo-test-r run --package golem-worker-executor --test integration :tag: -- --report-time --nocapture $JUNIT_OPTS
cargo-test-r run --package golem-worker-executor --test integration :tag:rdbms_service -- --flaky-run=5 --report-time --nocapture $JUNIT_OPTS
'''
[tasks.worker-executor-tests-group1]
dependencies = ["wit"]
description = "Runs worker executor tests only (group 1/3)"
env = { "RUST_BACKTRACE" = "1", "WASMTIME_BACKTRACE_DETAILS" = "1", "RUST_LOG" = "info", "RUST_TEST_TIME_INTEGRATION" = "5000,30000" }
script = '''
cargo-test-r run --package golem-worker-executor --test integration :tag:group1 -- --report-time --nocapture $WORKER_TEST_THREAD_OPTS $JUNIT_OPTS
'''
[tasks.worker-executor-tests-group2]
dependencies = ["wit"]
description = "Runs worker executor tests only (group 2/3)"
env = { "RUST_BACKTRACE" = "1", "WASMTIME_BACKTRACE_DETAILS" = "1", "RUST_LOG" = "info", "RUST_TEST_TIME_INTEGRATION" = "5000,30000" }
script = '''
cargo-test-r run --package golem-worker-executor --test integration :tag:group2 -- --report-time --nocapture $WORKER_TEST_THREAD_OPTS $JUNIT_OPTS
'''
[tasks.worker-executor-tests-group3]
dependencies = ["wit"]
description = "Runs worker executor tests only (group 3/3)"
env = { "RUST_BACKTRACE" = "1", "WASMTIME_BACKTRACE_DETAILS" = "1", "RUST_LOG" = "info", "RUST_TEST_TIME_INTEGRATION" = "5000,30000" }
script = '''
cargo-test-r run --package golem-worker-executor --test integration :tag:group3 -- --report-time --nocapture $WORKER_TEST_THREAD_OPTS $JUNIT_OPTS
'''
[tasks.integration-tests]
description = "Runs all integration tests"
dependencies = [
"integration-tests-group1",
"integration-tests-group2",
"integration-tests-group3",
"integration-tests-group4",
"cli-integration-tests",
]
[tasks.integration-tests-group1]
description = "Runs integration tests (group 1/4)"
dependencies = ["build-bins-non-ci"]
env = { "RUST_LOG" = "info", "RUST_BACKTRACE" = "1", "QUIET" = "true" }
script = '''
cargo-test-r run --package integration-tests --test integration -- --nocapture --test-threads=1 --report-time $JUNIT_OPTS
'''
[tasks.integration-tests-group2]
description = "Runs integration tests (group 2/4)"
dependencies = ["build-bins-non-ci"]
env = { "RUST_LOG" = "info", "RUST_BACKTRACE" = "1", "QUIET" = "true", "GOLEM_TEST_DB" = "sqlite" }
script = '''
cargo-test-r run --package integration-tests --test integration -- --nocapture --test-threads=1 --report-time $JUNIT_OPTS
'''
[tasks.integration-tests-group3]
description = "Runs integration tests (group 3/4)"
dependencies = ["wit"]
env = { "RUST_LOG" = "info", "RUST_BACKTRACE" = "1", "QUIET" = "true" }
script = '''
cargo-test-r run --package golem-service-base --test '*' -- --nocapture --report-time $JUNIT_OPTS
cargo-test-r run --package golem-registry-service --test '*' -- --nocapture --report-time $JUNIT_OPTS
cargo-test-r run --package golem-worker-service --test '*' -- --nocapture --report-time $JUNIT_OPTS
cargo-test-r run --package golem-debugging-service --test '*' -- --report-time $JUNIT_OPTS
'''
[tasks.integration-tests-group4]
description = "Runs integration tests (group 4/4)"
dependencies = ["build-bins-non-ci"]
env = { "RUST_LOG" = "info", "RUST_BACKTRACE" = "1", "QUIET" = "true", "GOLEM__WORKER_EXECUTOR_RETRIES__MAX_ATTEMPTS" = "20", "GOLEM__WORKER_EXECUTOR_RETRIES__MAX_DELAY" = "1s" }
script = '''
cargo-test-r run --package integration-tests --test sharding -- --nocapture --report-time $JUNIT_OPTS
'''
[tasks.cli-integration-tests]
description = "Runs all CLI integration tests"
dependencies = [
"cli-integration-tests-group1",
"cli-integration-tests-group2",
"cli-integration-tests-group3",
]
[tasks.cli-integration-tests-group1]
dependencies = ["setup-sdk-overrides", "build-bins-all-non-ci", "build-sdk-ts"]
description = "Run CLI integration tests (1/3)"
env = { "RUST_LOG" = "info", "RUST_BACKTRACE" = "1", "QUIET" = "true" }
script_runner = "@duckscript"
script = '''
exec --fail-on-error cargo-test-r run --package golem-cli :tag: --test integration -- --nocapture --report-time %{JUNIT_OPTS}
exec --fail-on-error cargo-test-r run --package golem-cli :tag:group1 --test integration -- --nocapture --test-threads=1 --report-time %{JUNIT_OPTS}
'''
[tasks.cli-integration-tests-group2]
dependencies = ["setup-sdk-overrides", "build-bins-all-non-ci", "build-sdk-ts"]
description = "Run CLI integration tests (2/3)"
env = { "RUST_LOG" = "info", "RUST_BACKTRACE" = "1", "QUIET" = "true" }
script_runner = "@duckscript"
script = '''
exec --fail-on-error cargo-test-r run --package golem-cli :tag:group2 --test integration -- --nocapture --report-time %{JUNIT_OPTS}
'''
[tasks.cli-integration-tests-group3]
dependencies = ["setup-sdk-overrides", "build-bins-all-non-ci", "build-sdk-ts"]
description = "Run CLI integration tests (3/3)"
env = { "RUST_LOG" = "info", "RUST_BACKTRACE" = "1", "QUIET" = "true" }
script_runner = "@duckscript"
script = '''
exec --fail-on-error cargo-test-r run --package golem-cli :tag:group3 --test integration -- --nocapture --report-time %{JUNIT_OPTS}
'''
[tasks.cli-integration-tests-update-golden-files]
dependencies = ["setup-sdk-overrides", "build-bins-all-non-ci", "build-sdk-ts"]
env = { "RUST_LOG" = "info", "RUST_BACKTRACE" = "1", "UPDATE_GOLDENFILES" = "1" }
script_runner = "@duckscript"
script = '''
exec --fail-on-error cargo-test-r run --package golem-cli --test integration app::agents::test_ts_code_first_with_rpc_and_all_types -- --nocapture
exec --fail-on-error cargo-test-r run --package golem-cli --test integration app::agents::test_rust_code_first_with_rpc_and_all_types -- --nocapture
'''
[tasks.sharding-tests-debug]
dependencies = ["build-bins-non-ci"]
script = '''
rm -rf logs data
mkdir -pv logs data
export RUST_LOG=info,golem_test_framework::components=WARN
export RUST_BACKTRACE=1
export GOLEM__TRACING__FILE_DIR=../logs
export GOLEM__TRACING__FILE_TRUNCATE=false
export GOLEM__TRACING__FILE__ENABLED=true
export GOLEM__WORKER_EXECUTOR_RETRIES__MAX_ATTEMPTS=20
export GOLEM__WORKER_EXECUTOR_RETRIES__MAX_DELAY="1s"
cargo-test-r run \
--package integration-tests \
--test sharding ${@} \
-- --nocapture --test-threads=1
'''
[tasks.registry-repo-coverage]
description = "Run registry service tests with covarage report for repository sources"
script = '''
cargo tarpaulin \
--skip-clean \
--target-dir target-tarpaulin \
--package golem-registry-service \
--include-files "golem-registry-service/src/repo/*" \
--out html \
--output-dir target-tarpaulin/reports
'''
## ** CHECK-OPENAPI **
[tasks.check-openapi]
description = "Generates openapi spec from the code and checks if it is the same as the ones in the openapi directory"
dependencies = ["merge-openapi", "diff-openapi"]
[tasks.diff-openapi]
description = "Checks if the generated openapi spec is the same as the one in the openapi directory"
dependencies = ["merge-openapi"]
script = '''
if diff openapi/golem-service.yaml target/golem-service.yaml >/dev/null 2>&1
then
echo "Latest Golem OpenAPI spec version detected."
else
echo "openapi/golem-service.yaml is not the same as produced by golem-service-yaml." 1>&2
echo "Run cargo make generate-openapi to generate new spec." 1>&2
echo ""
diff openapi/golem-service.yaml target/golem-service.yaml
exit 1
fi
if diff openapi/golem-registry-service.yaml target/golem-registry-service.yaml >/dev/null 2>&1
then
echo "Latest Golem Registry Service OpenAPI spec version detected."
else
echo "openapi/golem-registry-service.yaml is not the same as produced by golem-registry-service." 1>&2
echo "Run cargo make generate-openapi to generate new spec." 1>&2
exit 1
fi
if diff openapi/golem-worker-service.yaml target/golem-worker-service.yaml >/dev/null 2>&1
then
echo "Latest Golem Worker Service OpenAPI spec version detected."
else
echo "openapi/golem-worker-service.yaml is not the same as produced by golem-worker-service." 1>&2
echo "Run cargo make generate-openapi to generate new spec." 1>&2
exit 1
fi
'''
## ** GENERATE-OPENAPI **
[tasks.generate-openapi]
dependencies = ["merge-openapi", "store-openapi"]
description = "Generates openapi spec from the code and saves it to the openapi directory"
[tasks.generate-registry-service-openapi]
description = "Generates openapi spec for registry service"
dependencies = ["build-registry-service-non-ci"]
cwd = "./target/debug"
script = '''
mkdir -pv ../data
./golem-registry-service --dump-openapi-yaml > ../golem-registry-service.yaml
'''
[tasks.generate-worker-service-openapi]
description = "Generates openapi spec for worker service"
dependencies = ["build-worker-service-non-ci"]
cwd = "./target/debug"
script = '''
mkdir -pv ../data
./golem-worker-service --dump-openapi-yaml > ../golem-worker-service.yaml
'''
[tasks.merge-openapi]
dependencies = [
"generate-registry-service-openapi",
"generate-worker-service-openapi"
]
install_crate = { crate_name = "golem-openapi-client-generator", version = "=0.0.16" }
command = "golem-openapi-client-generator"
args = [
"merge",
"--spec-yaml",
"./target/golem-registry-service.yaml",
"./target/golem-worker-service.yaml",
"--output-yaml",
"./target/golem-service.yaml",
]
[tasks.store-openapi]
description = "Stores the generated openapi spec in the openapi directory"
dependencies = ["merge-openapi"]
script = [
"cp -v ./target/golem-service.yaml ./openapi/golem-service.yaml",
"cp -v ./target/golem-registry-service.yaml ./openapi/",
"cp -v ./target/golem-worker-service.yaml ./openapi/",
]
## ** PUBLISH **
[tasks.publish]
description = "Publishes packages to crates.io"
dependencies = [
"set-version",
"publish-golem-wasm-derive",
"publish-golem-wasm",
]
[tasks.set-version]
description = "Sets the version in all Cargo.toml files to the value of the VERSION environment variable"
condition = { env_set = ["VERSION"] }
script = '''
grep -rl --include 'Cargo.toml' '0\.0\.0' | xargs sed -i "s/0\.0\.0/${VERSION}/g"
'''
[tasks.set-version.mac]
condition = { env_set = ["VERSION"] }
script = '''
grep -rl --include '.*Cargo\.toml' '0\.0\.0' | xargs sed -i "" "s/0\.0\.0/${VERSION}/g"
'''
[tasks.set-version.windows]
script_runner = "powershell"
script_extension = "ps1"
condition = { env_set = ["VERSION"] }
script = '''
$cargoFiles = Get-ChildItem . Cargo.toml -rec
foreach ($file in $cargoFiles)
{
(Get-Content $file.PSPath) |
Foreach-Object { $_ -replace "0.0.0", $Env:VERSION } |
Set-Content $file.PSPath
}
'''
[tasks.publish-golem-wasm-derive]
description = "Publishes golem-wasm-derive package to crates.io"
command = "cargo"
args = [
"publish",
"-p",
"golem-wasm-derive",
"--all-features",
"--allow-dirty",
"--no-verify",
]
[tasks.publish-golem-wasm]
description = "Publishes golem-wasm package to crates.io"
command = "cargo"
args = [
"publish",
"-p",
"golem-wasm",
"--all-features",
"--allow-dirty",
"--no-verify",
]
## ** PACKAGE RELEASE **
# There are three variants of package-release, and only one of them will run based on the value of
# the PLATFORM_OVERRIDE environment variable
[tasks.package-release]
description = "Packages the project's release artifact"
dependencies = [
"package-release-default",
"package-release-override-linux-amd64",
"package-release-override-linux-arm64",
]
[tasks.package-release-base]
private = true
description = "Packages the project's release artifact. Must have the PLATFORM_TARGET env var set."
cwd = "target"
command = "tar"
args = [
"-cvf",
"${PLATFORM_TARGET}.tar",
"${PLATFORM_TARGET}/release/golem-registry-service",
"${PLATFORM_TARGET}/release/golem-shard-manager",
"${PLATFORM_TARGET}/release/worker-executor",
"${PLATFORM_TARGET}/release/golem-debugging-service",
"${PLATFORM_TARGET}/release/golem-worker-service",
"${PLATFORM_TARGET}/release/golem-component-compilation-service",
]
[tasks.package-release-default]
description = "Packages the project's release artifact"
condition = { env_not_set = ["PLATFORM_OVERRIDE"] }
env = { "PLATFORM_TARGET" = "." }
extend = "package-release-base"
dependencies = ["build-release-default"]
[tasks.package-release-override-linux-amd64]
description = "Packages the project's release artifact with target platform override to linux/amd64"
condition = { env = { "PLATFORM_OVERRIDE" = "linux/amd64" } }
env = { "PLATFORM_TARGET" = "x86_64-unknown-linux-gnu" }
extend = "package-release-base"
dependencies = ["build-release-override-linux-amd64"]
[tasks.package-release-override-linux-arm64]
description = "Packages the project in release artifact with target platform override to linux/arm64"
condition = { env = { "PLATFORM_OVERRIDE" = "linux/arm64" } }
env = { "PLATFORM_TARGET" = "aarch64-unknown-linux-gnu" }
extend = "package-release-base"
dependencies = ["build-release-override-linux-arm64"]
[tasks.run]
description = "Runs all the services locally"
dependencies = ["build"]
condition = { fail_message = "Requires lnav, nginx and redis on path. Install them with your package manager" }
condition_script = ["nginx -v", "lnav --version", "redis-server --version", ""]
env = { "GOLEM_REGISTRY_SERVICE_LOGIN_TYPE" = "Disabled" }
script = { file = "./local-run/start.sh" }
[tasks.run-with-login-enabled]
description = "Runs all the services locally with the oauth2 login system enabled"
dependencies = ["build"]
condition = { env_set = [
"GITHUB_CLIENT_ID",
"GITHUB_CLIENT_SECRET",
], fail_message = "Requires lnav, nginx and redis on path. Install them with your package manager. GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET env vars must be set." }
condition_script = ["nginx -v", "lnav --version", "redis-server --version", ""]
env = { "GOLEM_REGISTRY_SERVICE_LOGIN_TYPE" = "OAuth2" }
script = { file = "./local-run/start.sh" }
## ** GENERATE CONFIGS **
[tasks.generate-configs]
description = "Generates default and example config files"
dependencies = ["build-bins-non-ci"]
script = '''
export RUST_BACKTRACE=1
./target/debug/golem-registry-service --dump-config-default-toml > golem-registry-service/config/registry-service.toml
./target/debug/golem-registry-service --dump-config-default-env-var > golem-registry-service/config/registry-service.sample.env
./target/debug/golem-shard-manager --dump-config-default-toml > golem-shard-manager/config/shard-manager.toml
./target/debug/golem-shard-manager --dump-config-default-env-var > golem-shard-manager/config/shard-manager.sample.env
./target/debug/golem-component-compilation-service --dump-config-default-toml > golem-component-compilation-service/config/component-compilation-service.toml
./target/debug/golem-component-compilation-service --dump-config-default-env-var > golem-component-compilation-service/config/component-compilation-service.sample.env
./target/debug/golem-worker-service --dump-config-default-toml > golem-worker-service/config/worker-service.toml
./target/debug/golem-worker-service --dump-config-default-env-var > golem-worker-service/config/worker-service.sample.env
./target/debug/worker-executor --dump-config-default-toml > golem-worker-executor/config/worker-executor.toml
./target/debug/worker-executor --dump-config-default-env-var > golem-worker-executor/config/worker-executor.sample.env
./target/debug/golem-debugging-service --dump-config-default-toml > golem-debugging-service/config/debug-worker-executor.toml
./target/debug/golem-debugging-service --dump-config-default-env-var > golem-debugging-service/config/debug-worker-executor.sample.env
'''
## ** CHECK CONFIGS **
[tasks.check-configs]
description = "Generates configs from code and checks if it's committed"
dependencies = ["generate-configs"]
script = '''
git diff --exit-code \
golem-registry-service/config/registry-service.toml \
golem-registry-service/config/registry-service.sample.env \
golem-shard-manager/config/shard-manager.toml \
golem-shard-manager/config/shard-manager.sample.env \
golem-component-compilation-service/config/component-compilation-service.toml \
golem-component-compilation-service/config/component-compilation-service.sample.env \
golem-worker-service/config/worker-service.toml \
golem-worker-service/config/worker-service.sample.env \
golem-worker-executor/config/worker-executor.toml \
golem-worker-executor/config/worker-executor.sample.env \
golem-debugging-service/config/debug-worker-executor.toml \
golem-debugging-service/config/debug-worker-executor.sample.env
'''
## ** CHECK UNUSED DEPS **
[tasks.check-unused-deps]
description = "Detects unused Cargo dependencies using cargo-udeps (requires nightly). Use UDEPS_FEATURES='' for default features only, or UDEPS_INSTALL=true to auto-install prerequisites."
env = { UDEPS_NIGHTLY = { default_value = "nightly", condition = { env_not_set = ["UDEPS_NIGHTLY"] } }, UDEPS_FEATURES = { default_value = "--all-features", condition = { env_not_set = ["UDEPS_FEATURES"] } }, UDEPS_INSTALL = { default_value = "false", condition = { env_not_set = ["UDEPS_INSTALL"] } } }
script = '''
#!/usr/bin/env bash
set -euo pipefail
NIGHTLY="${UDEPS_NIGHTLY}"
FEATURE_FLAG="${UDEPS_FEATURES}"
AUTO_INSTALL="${UDEPS_INSTALL}"
# ── Check prerequisites ──────────────────────────────────────────────────────
if ! rustup toolchain list | grep -q "$NIGHTLY"; then
if [ "$AUTO_INSTALL" = "true" ]; then
echo "📦 Installing $NIGHTLY toolchain..."
rustup toolchain install "$NIGHTLY"
else
echo "❌ $NIGHTLY toolchain not installed."
echo " Run: rustup toolchain install $NIGHTLY"
echo " Or re-run with: cargo make -e UDEPS_INSTALL=true check-unused-deps"
exit 1
fi
fi
if ! cargo "+$NIGHTLY" udeps --version >/dev/null 2>&1; then
if [ "$AUTO_INSTALL" = "true" ]; then
echo "📦 Installing cargo-udeps..."
cargo "+$NIGHTLY" install cargo-udeps --locked
else
echo "❌ cargo-udeps not installed."
echo " Run: cargo +$NIGHTLY install cargo-udeps --locked"
echo " Or re-run with: cargo make -e UDEPS_INSTALL=true check-unused-deps"
exit 1
fi
fi
# ── Use a separate target dir so we don't pollute the stable build ────────────
export CARGO_TARGET_DIR="${CARGO_MAKE_WORKING_DIRECTORY}/target/nightly-udeps"
echo "════════════════════════════════════════════════════════════════════════════"
echo " Unused Dependency Report (compiler-based, cargo-udeps)"
echo " Generated: $(date '+%Y-%m-%d %H:%M:%S')"
echo " Workspace: ${CARGO_MAKE_WORKING_DIRECTORY}"
echo " Nightly: $NIGHTLY"
echo " Features: ${FEATURE_FLAG:-default only}"
echo " Target: $CARGO_TARGET_DIR"
echo "════════════════════════════════════════════════════════════════════════════"
echo ""
echo "Running cargo +$NIGHTLY udeps on the entire workspace..."
echo "(First run is slow — full nightly build. Subsequent runs are incremental.)"
echo ""
# ── Run cargo-udeps on the whole workspace at once ────────────────────────────
UDEPS_OUTPUT_FILE=$(mktemp)
trap "rm -f '$UDEPS_OUTPUT_FILE'" EXIT
UDEPS_EXIT=0
# shellcheck disable=SC2086
cargo "+$NIGHTLY" udeps \
--workspace \
$FEATURE_FLAG \
--output human \
> "$UDEPS_OUTPUT_FILE" 2>&1 || UDEPS_EXIT=$?
# ── Check for compilation failure ─────────────────────────────────────────────
if grep -q "^error\[E" "$UDEPS_OUTPUT_FILE" || grep -q "could not compile" "$UDEPS_OUTPUT_FILE"; then
echo "❌ Build failed! cargo-udeps requires a successful nightly compilation."
echo ""
echo "Compilation errors:"
grep -A2 "^error\[E\|could not compile" "$UDEPS_OUTPUT_FILE" | head -30
echo ""
echo "You may need to set UDEPS_NIGHTLY to a version that compiles the workspace."
echo "Current: $NIGHTLY"
exit 1
fi
# ── Parse and display results ─────────────────────────────────────────────────
TOTAL_UNUSED=0
CRATES_WITH_UNUSED=0
AGENT_LINES=""
current_crate=""
current_manifest=""
current_section=""
crate_header_printed=false
agent_deps=""
flush_crate() {
if [ "$crate_header_printed" = true ]; then
echo "└─"
echo ""
fi
if [ -n "$agent_deps" ] && [ -n "$current_manifest" ]; then
if [ -n "$AGENT_LINES" ]; then
AGENT_LINES="$AGENT_LINES
"
fi
AGENT_LINES="${AGENT_LINES} In $current_manifest, remove:$agent_deps"
fi
current_crate=""
current_manifest=""
current_section=""
crate_header_printed=false
agent_deps=""
}
print_crate_header() {
if [ "$crate_header_printed" = false ]; then
CRATES_WITH_UNUSED=$((CRATES_WITH_UNUSED + 1))
echo "┌─ $current_crate ($current_manifest)"
echo "│"
crate_header_printed=true
fi
}
while IFS= read -r line; do
crate_name=$(echo "$line" | sed -n 's/^`\([a-zA-Z0-9_-]*\) v[0-9].* (\(.*\))`$/\1/p')
crate_path=$(echo "$line" | sed -n 's/^`\([a-zA-Z0-9_-]*\) v[0-9].* (\(.*\))`$/\2/p')
if [ -n "$crate_name" ] && [ -n "$crate_path" ]; then
flush_crate
current_crate="$crate_name"
rel_path="${crate_path#"${CARGO_MAKE_WORKING_DIRECTORY}/"}"
current_manifest="$rel_path/Cargo.toml"
current_section=""
continue
fi
case "$line" in
*"── dependencies"*)
if echo "$line" | grep -q "dev-dependencies"; then
current_section="dev"
elif echo "$line" | grep -q "build-dependencies"; then
current_section="build"
else
current_section="normal"
fi
continue
;;
esac
dep=$(echo "$line" | sed -n 's/.*[└├]─*── "\([a-zA-Z0-9_-]*\)".*/\1/p')
if [ -n "$dep" ] && [ -n "$current_crate" ] && [ -n "$current_section" ]; then
print_crate_header
TOTAL_UNUSED=$((TOTAL_UNUSED + 1))
case "$current_section" in
normal)
echo "│ - $dep"
agent_deps="$agent_deps $dep"
;;
dev)
echo "│ - $dep (dev-dependency)"
agent_deps="$agent_deps (dev) $dep"
;;
build)
echo "│ - $dep (build-dependency)"
agent_deps="$agent_deps (build) $dep"
;;
esac
fi
done < "$UDEPS_OUTPUT_FILE"
flush_crate