-
Notifications
You must be signed in to change notification settings - Fork 416
/
Copy pathEarthfile
1905 lines (1641 loc) · 83.3 KB
/
Earthfile
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
VERSION 0.8
FROM --pass-args ./integration-base+test-base
WORKDIR /test
PROJECT earthly-technologies/core
all:
BUILD +ga
BUILD +experimental
ga:
BUILD +ga-no-qemu
BUILD +ga-qemu
ga-qemu:
BUILD --pass-args ./platform+test
BUILD +test-platform-expansion
ga-no-qemu-group1:
BUILD --pass-args ./autocompletion+test-all
BUILD --pass-args ./dockerfile+test-all
BUILD --pass-args ./dockerfile2/subdir+test
BUILD --pass-args ./locally-in-command+all
BUILD --pass-args ./locally-in-function+all
BUILD --pass-args ./command-to-function-rename+all
BUILD --pass-args ./import+build
BUILD --pass-args ./import+build-imported
BUILD +privileged-test
ga-no-qemu-group2:
BUILD +copy-test
BUILD +copy-test-verbose-output
BUILD +copy-tilde-test
BUILD +copy-keep-own-test
BUILD +copy-test-empty-src
BUILD +copy-test-if-exists-wildcard
BUILD +copy-test-wildcard
BUILD +git-clone-test
BUILD +builtin-args-invalid-default-test
BUILD +builtin-args-invalid-pass-test
BUILD +builtin-args-cli-tests
BUILD +parser-smoke-test
ga-no-qemu-group3:
BUILD --pass-args ./invalid+test-all
BUILD +excludes-test
BUILD +secrets-test
BUILD +secrets-optional-prefix-test
BUILD +secrets-args-precedence-test
BUILD +project-secrets-test
BUILD +build-arg-test
BUILD +build-arg-explicit-global-test
BUILD +build-arg-dynamic-with-empty-base
BUILD +lc-test
BUILD +from-expose-test
BUILD +scratch-test
BUILD +build-earthly-test
BUILD +host-bind-test
BUILD +transitive-args-test
BUILD +transitive-args-test2
BUILD +non-transitive-args-test
ga-no-qemu-group4:
BUILD +star-test
BUILD +dockerfile-test
BUILD +fail-test
BUILD +fail-push-test
BUILD +allow-privileged-import-test
BUILD +reject-privileged-import-test
BUILD +required-arg-test
BUILD +push-test
BUILD +push-arg-test
BUILD +ci-arg-test
BUILD +gen-dockerfile-test
BUILD +chown-test
BUILD +env-test
BUILD +env-home-test
BUILD +stack-failure-test
BUILD +multi-stack-failure-test
BUILD +no-cache-local-artifact-test
BUILD +empty-git-test
BUILD +escape-test
BUILD +escape-dir-test
BUILD +fail-invalid-artifact-test
BUILD +wildcard-all
BUILD +target-first-line
BUILD +absolute-reference-with-relative
BUILD +end-comment
BUILD +file-copying
BUILD +run-no-cache
BUILD +save-artifact-file-as-dot
BUILD +save-artifact-dir-as-dot
BUILD +save-artifact-force-overwrite
BUILD +save-remote-artifact-selective
ga-no-qemu-group5:
BUILD +push-build
BUILD +build-arg-repeat
BUILD +arg-scope-requires-shellout-anywhere
BUILD +arg-set
BUILD +if
BUILD +for
BUILD +first-command
BUILD +platform-output
BUILD +command
BUILD +function
BUILD +function-nested-global
BUILD --pass-args ./functions-do-not-propagate-args+test-all
BUILD +duplicate
BUILD +reserved
BUILD +quotes-test
BUILD +quotes-test-extra
BUILD +new-args
BUILD +import
BUILD +from-dockerfile-arg
BUILD +true-false-flag
BUILD +true-false-flag-invalid
BUILD +dont-save-indirect-remote-artifact
BUILD +remote-earthfile-must-have-version
BUILD +version-flag-test
BUILD +implicit-ignores
BUILD +help
BUILD +ls
BUILD +ls-subdir
BUILD +host
BUILD +host-invalid
BUILD +mtime
BUILD +build-after-from
BUILD +doc
BUILD +doc-recipe-block
BUILD +no-network
BUILD +test-works-without-earthly-server
BUILD +test-init-unsupported
BUILD +test-init-golang
BUILD +pass-args-test
BUILD +pass-args-defaults-test
BUILD +pass-args-no-builtins-via-function-test
BUILD +test-reserved-label
BUILD +test-cache-mount-mode
BUILD +test-cache-mode
BUILD +test-shared-cache
BUILD +test-cache-persist
BUILD +test-visited-upfront-hash-collection
BUILD +test-exec-stats
BUILD +test-aws-flag-envs
BUILD +test-aws-flag-configs
BUILD +test-aws-flag-none
# Forcing the implicit global wait/end block, causes some tests, which rely
# on the ability to have two different targets issue the same SAVE IMAGE tag name
# (with the last SAVE IMAGE command taking precedence)
# Earthly, when using the wait-end feature, will return an error for such cases.
# As a result, the following tests are incompatible with WAIT/END block.
# Once version 0.7 is released AND support for 0.6 has been dropped,
# these tests can be removed, along with deprecated code from the builder.go's bf.
ARG GLOBAL_WAIT_END="false"
IF [ "$GLOBAL_WAIT_END" = "false" ]
BUILD +save-artifact-after-push
BUILD --pass-args ./with-docker-via-command+test
END
ga-no-qemu-group6:
BUILD +cache-test
BUILD --pass-args ./do-not-track+test-all
BUILD --pass-args ./scrub-https-credentials+all
BUILD --pass-args ./autocompletion/install+test-all
BUILD +cache-cmd
BUILD --pass-args ./config+test
BUILD +arg-redeclare-error
BUILD +ssh
BUILD +builtin-args-test
BUILD +remote-test
BUILD +save-artifact-dont-overwrite
BUILD --pass-args ./with-docker-expose+all
BUILD --pass-args ./logbus+test-all
ga-no-qemu-group7:
BUILD +cache-mount-arg
BUILD +infinite-recursion
BUILD +save-artifact-selective
BUILD +if-exists
BUILD +let-set
BUILD +let-scope
BUILD +save-artifact-selective-referencing-remote
BUILD --pass-args ./secret-provider-config+test-all
BUILD --pass-args ./shell-out+test-all
BUILD --pass-args ./with-docker-compose+all
BUILD +dotenv-test
BUILD +allow-privileged-test
ga-no-qemu-group8:
BUILD --pass-args ./with-docker-registry+all
BUILD +test-ssh-command-config-via-remote-target
BUILD +test-ssh-command-config-via-git-clone-earthfile-command
BUILD --pass-args ./propagate-args-to-base+test-all
BUILD --pass-args ./pass-args-default+test
BUILD --pass-args ./pass-args-no-builtins+test
BUILD --pass-args ./pass-args-global+test
BUILD --pass-args ./pass-args-default-via-function+test
BUILD --pass-args ./pass-args-global-via-function+test
BUILD --pass-args ./pass-args-via-function-with-override+test
BUILD --pass-args ./raw-output+test-all
ga-no-qemu-group9:
BUILD --pass-args ./autoskip+test-group1
ga-no-qemu-group10:
BUILD --pass-args ./autoskip+test-group2
ga-no-qemu-group11:
BUILD --pass-args ./autoskip+test-group3
ga-no-qemu-group12:
BUILD --pass-args ./warn-if-not-logged-in+test
BUILD --pass-args ./with-docker-validate-labels+all
BUILD --pass-args +test-aws-oidc
BUILD --pass-args +run-no-cache-save-artifact
ga-no-qemu-slow:
BUILD +server
BUILD --pass-args ./with-docker+all
BUILD --pass-args ./with-docker-cache+test
# this has been moved to a seperate target until we get the flakey "tell me who you are" bug
# fixed; see https://github.com/earthly/earthly/issues/2567
#BUILD --pass-args ./git-metadata+test
BUILD --pass-args ./git-ssh-server+all
BUILD --pass-args ./private-https+all
BUILD --pass-args ./version+test-all
ga-no-qemu-kind:
BUILD --pass-args ./with-docker-kind+all
ga-no-qemu:
BUILD +ga-no-qemu-group1
BUILD +ga-no-qemu-group2
BUILD +ga-no-qemu-group3
BUILD +ga-no-qemu-group4
BUILD +ga-no-qemu-group5
BUILD +ga-no-qemu-group6
BUILD +ga-no-qemu-group7
BUILD +ga-no-qemu-group8
BUILD +ga-no-qemu-group9
BUILD +ga-no-qemu-group10
BUILD +ga-no-qemu-group11
BUILD +ga-no-qemu-group12
BUILD +ga-no-qemu-slow
# Note that this target is split up under github action workflows
# since they are flaky and having the ability to restart them individually
# saves a lot of time
tests-that-require-earthly-technologies-account-access:
BUILD --pass-args +test-earthly-mirror-was-setup
BUILD --pass-args ./account+test
BUILD --pass-args ./registry-command+test
BUILD --pass-args ./web+test
BUILD --pass-args ./oidc+test
# tests that only run on linux amd64
# Note: this target is used to validate the USERPLATFORM user arg,
# and should not be used to programmatically detect if this should be
# run or not.
ga-linux-amd64:
BUILD +user-arg-test
experimental:
BUILD --pass-args ./dind-auto-install+all
ast-test-input:
FROM alpine:3.18
COPY ./*.earth ./
COPY ./with-docker/Earthfile ./with-docker.earth
COPY ./with-docker-compose/Earthfile ./with-docker-compose.earth
SAVE ARTIFACT ./*.earth
privileged-test:
DO +RUN_EARTHLY --earthfile=privileged.earth --extra_args="--allow-privileged" --target=+test
copy-test:
RUN mkdir -p in/sub/1 in/sub/2 && \
echo "root" > in/root && \
echo "1" > in/sub/1/file && \
echo "2" > in/sub/2/file && \
echo "sub" > in/sub/file
DO +RUN_EARTHLY --earthfile=copy.earth --output_does_not_contain="which does not expand to a home directory"
copy-test-empty-src:
DO +RUN_EARTHLY --earthfile=copy.earth --target=+copy-empty-src
DO +RUN_EARTHLY --earthfile=copy.earth --target=+copy-empty-src-if-exists
copy-test-wildcard:
DO +RUN_EARTHLY --earthfile=copy.earth --target=+copy-wildcard
copy-test-if-exists-wildcard:
DO +RUN_EARTHLY --earthfile=copy.earth --target=+copy-if-exists-wildcard
RUN mkdir existing_folder
DO +RUN_EARTHLY --earthfile=copy.earth --target="+copy-if-exists-wildcard-exists-empty"
RUN touch existing_folder/foo
DO +RUN_EARTHLY --earthfile=copy.earth --target="+copy-if-exists-wildcard-exists"
copy-test-verbose-output:
RUN mkdir -p subdir/a.txt && \
echo -n "a" > a.txt && \
echo -n "alpha" > alpha.txt && \
echo -n "beta" > subdir/a.txt/beta.txt
# Setup a test that runs earthly twice; both instances of earthly must be run
# back to back as the file caching logic references the directories inode ID while constructing
# the shared cache key.
RUN echo "#!/bin/sh
set -ex
earthly --config \$earthly_config --verbose +copy 2>&1 | tee output.txt;
earthly --config \$earthly_config --verbose +copy 2>&1 | tee output2.txt;
" >/tmp/multiple-earthly-script && chmod +x /tmp/multiple-earthly-script
DO +RUN_EARTHLY --earthfile=copy-verbose.earth --exec_cmd=/tmp/multiple-earthly-script
# test that the first run sends a.txt and doesn't send any non-referenced files
RUN cat output.txt | acbgrep 'sent data for a.txt (1 B)'
RUN if grep "sent data for alpha.txt" output.txt >/dev/null; then echo "alpha.txt should not have been sent"; exit 1; fi
RUN if grep "sent data for .*beta.txt" output.txt >/dev/null; then echo "beta.txt should not have been sent"; exit 1; fi
# test that the second run did not resend a.txt (or any other non-referenced files)
RUN if grep "sent data for a.txt" output2.txt >/dev/null; then echo "a.txt should not have been sent"; exit 1; fi
RUN if grep "sent data for alpha.txt" output2.txt >/dev/null; then echo "alpha.txt should not have been sent"; exit 1; fi
RUN if grep "sent data for .*beta.txt" output2.txt >/dev/null; then echo "beta.txt should not have been sent"; exit 1; fi
# test SAVE ARTIFACT AS LOCAL texts is output
DO +RUN_EARTHLY --earthfile=copy-verbose.earth --extra_args="--verbose" --target=+save --output_contains="received data for important-data .12 B."
RUN ls -la important-data
copy-keep-own-test:
DO +RUN_EARTHLY --target=+test-known-user --earthfile=copy-keep-own.earth
DO +RUN_EARTHLY --target=+test-unknown-user --earthfile=copy-keep-own.earth
copy-tilde-test:
RUN touch in
DO +RUN_EARTHLY --target=+copy-tilde-destination --earthfile=copy-tilde.earth --output_contains='destination path \"~/.\" contains a \"~\" which does not expand to a home directory'
DO +RUN_EARTHLY --target=+copy-tilde-in-destination --earthfile=copy-tilde.earth --output_contains='destination path \"/some/dir/~/.\" contains a \"~\" which does not expand to a home directory'
DO +RUN_EARTHLY --target=+copy-tilde-in-destination-prefix --earthfile=copy-tilde.earth --output_contains='destination path \"~some/dir.\" contains a \"~\" which does not expand to a home directory'
DO +RUN_EARTHLY --target=+copy-tilde-arg-in-destination --earthfile=copy-tilde.earth --output_contains='destination path \"/some/dir/~/.\" contains a \"~\" which does not expand to a home directory'
DO +RUN_EARTHLY --target=+copy-tilde-artifact --earthfile=copy-tilde.earth --output_contains='destination path \"/some/dir/~/.\" contains a \"~\" which does not expand to a home directory'
DO +RUN_EARTHLY --target=+copy-tilde-in-destination-not-prefix --earthfile=copy-tilde.earth --output_does_not_contain="which does not expand to a home directory"
cache-test:
# Test that a file can be passed between runs through the mounted cache.
DO +RUN_EARTHLY --earthfile=cache1.earth --target=+test-pass-file --use_tmpfs=false
DO +RUN_EARTHLY --earthfile=cache2.earth --target=+test-pass-file --use_tmpfs=false
# Test that a change to the contents of the mount does not cause a cache bust if everything else
# is the same.
DO +RUN_EARTHLY --earthfile=cache1.earth --target=+test-no-bust-on-change --use_tmpfs=false
DO +RUN_EARTHLY --earthfile=cache2.earth --target=+test-no-bust-on-change --use_tmpfs=false # make a change
DO +RUN_EARTHLY --earthfile=cache1.earth --target=+test-no-bust-on-change --use_tmpfs=false \
--post_command=">output.txt 2>&1" # check that all is still cached if re-running the prev version
RUN cat output.txt
RUN cat output.txt | acbgrep '\*cached\* --> RUN echo hey'
git-clone-test:
DO +RUN_EARTHLY --earthfile=git-clone.earth --target=+test
builtin-args-test:
ENV EARTHLY_CI_RUNNER=true
DO +RUN_EARTHLY --earthfile=builtin-args.earth --target=+builtin-args-test
RUN sed -i "1s/VERSION \(.*\)/VERSION --arg-scope-and-set \1/" Earthfile
DO +RUN_EARTHLY --target=+builtin-args-test
RUN sed -i "1s/VERSION \(.*\)/VERSION --earthly-ci-runner-arg \1/" Earthfile
DO +RUN_EARTHLY --target=+earthly-ci-runner-builtin-arg-test --extra_args="--build-arg EXPECTED_VALUE=true"
ENV EARTHLY_CI_RUNNER=""
DO +RUN_EARTHLY --target=+earthly-ci-runner-builtin-arg-test --extra_args="--build-arg EXPECTED_VALUE=false"
ENV EARTHLY_CI_RUNNER="false"
DO +RUN_EARTHLY --target=+earthly-ci-runner-builtin-arg-test --extra_args="--build-arg EXPECTED_VALUE=false"
builtin-args-invalid-default-test:
DO +RUN_EARTHLY --earthfile=builtin-args-invalid-default.earth --should_fail=true --target=+test --output_contains="arg default value supplied for built-in ARG"
RUN sed -i "1s/VERSION \(.*\)/VERSION --arg-scope-and-set \1/" Earthfile
DO +RUN_EARTHLY --should_fail=true --target=+test --output_contains="arg default value supplied for built-in ARG"
builtin-args-invalid-pass-test:
DO +RUN_EARTHLY --earthfile=builtin-args-invalid-pass.earth --should_fail=true --target=+test --output_contains="value cannot be specified for built-in build arg EARTHLY_VERSION"
RUN sed -i "1s/VERSION \(.*\)/VERSION --arg-scope-and-set \1/" Earthfile
DO +RUN_EARTHLY --should_fail=true --target=+test --output_contains="value cannot be specified for built-in build arg EARTHLY_VERSION"
builtin-args-cli-tests:
DO +RUN_EARTHLY --earthfile=builtin-args.earth --should_fail=true --extra_args="--build-arg EARTHLY_VERSION=123" --target=+builtin-args-test \
--output_contains="cannot be passed on the command line"
RUN sed -i "1s/VERSION \(.*\)/VERSION --arg-scope-and-set \1/" Earthfile
DO +RUN_EARTHLY --should_fail=true --extra_args="--build-arg EARTHLY_VERSION=123" --target=+builtin-args-test \
--output_contains="cannot be passed on the command line"
parser-smoke-test:
DO +RUN_EARTHLY --earthfile=parser-smoke.earth --target=+test
excludes-test:
RUN touch exclude-me.txt
RUN touch do-not-exclude-me.txt
RUN echo 'exclude-me.txt' > .earthlyignore
DO +RUN_EARTHLY --earthfile=excludes.earth --target=+test
secrets-optional-prefix-test:
ENV SECRET1=foo
ENV SECRET2=wrong
RUN echo -n "secretfilecontents" > /root/my-secret-file
DO +RUN_EARTHLY \
--earthfile=secrets.earth \
--extra_args="--secret SECRET1 --secret SECRET2=bar --secret-file SECRET3=~/my-secret-file --build-arg SECRET_ID=\"\" --build-arg SECRET_ID_2=\"\"" \
--target=+test
secrets-test:
ENV SECRET1=foo
ENV SECRET2=wrong
RUN echo -n "secretfilecontents" > /root/my-secret-file
DO +RUN_EARTHLY \
--earthfile=secrets.earth \
--extra_args="--secret SECRET1 --secret SECRET2=bar --secret-file SECRET3=~/my-secret-file --build-arg SECRET_ID=\"\" --build-arg SECRET_ID_2=\"\"" \
--target=+test
DO +RUN_EARTHLY \
--earthfile=secrets.earth \
--extra_args="--secret SECRET1 --secret SECRET2=bar --build-arg SECRET_ID=\"\" --build-arg SECRET_ID_2=\"\"" \
--target=+test \
--should_fail=true \
--output_contains='unable to lookup secret \"SECRET3\": not found'
project-secrets-test:
DO +RUN_EARTHLY \
--earthfile=project-secrets-without-flag.earth \
--target=+without-flag \
--should_fail=true \
--output_contains="must be enabled in order to use PROJECT"
DO +RUN_EARTHLY \
--earthfile=project-secrets.earth \
--target=+local-override \
--extra_args="--secret foo/bar=override" \
--output_contains="my secret is override"
DO +RUN_EARTHLY \
--earthfile=project-secrets.earth \
--target=+basic \
--extra_args="--secret SECRET1=foo --secret SECRET2=bar" \
--output_contains="my secrets are foo and bar"
secrets-args-precedence-test:
DO +RUN_EARTHLY --earthfile=secrets-args-precedence.earth --target=+test --extra_args="--secret foo=eggs"
build-arg-test:
DO +RUN_EARTHLY --earthfile=build-arg.earth
build-arg-explicit-global-test:
DO +RUN_EARTHLY --earthfile=build-arg-explicit-global.earth --target=+test-success
DO +RUN_EARTHLY --should_fail=true --earthfile=build-arg-explicit-global.earth \
--target=+test-failure \
--output_contains="invalid ARG arguments.*: global ARG can only be set in the base target"
build-arg-dynamic-with-empty-base:
DO +RUN_EARTHLY --earthfile=build-arg-dynamic-with-empty-base.earth --target=+test
#this test only works under linux/amd64
user-arg-test:
DO +RUN_EARTHLY --earthfile=user-arg.earth
lc-test:
DO +RUN_EARTHLY --earthfile=lc.earth --target=+test
from-expose-test:
DO +RUN_EARTHLY --earthfile=from-expose.earth --extra_args="--no-output" --target=+test
scratch-test:
DO +RUN_EARTHLY --earthfile=scratch-test.earth --extra_args="--no-output" --target=+test
build-earthly-test:
# Test that build.earth is supported.
COPY parser-smoke.earth ./build.earth
RUN --privileged \
--entrypoint \
--mount=type=tmpfs,target=/tmp/earthly \
-- +test
host-bind-test:
RUN mkdir /bind-test
RUN echo "a" > /bind-test/a.txt
DO +RUN_EARTHLY --earthfile=host-bind.earth --target=+test
RUN test -f /bind-test/b.txt
RUN cat /bind-test/b.txt
remote-test:
ENV GIT_URL_INSTEAD_OF="https://github.com/=git@github.com:"
RUN --privileged \
--entrypoint \
--mount=type=tmpfs,target=/tmp/earthly \
-- --no-output github.com/earthly/hello-world:main+hello
RUN --privileged \
--entrypoint \
--mount=type=tmpfs,target=/tmp/earthly \
-- --no-output github.com/earthly/test-remote/privileged:main+locally && \
ls /tmp/hostname.3d4b1831-c07e-4b2d-805e-2b8ce578bb50
RUN --privileged \
--entrypoint \
--mount=type=tmpfs,target=/tmp/earthly \
-- --no-output github.com/earthly/test-remote/builtin-args:main+test
transitive-args-test:
DO +RUN_EARTHLY --earthfile=transitive-args.earth --extra_args="--build-arg SOMEARG=xyz" --target=+test
RUN ls
RUN test -f ./abc
RUN test -f ./xyz
RUN test ! -f ./default
RUN cat ./abc | acbgrep abc
RUN cat ./xyz | acbgrep xyz
transitive-args-test2:
DO +RUN_EARTHLY --earthfile=transitive-args.earth --target=+test
RUN ls
RUN test -f ./abc && test -f ./default
RUN cat ./abc | acbgrep abc
RUN cat ./default | acbgrep default
non-transitive-args-test:
COPY non-transitive-args1.earth ./Earthfile
COPY non-transitive-args2.earth ./subdir/Earthfile
# Should not override if transitive and crossing project boundaries.
RUN --privileged \
--entrypoint \
--mount=type=tmpfs,target=/tmp/earthly \
-- --build-arg SOMEARG=def +test
RUN ls ./subdir
RUN test -f ./subdir/default && test ! -f ./subdir/def && test ! -f ./subdir/abc
RUN rm ./subdir/default
# Should override, if override is direct.
RUN --privileged \
--entrypoint \
--mount=type=tmpfs,target=/tmp/earthly \
-- --build-arg SOMEARG=xyz ./subdir+arg-target
RUN ls ./subdir
RUN test -f ./subdir/xyz && test ! -f ./subdir/default
RUN --privileged \
--entrypoint \
--mount=type=tmpfs,target=/tmp/earthly \
-- +direct
RUN ls ./subdir
RUN test -f ./subdir/direct && test ! -f ./subdir/default
star-test:
RUN touch a.txt b.txt c.nottxt
DO +RUN_EARTHLY --earthfile=star.earth --target=+test
# TODO: This does not pass.
star-test-todo:
RUN touch a.txt b.txt c.nottxt
DO +RUN_EARTHLY --earthfile=star.earth --target=+test --use_tmpfs=false
RUN echo "a change" > c.nottxt
DO +RUN_EARTHLY --earthfile=star.earth --target=+test --use_tmpfs=false \
--post_command=">output.txt"
RUN cat output.txt
RUN cached_lines=$(cat output.txt | grep cached | wc -l); \
echo "cached_lines=$cached_lines"; \
test "$cached_lines" == "6"
dockerfile-test:
COPY dockerfile/* ./
RUN --privileged \
--entrypoint \
--mount=type=tmpfs,target=/tmp/earthly \
-- --allow-privileged --no-output +test-all
fail-test:
DO +RUN_EARTHLY --earthfile=fail.earth --should_fail=true --verbose=0 --target=+test --post_command="2>output.txt"
RUN cat output.txt
# The output of the failed command should have been printed twice.
RUN cat output.txt | grep 'ZmFpbCA3YjcyZTAyNC01ZTIxLTRlMWItOTZlNC02NTVjMzk4NzYxMDcK' | test "$(wc -l)" -eq 2
RUN cat output.txt | grep 'Repeating the failure error...'
RUN cat output.txt | grep 'ERROR Earthfile:10:4'
RUN cat output.txt | grep 'RUN echo "fail 7b72e024-5e21-4e1b-96e4-655c39876107" | base64; false'
RUN cat output.txt | grep 'did not complete successfully. Exit code 1'
DO +RUN_EARTHLY --earthfile=fail.earth --should_fail=true --verbose=0 --target=+test-copy --post_command="2>output.txt"
RUN cat output.txt
RUN cat output.txt | grep 'Repeating the failure error...'
RUN cat output.txt | grep 'ERROR Earthfile:14:4'
RUN cat output.txt | grep 'COPY ./does-not-exist ./'
RUN cat output.txt | grep 'failed: "/does-not-exist": not found'
RUN cat output.txt | grep 'Should not be reached'; test "$?" -eq 1
allow-privileged-test:
# test that privileged-tasks in remote repos dont run
DO +RUN_EARTHLY --earthfile=allow-privileged.earth --should_fail=true --extra_args="--allow-privileged" -target=+reject-privileged-in-remote-repo-triggered-by-from-locally
DO +RUN_EARTHLY --earthfile=allow-privileged.earth --should_fail=true --extra_args="--allow-privileged" -target=+reject-privileged-in-remote-repo-triggered-by-from-privileged
DO +RUN_EARTHLY --earthfile=allow-privileged.earth --should_fail=true --extra_args="--allow-privileged" -target=+reject-privileged-in-remote-repo-triggered-by-copy-locally
DO +RUN_EARTHLY --earthfile=allow-privileged.earth --should_fail=true --extra_args="--allow-privileged" -target=+reject-privileged-in-remote-repo-triggered-by-copy-privileged
DO +RUN_EARTHLY --earthfile=allow-privileged.earth --should_fail=true --extra_args="--allow-privileged" -target=+reject-privileged-in-remote-repo-triggered-by-build-locally
DO +RUN_EARTHLY --earthfile=allow-privileged.earth --should_fail=true --extra_args="--allow-privileged" -target=+reject-privileged-in-remote-repo-triggered-by-build-privileged
DO +RUN_EARTHLY --earthfile=allow-privileged.earth --should_fail=true --extra_args="--allow-privileged" -target=+reject-dedup
# test allowed-privileged tasks in remote repos work
DO +RUN_EARTHLY --earthfile=allow-privileged.earth --extra_args="--allow-privileged" --target=+allow-all
allow-privileged-import-test:
RUN mkdir -p a/really/deep/subdir && echo "VERSION 0.8
subdirprivileged:
FROM alpine:latest
RUN --privileged cat /proc/self/status | grep CapEff > output
SAVE ARTIFACT output proc-status
" > a/really/deep/subdir/Earthfile
DO +RUN_EARTHLY --earthfile=allow-privileged-import.earth --extra_args="--allow-privileged" --target=+test
reject-privileged-import-test:
DO +RUN_EARTHLY --earthfile=reject-privileged-import.earth --should_fail=true --extra_args="--allow-privileged" --target=+test-reject-copy
DO +RUN_EARTHLY --earthfile=reject-privileged-import.earth --should_fail=true --extra_args="--allow-privileged" --target=+test-reject-cmd
pass-args-test:
COPY pass-args-sub-dir.earth subdir/Earthfile
COPY pass-args-root.earth Earthfile
DO +RUN_EARTHLY --target=./subdir+test-all --extra_args="--build-arg foo=bar"
pass-args-defaults-test:
DO +RUN_EARTHLY --earthfile=pass-args-defaults.earth
# test arg can still be overridden from the cli
RUN sed -i 's/hello/hellofromcli/g' Earthfile
DO +RUN_EARTHLY --extra_args="--build-arg foo=hellofromcli"
pass-args-no-builtins-via-function-test:
DO +RUN_EARTHLY --earthfile=pass-args-no-builtins-via-function.earth --target=+test --output_contains="MY_FUNC IS OK"
required-arg-test:
# test that build arg is required
DO +RUN_EARTHLY --earthfile=required-args.earth --should_fail=true --target=+test-accept-valid-required-arg
# test parser rejects required arg with default value
DO +RUN_EARTHLY --earthfile=required-args.earth --should_fail=true --target=+test-reject-default-val-required-arg
DO +RUN_EARTHLY --earthfile=required-args.earth --should_fail=true --extra_args="--build-arg req=val" --target=+test-reject-default-val-required-arg
# test valid required arg with build-arg provided
DO +RUN_EARTHLY --earthfile=required-args.earth --extra_args="--build-arg req=val" --target=+test-accept-valid-required-arg
DO +RUN_EARTHLY --earthfile=required-args.earth --target=+test-accept-valid-required-arg-build-arg-in-earthfile
fail-push-test:
# test that an error code is correctly returned
DO +RUN_EARTHLY --earthfile=fail.earth --should_fail=true --verbose=0 --extra_args="--push" --target=+test-push \
--output_contains="this-too-will-fail"
fail-invalid-artifact-test:
# test that the artifact fails to be copied
DO +RUN_EARTHLY --earthfile=fail-invalid-artifact.earth --should_fail=true --target="--artifact +test/foo /tmp/stuff" \
--output_contains="cannot save artifact +test/foo, since it does not exist"
wildcard-all:
# wildcard BUILD tests
BUILD +wildcard-build
BUILD +wildcard-build-pwd
BUILD +wildcard-build-auto-skip
BUILD +wildcard-build-pwd-rel
BUILD +wildcard-build-rel-dir
BUILD +wildcard-build-remote
# wildcard COPY tests
BUILD +wildcard-copy
BUILD +wildcard-copy-pwd
BUILD +wildcard-copy-pwd-rel
BUILD +wildcard-copy-rel-dir
BUILD +wildcard-copy-remote
BUILD +wildcard-copy-with-flags
BUILD +wildcard-copy-multi
BUILD +wildcard-copy-with-args
wildcard-build:
COPY --dir wildcard .
DO +RUN_EARTHLY --earthfile=wildcard-build.earth --target=+wildcard-build
RUN cat earthly.output | acbgrep 'hello world 1'
RUN cat earthly.output | acbgrep 'hello world 2'
RUN cat earthly.output | acbgrep 'hello world 3'
RUN cat earthly.output | acbgrep -v 'not-test run'
DO +RUN_EARTHLY --earthfile=wildcard-build.earth --target=+wildcard-globstar --should_fail=true --output_contains="pattern not yet supported"
DO +RUN_EARTHLY --earthfile=wildcard-build.earth --target=+wildcard-glob
RUN cat earthly.output | acbgrep 'hello world 2'
RUN cat earthly.output | acbgrep 'hello world 3'
RUN cat earthly.output | acbgrep -v 'hello world 1'
RUN cat earthly.output | acbgrep -v 'not-test run'
wildcard-build-pwd:
COPY wildcard .
DO +RUN_EARTHLY --earthfile=wildcard-build.earth --target=+wildcard-build-pwd
RUN cat earthly.output | acbgrep 'hello world 1'
RUN cat earthly.output | acbgrep 'hello world 2'
RUN cat earthly.output | acbgrep 'hello world 3'
RUN cat earthly.output | acbgrep -v 'not-test run'
wildcard-build-auto-skip:
COPY wildcard .
DO +RUN_EARTHLY --earthfile=wildcard-build.earth --target=+wildcard-build-auto-skip
wildcard-build-pwd-rel:
COPY wildcard subdir
COPY wildcard-build.earth subdir/Earthfile
DO +RUN_EARTHLY --target=./subdir+wildcard-build-pwd
RUN cat earthly.output | acbgrep 'hello world 1'
RUN cat earthly.output | acbgrep 'hello world 2'
RUN cat earthly.output | acbgrep 'hello world 3'
RUN cat earthly.output | acbgrep -v 'not-test run'
wildcard-build-rel-dir:
WORKDIR /root/some-dir
RUN mkdir -p /tmp/other-dir
COPY wildcard /tmp/other-dir
DO +RUN_EARTHLY --earthfile=wildcard-build.earth --target=+wildcard-build-rel-dir
RUN cat earthly.output | acbgrep 'hello world 1'
RUN cat earthly.output | acbgrep 'hello world 2'
RUN cat earthly.output | acbgrep 'hello world 3'
RUN cat earthly.output | acbgrep -v 'not-test run'
wildcard-build-remote:
DO +RUN_EARTHLY --earthfile=wildcard-build.earth --target=+wildcard-remote
RUN cat earthly.output | acbgrep 'hello world 1'
RUN cat earthly.output | acbgrep 'hello world 2'
RUN cat earthly.output | acbgrep 'hello world 3'
RUN cat earthly.output | acbgrep -v 'not-test run'
DO +RUN_EARTHLY --earthfile=wildcard-build.earth --target=+wildcard-remote-glob
RUN cat earthly.output | acbgrep 'hello world 2'
RUN cat earthly.output | acbgrep 'hello world 3'
RUN cat earthly.output | acbgrep -v 'hello world 1'
RUN cat earthly.output | acbgrep -v 'not-test run'
wildcard-copy:
COPY --dir wildcard .
DO +RUN_EARTHLY --earthfile=wildcard-copy.earth --target=+wildcard-copy
RUN cat earthly.output | acbgrep -v 'not-test run'
DO +RUN_EARTHLY --earthfile=wildcard-copy.earth --target=+wildcard-globstar --should_fail=true --output_contains="pattern not yet supported"
DO +RUN_EARTHLY --earthfile=wildcard-copy.earth --target=+wildcard-glob
RUN cat earthly.output | acbgrep -v 'not-test run'
wildcard-copy-pwd:
COPY wildcard .
DO +RUN_EARTHLY --earthfile=wildcard-copy.earth --target=+wildcard-copy-pwd
RUN cat earthly.output | acbgrep -v 'not-test run'
wildcard-copy-pwd-rel:
COPY wildcard subdir
COPY wildcard-copy.earth subdir/Earthfile
DO +RUN_EARTHLY --target=./subdir+wildcard-copy-pwd
RUN cat earthly.output | acbgrep -v 'not-test run'
wildcard-copy-rel-dir:
WORKDIR /root/some-dir
RUN mkdir -p /tmp/other-dir
COPY wildcard /tmp/other-dir
DO +RUN_EARTHLY --earthfile=wildcard-copy.earth --target=+wildcard-copy-rel-dir
RUN cat earthly.output | acbgrep -v 'not-test run'
wildcard-copy-remote:
DO +RUN_EARTHLY --earthfile=wildcard-copy.earth --target=+wildcard-remote
RUN cat earthly.output | acbgrep -v 'not-test run'
DO +RUN_EARTHLY --earthfile=wildcard-copy.earth --target=+wildcard-remote-glob
RUN cat earthly.output | acbgrep -v 'not-test run'
wildcard-copy-with-flags:
COPY --dir wildcard .
DO +RUN_EARTHLY --earthfile=wildcard-copy.earth --target=+wildcard-if-exists
RUN cat earthly.output | acbgrep -v 'not-test run'
DO +RUN_EARTHLY --earthfile=wildcard-copy.earth --target=+wildcard-dir
RUN cat earthly.output | acbgrep -v 'not-test run'
DO +RUN_EARTHLY --earthfile=wildcard-copy.earth --target=+wildcard-with-artifact-args
RUN cat earthly.output | acbgrep -v 'not-test run'
DO +RUN_EARTHLY --earthfile=wildcard-copy.earth --target=+wildcard-multi-with-artifact-args
RUN cat earthly.output | acbgrep -v 'not-test run'
wildcard-copy-multi:
COPY --dir wildcard .
DO +RUN_EARTHLY --earthfile=wildcard-copy.earth --target=+wildcard-multi
RUN cat earthly.output | acbgrep -v 'not-test run'
DO +RUN_EARTHLY --earthfile=wildcard-copy.earth --target=+wildcard-multi-mix
RUN cat earthly.output | acbgrep -v 'not-test run'
DO +RUN_EARTHLY --earthfile=wildcard-copy.earth --target=+wildcard-multi-with-flags
RUN cat earthly.output | acbgrep -v 'not-test run'
wildcard-copy-with-args:
COPY --dir wildcard .
DO +RUN_EARTHLY --earthfile=wildcard-copy.earth --target=+wildcard-with-args
RUN cat earthly.output | acbgrep -v 'not-test run'
DO +RUN_EARTHLY --earthfile=wildcard-copy.earth --target=+wildcard-multi-with-args
RUN cat earthly.output | acbgrep -v 'not-test run'
push-test:
DO +RUN_EARTHLY --earthfile=push.earth --target=+push-test \
--output_contains="\(disabled\)"
DO +RUN_EARTHLY --earthfile=push.earth --extra_args="--push" --target=+push-test \
--output_contains="hello world"
push-arg-test:
DO +RUN_EARTHLY --earthfile=push-arg.earth --target=+push-test \
--output_contains="shoop"
DO +RUN_EARTHLY --earthfile=push-arg.earth --extra_args="--push" --target=+push-test \
--output_contains="real good"
push-arg-indirect-test:
DO +RUN_EARTHLY --earthfile=push-arg.earth --target=+indirect-test \
--output_contains="shoop"
DO +RUN_EARTHLY --earthfile=push-arg.earth --extra_args="--push" --target=+indirect-test \
--output_contains="shoop"
ci-arg-test:
DO +RUN_EARTHLY --earthfile=ci-arg.earth --target=+ci-test \
--output_contains="local environment"
DO +RUN_EARTHLY --earthfile=ci-arg.earth --extra_args="--ci" --target=+ci-test \
--output_contains="CI environment"
private-image-test:
FROM earthly/private-test:latest
RUN --entrypoint echo hello world
gen-dockerfile-test:
DO +RUN_EARTHLY --earthfile=gen-dockerfile.earth --extra_args="--no-output" --target=+all
comments-test:
DO +RUN_EARTHLY --earthfile=comments.earth --extra_args="--no-output" --target=+test
chown-test:
RUN echo "test" > ./a.txt
DO +RUN_EARTHLY --earthfile=chown.earth --target=+test
dotenv-test:
RUN echo "TEST_IN_DOTENV=this-should-not-appear-as-a-build-arg" >.env
DO +RUN_EARTHLY --earthfile=dotenv.earth --extra_args="--no-output" --target=+test-no-dotenv --output_contains="unexpected env .TEST_IN_DOTENV.: as of v0.7.0, --build-arg values must be defined in .arg"
RUN touch .arg
DO +RUN_EARTHLY --earthfile=dotenv.earth --extra_args="--no-output" --target=+test-no-dotenv --output_does_not_contain="unexpected env .TEST_IN_DOTENV.: as of v0.7.0, --build-arg values must be defined in .arg"
RUN echo "TEST_ARG_1=abracadabra" >.arg
RUN echo "TEST_SEC_2=foo" >.secret
RUN echo "TEST_ARG_3=bar" >>.arg
DO +RUN_EARTHLY --earthfile=dotenv.earth --extra_args="--no-output" --target=+test
# test non-standard .arg paths can be used
RUN mv .arg .some-other-arg
DO +RUN_EARTHLY --earthfile=dotenv.earth --extra_args="--no-output" --target=+test-no-dotenv
DO +RUN_EARTHLY --earthfile=dotenv.earth --extra_args="--no-output --arg-file-path .some-other-arg" --target=+test
DO +RUN_EARTHLY --earthfile=dotenv.earth --extra_args="--no-output" --pre_command="export EARTHLY_ARG_FILE_PATH=.some-other-arg" --target=+test
DO +RUN_EARTHLY --earthfile=dotenv.earth --extra_args="--no-output --arg-file-path .this-should-fail" --should_fail="true" --target=+test --output_contains="open .this-should-fail: no such file or directory"
DO +RUN_EARTHLY --earthfile=dotenv.earth --extra_args="--no-output" --pre_command="export EARTHLY_ARG_FILE_PATH=.this-too-should-fail" --should_fail="true" --target=+test --output_contains="open .this-too-should-fail: no such file or directory"
# --env-file takes precedence
DO +RUN_EARTHLY --earthfile=dotenv.earth --extra_args="--no-output --arg-file-path .some-other-arg" --pre_command="export EARTHLY_ARG_FILE_PATH=.this-should-be-ignored" --target=+test
# test .secret can be renamed
RUN mv .secret .some-other-secret
DO +RUN_EARTHLY --earthfile=dotenv.earth --extra_args="--no-output --arg-file-path .some-other-arg --secret-file-path .some-other-secret" --target=+test
# test .env values still affect earthly cli
RUN echo EARTHLY_PUSH=1 > .env
DO +RUN_EARTHLY --earthfile=dotenv.earth --extra_args="--no-output" --target=+test-with-push
RUN mv .env .some-other-env
DO +RUN_EARTHLY --earthfile=dotenv.earth --extra_args="--no-output" --target=+test-no-push
DO +RUN_EARTHLY --earthfile=dotenv.earth --extra_args="--no-output --env-file-path .some-other-env" --target=+test-with-push
stack-failure-test:
RUN echo "TEST_ARG_1=abracadabra" >.arg
RUN echo "TEST_ARG_2=foo" >>.arg
RUN echo "THIS_IS_SECRET=dont-display-this" >>.secret
RUN echo "THIS_IS_ALSO_A_SECRET=dont-display-this-either" >>.env # test for user accidentally putting a secret in .env (carried over from a v0.6.0 .env file)
# test that only declared ARGs are displayed in output (and non-referenced .arg values which may actually be secrets aren't)
DO +RUN_EARTHLY --earthfile=stack-failure.earth --extra_args="--no-output" --output_contains="unknown flag .cause-interpreter-failure." --should_fail="true" --target=+fail
RUN if grep dont-display-this earthly.output; then echo "secret was leaked!"; exit 1; fi
RUN grep 'in.*+fail --TEST_ARG_1=abracadabra --TEST_ARG_2=foo' earthly.output
# test missing target doesn't leak secret
DO +RUN_EARTHLY --earthfile=stack-failure.earth --extra_args="--no-output" --output_contains="target this-does-not-exist not found" --should_fail="true" --target=+this-does-not-exist
RUN if grep dont-display-this earthly.output; then echo "secret was leaked!"; exit 1; fi
multi-stack-failure-test:
RUN echo "FOO=foo" >.arg
RUN echo "THIS_IS_SECRET=dont-display-this" >>.secret
RUN echo "THIS_IS_ALSO_A_SECRET=dont-display-this-either" >>.env # test for user accidentally putting a secret in .env (carried over from a v0.6.0 .env file)
DO +RUN_EARTHLY --earthfile=multi-stack-failure.earth --extra_args="--no-output --build-arg BAR=bar" --output_contains="unknown flag .cause-interpreter-failure." --should_fail="true" --target=+fail
RUN if grep dont-display-this earthly.output; then echo "secret was leaked!"; exit 1; fi
RUN grep 'in.*+fail --BAR=bar --EMPTY= --FOO=foo' earthly.output
DO +RUN_EARTHLY --earthfile=multi-stack-failure.earth --extra_args="--no-output --build-arg BAR=bar --build-arg ANOTHER_ARG=another-value" --output_contains="unknown flag .cause-interpreter-failure." --should_fail="true" --target=+from-fail
RUN if grep dont-display-this earthly.output; then echo "secret was leaked!"; exit 1; fi
RUN grep 'in.*+fail --BAR=bar --EMPTY= --FOO=foo' earthly.output
RUN grep 'in.*+from-fail --ANOTHER_ARG=another-value' earthly.output
env-test:
DO +RUN_EARTHLY --earthfile=env.earth --extra_args="--no-output" --target=+test
env-home-test:
DO +RUN_EARTHLY --earthfile=env-home.earth --extra_args="--secret sshkey=not-actually-a-ssh-key --no-output" --target=+test
no-cache-local-artifact-test:
DO +RUN_EARTHLY --earthfile=no-cache-local-artifact.earth --use_tmpfs=false --extra_args="--no-cache" --target=+test
RUN mv file.txt old.txt
DO +RUN_EARTHLY --earthfile=no-cache-local-artifact.earth --use_tmpfs=false --extra_args="--no-cache" --target=+test
RUN ! diff file.txt old.txt
empty-git-test:
RUN git init
DO +RUN_EARTHLY --earthfile=empty-git.earth --extra_args="--no-output" --target=+test-empty
RUN git remote add origin https://github.com/earthly/earthly.git
DO +RUN_EARTHLY --earthfile=empty-git.earth --extra_args="--no-output" --target=+test-origin-no-hash
escape-test:
RUN printf "content" >file-with-+.txt
RUN printf "content" >regular-file.txt
DO +RUN_EARTHLY --earthfile=escape.earth
escape-dir-test:
RUN mkdir ./dir-with-+-in-it
COPY escape-dir2.earth ./dir-with-+-in-it/Earthfile
DO +RUN_EARTHLY --earthfile=escape-dir1.earth --extra_args="--no-output" --target=+test
eine-test-base:
FROM docker:19.03.12-dind
RUN apk --update --no-cache add git
COPY ../..+earthly/earthly /usr/local/bin/
ENV EARTHLY_BUILDKIT_IMAGE=earthly/buildkitd:dind-test
WORKDIR /test
eine-smoke-test:
FROM +eine-test-base
COPY parser-smoke.earth ./Earthfile
WITH DOCKER --load earthly/buildkitd:dind-test=../../buildkitd+buildkitd
RUN earthly +test
END
eine-privileged-test:
FROM +eine-test-base
COPY privileged.earth ./Earthfile
WITH DOCKER --load earthly/buildkitd:dind-test=../../buildkitd+buildkitd
RUN earthly --allow-privileged +test
END
target-first-line:
DO +RUN_EARTHLY --earthfile=target-first-line.earth --extra_args="--no-output" --target=+test
absolute-reference-with-relative:
RUN mkdir -p /a/path/to/test/subdir
# create a base Earthfile which is referenced by target-absolute-reference.earth
RUN echo -e "VERSION 0.8\nFROM alpine:3.18\nRUN mkdir -p /dir/from/base" > /a/path/to/test/Earthfile
DO +RUN_EARTHLY --earthfile=absolute-reference-with-relative.earth --earthfile_dest=/a/path/to/test/subdir/Earthfile --extra_args="--no-output" --target=/a/path/to/test/subdir+test
end-comment:
DO +RUN_EARTHLY --earthfile=end-comment.earth --target=+test
if-exists:
DO +RUN_EARTHLY --earthfile=if-exists.earth --target=+save-exist-local
DO +RUN_EARTHLY --earthfile=if-exists.earth --should_fail=true --target=+save-not-exist \
--output_contains="save-not-exist"
DO +RUN_EARTHLY --earthfile=if-exists.earth --should_fail=true --target=+copy-not-exist \
--output_contains="copy-not-exist"
DO +RUN_EARTHLY --earthfile=if-exists.earth --should_fail=true --target=+bad-wildcard-copy \
--output_contains="bad-wildcard-copy"
DO +RUN_EARTHLY --earthfile=if-exists.earth --should_fail=true --target=+bad-wildcard-save \
--output_contains="bad-wildcard-save"
DO +RUN_EARTHLY --earthfile=if-exists.earth --target=+artifact-copy-exists
DO +RUN_EARTHLY --earthfile=if-exists.earth --target=+artifact-copy-not-exist
DO +RUN_EARTHLY --earthfile=if-exists.earth --target=+artifact-copy-not-exist-wildcard
RUN mkdir in && \
echo "this-file-does-exist" > ./in/this-file-does-exist && \
echo "so-does-this-one" > so-does-this-one
DO +RUN_EARTHLY --earthfile=if-exists.earth --target=+classic-copy-exists
DO +RUN_EARTHLY --earthfile=if-exists.earth --target=+classic-copy-not-exist
file-copying:
DO +RUN_EARTHLY --earthfile=file-copying.earth
RUN find out-glob -printf '%P\n' | sort > result-glob
RUN ls -la out-glob
RUN diff -ws expected-glob result-glob
RUN find out-dot -printf '%P\n' | sort > result-dot
RUN ls -la out-dot
RUN diff -ws expected-dot result-dot
RUN find out-dot-slash -printf '%P\n' | sort > result-dot-slash
RUN ls -la out-dot-slash
RUN diff -ws expected-dot-slash result-dot-slash
RUN find out-sub -printf '%P\n' | sort > result-sub
RUN ls -la out-sub
RUN diff -ws expected-sub result-sub
RUN find out-sub-glob -printf '%P\n' | sort > result-sub-glob
RUN ls -la out-sub-glob
RUN diff -ws expected-sub-glob result-sub-glob
RUN find out-dot-single -printf '%P\n' | sort > result-dot-single
RUN ls -la out-dot-single
RUN diff -ws expected-dot-single result-dot-single
RUN find out-rel-single -printf '%P\n' | sort > result-rel-single
RUN ls -la out-rel-single
RUN diff -ws expected-rel-single result-rel-single
RUN find out-src-dest-file-rename -printf '%P\n' | sort > result-src-dest-file-rename
RUN ls -la out-src-dest-file-rename
RUN diff -ws expected-src-dest-file-rename result-src-dest-file-rename
RUN find out-src-dest-dir-rename -printf '%P\n' | sort > result-src-dest-dir-rename
RUN ls -la out-src-dest-dir-rename
RUN diff -ws expected-src-dest-dir-rename result-src-dest-dir-rename