diff --git a/tests/helpers.bash b/tests/helpers.bash index 057dd9d4..8d52cd0a 100644 --- a/tests/helpers.bash +++ b/tests/helpers.bash @@ -10,3 +10,8 @@ common_setup() { DAGGER_STORE="$(mktemp -d -t dagger-store-XXXXXX)" export DAGGER_STORE } + +skip_unless_secrets_available() { + local inputFile="$1" + sops exec-file "$inputFile" echo > /dev/null 2>&1 || skip "$inputFile cannot be decrypted" +} diff --git a/tests/llb/copy/valid/component/main.cue b/tests/llb/copy/valid/component/main.cue deleted file mode 100644 index 99e0139f..00000000 --- a/tests/llb/copy/valid/component/main.cue +++ /dev/null @@ -1,65 +0,0 @@ -package testing - -component: #up: [{ - do: "fetch-container" - ref: "alpine" -}, { - do: "exec" - args: ["sh", "-c", """ - printf lol > /id - """] - dir: "/" -}] - -test1: { - string - - #up: [ - { - do: "fetch-container" - ref: "busybox" - }, - { - do: "copy" - from: component - src: "/id" - dest: "/" - }, - { - do: "export" - source: "/id" - format: "string" - }, - ] -} - -test2: { - string - - #up: [ - { - do: "fetch-container" - ref: "busybox" - }, - { - do: "copy" - from: #up: [{ - do: "fetch-container" - ref: "alpine" - }, { - do: "exec" - args: ["sh", "-c", """ - printf lol > /id - """] - dir: "/" - }] - src: "/id" - dest: "/" - }, - { - do: "export" - source: "/id" - format: "string" - }, - ] -} diff --git a/tests/llb/copy/valid/script/main.cue b/tests/llb/copy/valid/script/main.cue deleted file mode 100644 index 0f6bb202..00000000 --- a/tests/llb/copy/valid/script/main.cue +++ /dev/null @@ -1,23 +0,0 @@ -package testing - -test: { - string - - #up: [ - { - do: "fetch-container" - ref: "busybox" - }, - { - do: "copy" - from: [{do: "fetch-container", ref: "alpine"}] - src: "/etc/issue" - dest: "/" - }, - { - do: "export" - source: "/issue" - format: "string" - }, - ] -} diff --git a/tests/llb/exec/exit_code/main.cue b/tests/llb/exec/exit_code/main.cue deleted file mode 100644 index 385392eb..00000000 --- a/tests/llb/exec/exit_code/main.cue +++ /dev/null @@ -1,14 +0,0 @@ -package testing - -#up: [ - { - do: "fetch-container" - ref: "alpine" - }, - { - do: "exec" - args: ["sh", "-c", "exit 123"] - // XXX Blocked by https://github.com/blocklayerhq/dagger/issues/19 - dir: "/" - }, -] diff --git a/tests/llb/exec/invalid/main.cue b/tests/llb/exec/invalid/main.cue deleted file mode 100644 index 577e3544..00000000 --- a/tests/llb/exec/invalid/main.cue +++ /dev/null @@ -1,11 +0,0 @@ -package testing - -#up: [ - { - do: "fetch-container" - ref: "alpine" - }, - { - do: "exec" - }, -] diff --git a/tests/llb/fetch-container/invalid/main.cue b/tests/llb/fetch-container/invalid/main.cue deleted file mode 100644 index 9a41348e..00000000 --- a/tests/llb/fetch-container/invalid/main.cue +++ /dev/null @@ -1,7 +0,0 @@ -package testing - -#up: [ - { - do: "fetch-container" - }, -] diff --git a/tests/llb/fetch-container/nonexistent/image/main.cue b/tests/llb/fetch-container/nonexistent/image/main.cue deleted file mode 100644 index c85f89ce..00000000 --- a/tests/llb/fetch-container/nonexistent/image/main.cue +++ /dev/null @@ -1,8 +0,0 @@ -package testing - -#up: [ - { - do: "fetch-container" - ref: "doesnotexist" - }, -] diff --git a/tests/llb/fetch-git/invalid/main.cue b/tests/llb/fetch-git/invalid/main.cue deleted file mode 100644 index 4157da11..00000000 --- a/tests/llb/fetch-git/invalid/main.cue +++ /dev/null @@ -1,7 +0,0 @@ -package testing - -#up: [ - { - do: "fetch-git" - }, -] diff --git a/tests/llb/load/invalid/cache/main.cue b/tests/llb/load/invalid/cache/main.cue deleted file mode 100644 index f13957d7..00000000 --- a/tests/llb/load/invalid/cache/main.cue +++ /dev/null @@ -1,33 +0,0 @@ -package testing - -test1: { - string - - #up: [ - { - do: "load" - from: [{do: "fetch-container", ref: "alpine"}] - }, - { - do: "export" - source: "/etc/issue" - format: "string" - }, - ] -} - -test2: { - string - - #up: [ - { - do: "load" - from: [{do: "fetch-container", ref: "busybox"}] - }, - { - do: "export" - source: "/etc/issue" - format: "string" - }, - ] -} diff --git a/tests/llb/load/valid/component/main.cue b/tests/llb/load/valid/component/main.cue deleted file mode 100644 index a9fa7341..00000000 --- a/tests/llb/load/valid/component/main.cue +++ /dev/null @@ -1,53 +0,0 @@ -package testing - -component: #up: [{ - do: "fetch-container" - ref: "alpine" -}, { - do: "exec" - args: ["sh", "-c", """ - printf lol > /id - """] - dir: "/" -}] - -test1: { - string - - #up: [ - { - do: "load" - from: component - }, - { - do: "export" - source: "/id" - format: "string" - }, - ] -} - -test2: { - string - - #up: [ - { - do: "load" - from: #up: [{ - do: "fetch-container" - ref: "alpine" - }, { - do: "exec" - args: ["sh", "-c", """ - printf lol > /id - """] - dir: "/" - }] - }, - { - do: "export" - source: "/id" - format: "string" - }, - ] -} diff --git a/tests/llb/load/valid/script/main.cue b/tests/llb/load/valid/script/main.cue deleted file mode 100644 index d009ab66..00000000 --- a/tests/llb/load/valid/script/main.cue +++ /dev/null @@ -1,17 +0,0 @@ -package testing - -test: { - string - - #up: [ - { - do: "load" - from: [{do: "fetch-container", ref: "alpine"}] - }, - { - do: "export" - source: "/etc/issue" - format: "string" - }, - ] -} diff --git a/tests/ops.bats b/tests/ops.bats new file mode 100644 index 00000000..f3f6be81 --- /dev/null +++ b/tests/ops.bats @@ -0,0 +1,215 @@ +setup() { + load 'helpers' + + common_setup +} + +@test "op.#Load" { + run "$DAGGER" compute "$TESTDIR"/ops/load/valid/component + assert_success + assert_line '{"component":{},"test1":"lol","test2":"lol"}' + + "$DAGGER" compute "$TESTDIR"/ops/load/valid/script + + run "$DAGGER" compute "$TESTDIR"/ops/load/invalid/cache + assert_failure +} + +@test "op.#Mount" { + # tmpfs + "$DAGGER" compute "$TESTDIR"/ops/mounts/valid/tmpfs + + # cache + "$DAGGER" compute "$TESTDIR"/ops/mounts/valid/cache + + # component + run "$DAGGER" compute "$TESTDIR"/ops/mounts/valid/component + assert_success + assert_line '{"test":"hello world"}' + + # FIXME https://github.com/blocklayerhq/dagger/issues/46 + # "$DAGGER" compute "$TESTDIR"/ops/mounts/valid/script +} + +@test "op.#Copy" { + run "$DAGGER" compute "$TESTDIR"/ops/copy/valid/component + assert_success + assert_line '{"component":{},"test1":"lol","test2":"lol"}' + + "$DAGGER" compute "$TESTDIR"/ops/copy/valid/script + + # FIXME https://github.com/blocklayerhq/dagger/issues/44 + # run "$DAGGER" compute "$TESTDIR"/ops/copy/invalid/cache + # assert_failure +} + +@test "op.#Local" { + skip "There are no local tests right now (the feature is possibly not functioning at all: see https://github.com/blocklayerhq/dagger/issues/41)" +} + +@test "op.#FetchContainer" { + # non existent container image" + run "$DAGGER" compute "$TESTDIR"/ops/fetch-container/nonexistent/image + assert_failure + + # non existent container tag + run "$DAGGER" compute "$TESTDIR"/ops/fetch-container/nonexistent/tag + assert_failure + + # non existent container digest + run "$DAGGER" compute "$TESTDIR"/ops/fetch-container/nonexistent/digest + assert_failure + + # valid containers + run "$DAGGER" compute "$TESTDIR"/ops/fetch-container/exist + assert_success + + # missing ref + # FIXME: distinguish missing inputs from incorrect config + # run "$DAGGER" compute "$TESTDIR"/ops/fetch-container/invalid + # assert_failure + + # non existent container image with valid digest + # FIXME https://github.com/blocklayerhq/dagger/issues/32 + # run "$DAGGER" compute "$TESTDIR"/ops/fetch-container/nonexistent/image-with-valid-digest + # assert_failure +} + +@test "op.#PushContainer" { + skip_unless_secrets_available "$TESTDIR"/ops/push-container/inputs.yaml + + "$DAGGER" compute --input-yaml "$TESTDIR"/ops/push-container/inputs.yaml "$TESTDIR"/ops/push-container +} + +@test "op.#FetchGit" { + run "$DAGGER" compute "$TESTDIR"/ops/fetch-git/exist + assert_success + + run "$DAGGER" compute "$TESTDIR"/ops/fetch-git/nonexistent/remote + assert_failure + + run "$DAGGER" compute "$TESTDIR"/ops/fetch-git/nonexistent/ref + assert_failure + + run "$DAGGER" compute "$TESTDIR"/ops/fetch-git/nonexistent/bork + assert_failure + + # FIXME: distinguish missing inputs from incorrect config + # run "$DAGGER" compute "$TESTDIR"/ops/fetch-git/invalid + # assert_failure +} + +@test "op.#Exec" { + run "$DAGGER" compute "$TESTDIR"/ops/exec/invalid + assert_failure + + run "$DAGGER" compute "$TESTDIR"/ops/exec/error + assert_failure + + run "$DAGGER" compute "$TESTDIR"/ops/exec/simple + assert_success + + # XXX should run twice and test that the string "always output" is visible with DOCKER_OUTPUT=1 + # Alternatively, use export, but this would test multiple things then... + run "$DAGGER" compute "$TESTDIR"/ops/exec/always + assert_success + + run "$DAGGER" compute "$TESTDIR"/ops/exec/env/invalid + assert_failure + + run "$DAGGER" compute "$TESTDIR"/ops/exec/env/valid + assert_success + + run "$DAGGER" compute --input-string 'bar=overlay environment' "$TESTDIR"/ops/exec/env/overlay + assert_success + + run "$DAGGER" compute "$TESTDIR"/ops/exec/dir/doesnotexist + assert_success + + run "$DAGGER" compute "$TESTDIR"/ops/exec/dir/exist + assert_success + + + run "$DAGGER" compute "$TESTDIR"/ops/exec/undefined/non_concrete_referenced + assert_success + assert_line '{"hello":"world"}' + + # NOTE: the exec is meant to fail - and we test that as a way to confirm it has been executed + run "$DAGGER" compute "$TESTDIR"/ops/exec/undefined/non_concrete_not_referenced + assert_failure + + # package with optional def, not referenced, should be executed + run "$DAGGER" compute "$TESTDIR"/ops/exec/undefined/with_pkg_def + assert_success + + # script with optional prop, not referenced, should be executed + run "$DAGGER" compute "$TESTDIR"/ops/exec/undefined/with_pkg_optional + assert_success + + # FIXME https://github.com/blocklayerhq/dagger/issues/74 + # run "$DAGGER" compute "$TESTDIR"/ops/exec/exit_code + # assert_failure # --exit=123 + + # script with non-optional prop, not referenced, should be executed + # FIXME https://github.com/blocklayerhq/dagger/issues/70 + # run "$DAGGER" compute "$TESTDIR"/ops/exec/undefined/with_pkg_mandatory + # assert_failure +} + +@test "op.#Export" { + run "$DAGGER" compute "$TESTDIR"/ops/export/json + assert_success + assert_line '{"testMap":{"something":"something"},"testScalar":true}' + + run "$DAGGER" compute "$TESTDIR"/ops/export/string + assert_success + assert_line '{"test":"something"}' + + run "$DAGGER" compute "$TESTDIR"/ops/export/withvalidation + assert_success + assert_line '{"test":"something"}' + + run "$DAGGER" compute "$TESTDIR"/ops/export/concurrency + assert_success + + # does not pass additional validation + run "$DAGGER" compute "$TESTDIR"/ops/export/invalid/validation + assert_failure + + # invalid format + run "$DAGGER" compute "$TESTDIR"/ops/export/invalid/format + assert_failure + + # invalid path + run "$DAGGER" compute "$TESTDIR"/ops/export/invalid/path + assert_failure + + + run "$DAGGER" compute "$TESTDIR"/ops/export/float + assert_success + assert_line '{"test":-123.5}' + + run "$DAGGER" compute "$TESTDIR"/ops/export/yaml + assert_success + assert_line '{"testMap":{"something":"something"},"testScalar":true}' + + run "$DAGGER" compute "$TESTDIR"/ops/export/bool + assert_success + assert_line '{"test":true}' + + # FIXME: https://github.com/blocklayerhq/dagger/issues/96 + # run "$DAGGER" compute "$TESTDIR"/ops/export/number + # assert_success + # assert_line '{"test":-123.5}' +} + +@test "op.#Subdir" { + run "$DAGGER" compute "$TESTDIR"/ops/subdir/simple + assert_success + assert_line '{"hello":"world"}' +} + +@test "op.#DockerBuild" { + run "$DAGGER" compute --input-dir TestData="$TESTDIR"/ops/dockerbuild/testdata "$TESTDIR"/ops/dockerbuild + assert_success +} diff --git a/tests/llb/copy/invalid/cache/main.cue b/tests/ops/copy/invalid/cache/main.cue similarity index 51% rename from tests/llb/copy/invalid/cache/main.cue rename to tests/ops/copy/invalid/cache/main.cue index 9f15e987..3438a216 100644 --- a/tests/llb/copy/invalid/cache/main.cue +++ b/tests/ops/copy/invalid/cache/main.cue @@ -1,21 +1,24 @@ package testing +import "dagger.io/dagger/op" + test1: { string #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "busybox" }, - { - do: "copy" - from: [{do: "fetch-container", ref: "alpine"}] + op.#Copy & { + from: [ + op.#FetchContainer & { + ref: "alpine" + }, + ] src: "/etc/issue" dest: "/" }, - { - do: "export" + op.#Export & { source: "/issue" format: "string" }, @@ -26,18 +29,19 @@ test2: { string #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "busybox" }, - { - do: "copy" - from: [{do: "fetch-container", ref: "busybox"}] + op.#Copy & { + from: [ + op.#FetchContainer & { + ref: "busybox" + }, + ] src: "/etc/issue" dest: "/" }, - { - do: "export" + op.#Export & { source: "/issue" format: "string" }, diff --git a/tests/ops/copy/valid/component/main.cue b/tests/ops/copy/valid/component/main.cue new file mode 100644 index 00000000..ec793f21 --- /dev/null +++ b/tests/ops/copy/valid/component/main.cue @@ -0,0 +1,61 @@ +package testing + +import "dagger.io/dagger/op" + +component: #up: [ + op.#FetchContainer & { + ref: "alpine" + }, + op.#Exec & { + args: ["sh", "-c", """ + printf lol > /id + """] + }, +] + +test1: { + string + + #up: [ + op.#FetchContainer & { + ref: "busybox" + }, + op.#Copy & { + from: component + src: "/id" + dest: "/" + }, + op.#Export & { + source: "/id" + format: "string" + }, + ] +} + +test2: { + string + + #up: [ + op.#FetchContainer & { + ref: "busybox" + }, + op.#Copy & { + from: #up: [ + op.#FetchContainer & { + ref: "alpine" + }, + op.#Exec & { + args: ["sh", "-c", """ + printf lol > /id + """] + }, + ] + src: "/id" + dest: "/" + }, + op.#Export & { + source: "/id" + format: "string" + }, + ] +} diff --git a/tests/ops/copy/valid/script/main.cue b/tests/ops/copy/valid/script/main.cue new file mode 100644 index 00000000..fc21340b --- /dev/null +++ b/tests/ops/copy/valid/script/main.cue @@ -0,0 +1,26 @@ +package testing + +import "dagger.io/dagger/op" + +test: { + string + + #up: [ + op.#FetchContainer & { + ref: "busybox" + }, + op.#Copy & { + from: [ + op.#FetchContainer & { + ref: "alpine" + }, + ] + src: "/etc/issue" + dest: "/" + }, + op.#Export & { + source: "/issue" + format: "string" + }, + ] +} diff --git a/tests/llb/dockerbuild/main.cue b/tests/ops/dockerbuild/main.cue similarity index 100% rename from tests/llb/dockerbuild/main.cue rename to tests/ops/dockerbuild/main.cue diff --git a/tests/llb/dockerbuild/testdata/Dockerfile b/tests/ops/dockerbuild/testdata/Dockerfile similarity index 100% rename from tests/llb/dockerbuild/testdata/Dockerfile rename to tests/ops/dockerbuild/testdata/Dockerfile diff --git a/tests/llb/dockerbuild/testdata/dockerfilepath/Dockerfile.custom b/tests/ops/dockerbuild/testdata/dockerfilepath/Dockerfile.custom similarity index 100% rename from tests/llb/dockerbuild/testdata/dockerfilepath/Dockerfile.custom rename to tests/ops/dockerbuild/testdata/dockerfilepath/Dockerfile.custom diff --git a/tests/llb/dockerbuild/testdata/foo b/tests/ops/dockerbuild/testdata/foo similarity index 100% rename from tests/llb/dockerbuild/testdata/foo rename to tests/ops/dockerbuild/testdata/foo diff --git a/tests/llb/exec/always/main.cue b/tests/ops/exec/always/main.cue similarity index 59% rename from tests/llb/exec/always/main.cue rename to tests/ops/exec/always/main.cue index 208717ef..dad2f1b4 100644 --- a/tests/llb/exec/always/main.cue +++ b/tests/ops/exec/always/main.cue @@ -1,12 +1,12 @@ package testing +import "dagger.io/dagger/op" + #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "exec" + op.#Exec & { args: ["echo", "always output"] always: true }, diff --git a/tests/llb/exec/dir/doesnotexist/main.cue b/tests/ops/exec/dir/doesnotexist/main.cue similarity index 73% rename from tests/llb/exec/dir/doesnotexist/main.cue rename to tests/ops/exec/dir/doesnotexist/main.cue index d8198555..adcb9f80 100644 --- a/tests/llb/exec/dir/doesnotexist/main.cue +++ b/tests/ops/exec/dir/doesnotexist/main.cue @@ -1,12 +1,12 @@ package testing +import "dagger.io/dagger/op" + #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", """ echo "pwd is: $(pwd)" [ "$(pwd)" == "/thisisnonexistent" ] || exit 1 diff --git a/tests/llb/exec/dir/exist/main.cue b/tests/ops/exec/dir/exist/main.cue similarity index 70% rename from tests/llb/exec/dir/exist/main.cue rename to tests/ops/exec/dir/exist/main.cue index 2049c10f..28e74fa2 100644 --- a/tests/llb/exec/dir/exist/main.cue +++ b/tests/ops/exec/dir/exist/main.cue @@ -1,12 +1,12 @@ package testing +import "dagger.io/dagger/op" + #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", """ echo "pwd is: $(pwd)" [ "$(pwd)" == "/etc" ] || exit 1 diff --git a/tests/llb/exec/env/invalid/main.cue b/tests/ops/exec/env/invalid/main.cue similarity index 64% rename from tests/llb/exec/env/invalid/main.cue rename to tests/ops/exec/env/invalid/main.cue index 1e1950f1..e9c5a331 100644 --- a/tests/llb/exec/env/invalid/main.cue +++ b/tests/ops/exec/env/invalid/main.cue @@ -1,12 +1,12 @@ package testing +import "dagger.io/dagger/op" + #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", #""" echo "$foo" """#] diff --git a/tests/llb/exec/env/overlay/main.cue b/tests/ops/exec/env/overlay/main.cue similarity index 72% rename from tests/llb/exec/env/overlay/main.cue rename to tests/ops/exec/env/overlay/main.cue index d3c8c3c4..35e8bfc3 100644 --- a/tests/llb/exec/env/overlay/main.cue +++ b/tests/ops/exec/env/overlay/main.cue @@ -1,14 +1,14 @@ package testing +import "dagger.io/dagger/op" + bar: string #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", """ echo "foo: $foo" [ "$foo" == "overlay environment" ] || exit 1 diff --git a/tests/llb/exec/env/valid/main.cue b/tests/ops/exec/env/valid/main.cue similarity index 73% rename from tests/llb/exec/env/valid/main.cue rename to tests/ops/exec/env/valid/main.cue index 6b0cd61e..b378e4c1 100644 --- a/tests/llb/exec/env/valid/main.cue +++ b/tests/ops/exec/env/valid/main.cue @@ -1,12 +1,13 @@ package testing +import "dagger.io/dagger/op" + #up: [ - { + op.#FetchContainer & { do: "fetch-container" ref: "alpine" }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", """ [ "$foo" == "output environment" ] || exit 1 """] diff --git a/tests/llb/exec/error/main.cue b/tests/ops/exec/error/main.cue similarity index 52% rename from tests/llb/exec/error/main.cue rename to tests/ops/exec/error/main.cue index 72cf9469..8347c5ae 100644 --- a/tests/llb/exec/error/main.cue +++ b/tests/ops/exec/error/main.cue @@ -1,12 +1,12 @@ package testing +import "dagger.io/dagger/op" + #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "exec" + op.#Exec & { args: ["erroringout"] }, ] diff --git a/tests/ops/exec/exit_code/main.cue b/tests/ops/exec/exit_code/main.cue new file mode 100644 index 00000000..d83a1e77 --- /dev/null +++ b/tests/ops/exec/exit_code/main.cue @@ -0,0 +1,12 @@ +package testing + +import "dagger.io/dagger/op" + +#up: [ + op.#FetchContainer & { + ref: "alpine" + }, + op.#Exec & { + args: ["sh", "-c", "exit 123"] + }, +] diff --git a/tests/ops/exec/invalid/main.cue b/tests/ops/exec/invalid/main.cue new file mode 100644 index 00000000..e1feea27 --- /dev/null +++ b/tests/ops/exec/invalid/main.cue @@ -0,0 +1,11 @@ +package testing + +import "dagger.io/dagger/op" + +#up: [ + op.#FetchContainer & { + ref: "alpine" + }, + op.#Exec & { + }, +] diff --git a/tests/llb/exec/simple/main.cue b/tests/ops/exec/simple/main.cue similarity index 55% rename from tests/llb/exec/simple/main.cue rename to tests/ops/exec/simple/main.cue index 5166e3d2..4ec86863 100644 --- a/tests/llb/exec/simple/main.cue +++ b/tests/ops/exec/simple/main.cue @@ -1,12 +1,12 @@ package testing +import "dagger.io/dagger/op" + #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "exec" + op.#Exec & { args: ["echo", "simple output"] }, ] diff --git a/tests/llb/exec/undefined/non_concrete_not_referenced/main.cue b/tests/ops/exec/undefined/non_concrete_not_referenced/main.cue similarity index 78% rename from tests/llb/exec/undefined/non_concrete_not_referenced/main.cue rename to tests/ops/exec/undefined/non_concrete_not_referenced/main.cue index d0aa3d65..85b6a817 100644 --- a/tests/llb/exec/undefined/non_concrete_not_referenced/main.cue +++ b/tests/ops/exec/undefined/non_concrete_not_referenced/main.cue @@ -1,15 +1,15 @@ package testing +import "dagger.io/dagger/op" + hello: "world" bar: string #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "exec" + op.#Exec & { dir: "/" args: ["sh", "-c", """ echo \(hello) diff --git a/tests/llb/exec/undefined/non_concrete_referenced/main.cue b/tests/ops/exec/undefined/non_concrete_referenced/main.cue similarity index 78% rename from tests/llb/exec/undefined/non_concrete_referenced/main.cue rename to tests/ops/exec/undefined/non_concrete_referenced/main.cue index 93c40120..3a1e8796 100644 --- a/tests/llb/exec/undefined/non_concrete_referenced/main.cue +++ b/tests/ops/exec/undefined/non_concrete_referenced/main.cue @@ -1,15 +1,15 @@ package testing +import "dagger.io/dagger/op" + hello: "world" bar: string #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "exec" + op.#Exec & { dir: "/" args: ["sh", "-c", """ echo \(bar) diff --git a/tests/llb/exec/undefined/with_pkg_def/cue.mod/module.cue b/tests/ops/exec/undefined/with_pkg_def/cue.mod/module.cue similarity index 100% rename from tests/llb/exec/undefined/with_pkg_def/cue.mod/module.cue rename to tests/ops/exec/undefined/with_pkg_def/cue.mod/module.cue diff --git a/tests/llb/exec/undefined/with_pkg_def/cue.mod/pkg/dagger.io/def/main.cue b/tests/ops/exec/undefined/with_pkg_def/cue.mod/pkg/dagger.io/def/main.cue similarity index 100% rename from tests/llb/exec/undefined/with_pkg_def/cue.mod/pkg/dagger.io/def/main.cue rename to tests/ops/exec/undefined/with_pkg_def/cue.mod/pkg/dagger.io/def/main.cue diff --git a/tests/llb/exec/undefined/with_pkg_def/main.cue b/tests/ops/exec/undefined/with_pkg_def/main.cue similarity index 65% rename from tests/llb/exec/undefined/with_pkg_def/main.cue rename to tests/ops/exec/undefined/with_pkg_def/main.cue index dfb1d73e..cd8a98b5 100644 --- a/tests/llb/exec/undefined/with_pkg_def/main.cue +++ b/tests/ops/exec/undefined/with_pkg_def/main.cue @@ -1,12 +1,12 @@ package testing import ( + "dagger.io/dagger/op" "dagger.io/def" ) #up: [ - { - do: "load", + op.#Load & { from: def }, ] diff --git a/tests/llb/exec/undefined/with_pkg_mandatory/cue.mod/module.cue b/tests/ops/exec/undefined/with_pkg_mandatory/cue.mod/module.cue similarity index 100% rename from tests/llb/exec/undefined/with_pkg_mandatory/cue.mod/module.cue rename to tests/ops/exec/undefined/with_pkg_mandatory/cue.mod/module.cue diff --git a/tests/llb/exec/undefined/with_pkg_mandatory/cue.mod/pkg/dagger.io/nonoptional/main.cue b/tests/ops/exec/undefined/with_pkg_mandatory/cue.mod/pkg/dagger.io/nonoptional/main.cue similarity index 100% rename from tests/llb/exec/undefined/with_pkg_mandatory/cue.mod/pkg/dagger.io/nonoptional/main.cue rename to tests/ops/exec/undefined/with_pkg_mandatory/cue.mod/pkg/dagger.io/nonoptional/main.cue diff --git a/tests/llb/exec/undefined/with_pkg_mandatory/main.cue b/tests/ops/exec/undefined/with_pkg_mandatory/main.cue similarity index 70% rename from tests/llb/exec/undefined/with_pkg_mandatory/main.cue rename to tests/ops/exec/undefined/with_pkg_mandatory/main.cue index c6c6e400..e6673db4 100644 --- a/tests/llb/exec/undefined/with_pkg_mandatory/main.cue +++ b/tests/ops/exec/undefined/with_pkg_mandatory/main.cue @@ -2,11 +2,11 @@ package testing import ( "dagger.io/nonoptional" + "dagger.io/dagger/op" ) #up: [ - { - do: "load", + op.#Load & { from: nonoptional }, ] diff --git a/tests/llb/exec/undefined/with_pkg_optional/cue.mod/module.cue b/tests/ops/exec/undefined/with_pkg_optional/cue.mod/module.cue similarity index 100% rename from tests/llb/exec/undefined/with_pkg_optional/cue.mod/module.cue rename to tests/ops/exec/undefined/with_pkg_optional/cue.mod/module.cue diff --git a/tests/llb/exec/undefined/with_pkg_optional/cue.mod/pkg/dagger.io/optional/main.cue b/tests/ops/exec/undefined/with_pkg_optional/cue.mod/pkg/dagger.io/optional/main.cue similarity index 100% rename from tests/llb/exec/undefined/with_pkg_optional/cue.mod/pkg/dagger.io/optional/main.cue rename to tests/ops/exec/undefined/with_pkg_optional/cue.mod/pkg/dagger.io/optional/main.cue diff --git a/tests/llb/exec/undefined/with_pkg_optional/main.cue b/tests/ops/exec/undefined/with_pkg_optional/main.cue similarity index 68% rename from tests/llb/exec/undefined/with_pkg_optional/main.cue rename to tests/ops/exec/undefined/with_pkg_optional/main.cue index 349fdeb5..59569918 100644 --- a/tests/llb/exec/undefined/with_pkg_optional/main.cue +++ b/tests/ops/exec/undefined/with_pkg_optional/main.cue @@ -2,11 +2,11 @@ package testing import ( "dagger.io/optional" + "dagger.io/dagger/op" ) #up: [ - { - do: "load", + op.#Load & { from: optional }, ] diff --git a/tests/llb/export/bool/main.cue b/tests/ops/export/bool/main.cue similarity index 72% rename from tests/llb/export/bool/main.cue rename to tests/ops/export/bool/main.cue index f30e94bf..3c7fa51b 100644 --- a/tests/llb/export/bool/main.cue +++ b/tests/ops/export/bool/main.cue @@ -1,23 +1,22 @@ package testing +import "dagger.io/dagger/op" + test: { bool #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", """ printf "true" > /tmp/out """, ] dir: "/" }, - { - do: "export" + op.#Export & { // Source path in the container source: "/tmp/out" format: "json" diff --git a/tests/llb/export/concurrency/main.cue b/tests/ops/export/concurrency/main.cue similarity index 71% rename from tests/llb/export/concurrency/main.cue rename to tests/ops/export/concurrency/main.cue index a581cdc5..97607913 100644 --- a/tests/llb/export/concurrency/main.cue +++ b/tests/ops/export/concurrency/main.cue @@ -1,23 +1,22 @@ package testing +import "dagger.io/dagger/op" + test1: { string #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", """ echo lol1 > /tmp/out """] dir: "/" always: true }, - { - do: "export" + op.#Export & { source: "/tmp/out" format: "string" }, @@ -28,20 +27,17 @@ test2: { string #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", """ echo lol2 > /tmp/out """] dir: "/" always: true }, - { - do: "export" + op.#Export & { source: "/tmp/out" format: "string" }, @@ -52,20 +48,17 @@ test3: { string #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", """ echo lol3 > /tmp/out """] dir: "/" always: true }, - { - do: "export" + op.#Export & { source: "/tmp/out" format: "string" }, @@ -76,20 +69,17 @@ test4: { string #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", """ echo lol4 > /tmp/out """] dir: "/" always: true }, - { - do: "export" + op.#Export & { source: "/tmp/out" format: "string" }, @@ -100,20 +90,16 @@ test5: { string #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", """ echo lol5 > /tmp/out """] - dir: "/" always: true }, - { - do: "export" + op.#Export & { source: "/tmp/out" format: "string" }, @@ -124,20 +110,16 @@ test6: { string #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", """ echo lol6 > /tmp/out """] - dir: "/" always: true }, - { - do: "export" + op.#Export & { source: "/tmp/out" format: "string" }, @@ -148,20 +130,16 @@ test7: { string #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", """ echo lol7 > /tmp/out """] - dir: "/" always: true }, - { - do: "export" + op.#Export & { source: "/tmp/out" format: "string" }, @@ -172,20 +150,17 @@ test8: { string #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", """ echo lol8 > /tmp/out """] dir: "/" always: true }, - { - do: "export" + op.#Export & { source: "/tmp/out" format: "string" }, @@ -196,20 +171,17 @@ test9: { string #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", """ echo lol9 > /tmp/out """] dir: "/" always: true }, - { - do: "export" + op.#Export & { source: "/tmp/out" format: "string" }, @@ -220,20 +192,17 @@ test10: { string #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", """ echo lol10 > /tmp/out """] dir: "/" always: true }, - { - do: "export" + op.#Export & { source: "/tmp/out" format: "string" }, diff --git a/tests/llb/export/float/main.cue b/tests/ops/export/float/main.cue similarity index 71% rename from tests/llb/export/float/main.cue rename to tests/ops/export/float/main.cue index b3bc2825..3fdcc53b 100644 --- a/tests/llb/export/float/main.cue +++ b/tests/ops/export/float/main.cue @@ -1,22 +1,21 @@ package testing +import "dagger.io/dagger/op" + test: { float #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", """ echo -123.5 > /tmp/out """, ] }, - { - do: "export" + op.#Export & { // Source path in the container source: "/tmp/out" format: "json" diff --git a/tests/llb/export/invalid/format/main.cue b/tests/ops/export/invalid/format/main.cue similarity index 72% rename from tests/llb/export/invalid/format/main.cue rename to tests/ops/export/invalid/format/main.cue index abbc2259..e645d9ad 100644 --- a/tests/llb/export/invalid/format/main.cue +++ b/tests/ops/export/invalid/format/main.cue @@ -1,22 +1,21 @@ package testing +import "dagger.io/dagger/op" + teststring: { string #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", """ echo something > /tmp/out """, ] }, - { - do: "export" + op.#Export & { // Source path in the container source: "/tmp/out" format: "lalalalal" diff --git a/tests/llb/export/invalid/path/main.cue b/tests/ops/export/invalid/path/main.cue similarity index 76% rename from tests/llb/export/invalid/path/main.cue rename to tests/ops/export/invalid/path/main.cue index 25934352..74e6cd50 100644 --- a/tests/llb/export/invalid/path/main.cue +++ b/tests/ops/export/invalid/path/main.cue @@ -4,12 +4,10 @@ teststring: { string #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "export" + op.#Export & { // Source path in the container source: "/tmp/lalala" format: "string" diff --git a/tests/llb/export/invalid/validation/main.cue b/tests/ops/export/invalid/validation/main.cue similarity index 73% rename from tests/llb/export/invalid/validation/main.cue rename to tests/ops/export/invalid/validation/main.cue index 8de9c3f1..1f08b75e 100644 --- a/tests/llb/export/invalid/validation/main.cue +++ b/tests/ops/export/invalid/validation/main.cue @@ -1,23 +1,22 @@ package testing +import "dagger.io/dagger/op" + test: { string =~"^NAAAA.+" #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", """ printf something > /tmp/out """, ] }, - { - do: "export" + op.#Export & { // Source path in the container source: "/tmp/out" format: "string" diff --git a/tests/llb/export/json/main.cue b/tests/ops/export/json/main.cue similarity index 84% rename from tests/llb/export/json/main.cue rename to tests/ops/export/json/main.cue index 5bedf20e..8f670af7 100644 --- a/tests/llb/export/json/main.cue +++ b/tests/ops/export/json/main.cue @@ -1,23 +1,21 @@ package testing +import "dagger.io/dagger/op" + testScalar: { bool #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", """ echo true > /tmp/out """, ] - dir: "/" }, - { - do: "export" + op.#Export & { // Source path in the container source: "/tmp/out" format: "json" @@ -26,20 +24,16 @@ testScalar: { } testMap: #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", """ echo '{"something": "something"}' > /tmp/out """, ] - dir: "/" }, - { - do: "export" + op.#Export & { // Source path in the container source: "/tmp/out" format: "json" diff --git a/tests/llb/export/number/main.cue b/tests/ops/export/number/main.cue similarity index 71% rename from tests/llb/export/number/main.cue rename to tests/ops/export/number/main.cue index 11fd0c65..1c514aa2 100644 --- a/tests/llb/export/number/main.cue +++ b/tests/ops/export/number/main.cue @@ -1,22 +1,21 @@ package testing +import "dagger.io/dagger/op" + test: { number #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", """ echo -123.5 > /tmp/out """, ] }, - { - do: "export" + op.#Export & { // Source path in the container source: "/tmp/out" format: "json" diff --git a/tests/llb/export/string/main.cue b/tests/ops/export/string/main.cue similarity index 72% rename from tests/llb/export/string/main.cue rename to tests/ops/export/string/main.cue index 65917c83..e2fbf7eb 100644 --- a/tests/llb/export/string/main.cue +++ b/tests/ops/export/string/main.cue @@ -1,22 +1,21 @@ package testing +import "dagger.io/dagger/op" + test: { string #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", """ printf something > /tmp/out """, ] }, - { - do: "export" + op.#Export & { // Source path in the container source: "/tmp/out" format: "string" diff --git a/tests/llb/export/withvalidation/main.cue b/tests/ops/export/withvalidation/main.cue similarity index 73% rename from tests/llb/export/withvalidation/main.cue rename to tests/ops/export/withvalidation/main.cue index e6ddd93f..3252c721 100644 --- a/tests/llb/export/withvalidation/main.cue +++ b/tests/ops/export/withvalidation/main.cue @@ -1,23 +1,22 @@ package testing +import "dagger.io/dagger/op" + test: { string =~"^some.+" #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", """ printf something > /tmp/out """, ] }, - { - do: "export" + op.#Export & { // Source path in the container source: "/tmp/out" format: "string" diff --git a/tests/llb/export/yaml/main.cue b/tests/ops/export/yaml/main.cue similarity index 87% rename from tests/llb/export/yaml/main.cue rename to tests/ops/export/yaml/main.cue index d6a7de34..88c0d96f 100644 --- a/tests/llb/export/yaml/main.cue +++ b/tests/ops/export/yaml/main.cue @@ -1,24 +1,21 @@ package testing +import "dagger.io/dagger/op" + testScalar: { bool #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", """ echo true > /tmp/out """, ] - // XXX Blocked by https://github.com/blocklayerhq/dagger/issues/19 - dir: "/" }, - { - do: "export" + op.#Export & { // Source path in the container source: "/tmp/out" format: "yaml" diff --git a/tests/llb/fetch-container/exist/main.cue b/tests/ops/fetch-container/exist/main.cue similarity index 72% rename from tests/llb/fetch-container/exist/main.cue rename to tests/ops/fetch-container/exist/main.cue index c6b44ad4..287622c3 100644 --- a/tests/llb/fetch-container/exist/main.cue +++ b/tests/ops/fetch-container/exist/main.cue @@ -1,36 +1,33 @@ package testing +import "dagger.io/dagger/op" + busybox1: #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "busybox" }, ] busybox2: #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "busybox:latest" }, ] busybox3: #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "busybox:1.33-musl" }, ] busybox4: #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "busybox@sha256:e2af53705b841ace3ab3a44998663d4251d33ee8a9acaf71b66df4ae01c3bbe7" }, ] busybox5: #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "busybox:1.33-musl@sha256:e2af53705b841ace3ab3a44998663d4251d33ee8a9acaf71b66df4ae01c3bbe7" }, ] diff --git a/tests/ops/fetch-container/invalid/main.cue b/tests/ops/fetch-container/invalid/main.cue new file mode 100644 index 00000000..0de73875 --- /dev/null +++ b/tests/ops/fetch-container/invalid/main.cue @@ -0,0 +1,8 @@ +package testing + +import "dagger.io/dagger/op" + +#up: [ + op.#FetchContainer & { + }, +] diff --git a/tests/llb/fetch-container/nonexistent/digest/main.cue b/tests/ops/fetch-container/nonexistent/digest/main.cue similarity index 68% rename from tests/llb/fetch-container/nonexistent/digest/main.cue rename to tests/ops/fetch-container/nonexistent/digest/main.cue index 6974d5da..e41a0af6 100644 --- a/tests/llb/fetch-container/nonexistent/digest/main.cue +++ b/tests/ops/fetch-container/nonexistent/digest/main.cue @@ -1,8 +1,9 @@ package testing +import "dagger.io/dagger/op" + #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine@sha256:c6c7524e2111f22a9f7577211232d89a9e68cf5b9ed4a41ba77957c9771380a5" }, ] diff --git a/tests/llb/fetch-container/nonexistent/image-with-valid-digest/main.cue b/tests/ops/fetch-container/nonexistent/image-with-valid-digest/main.cue similarity index 82% rename from tests/llb/fetch-container/nonexistent/image-with-valid-digest/main.cue rename to tests/ops/fetch-container/nonexistent/image-with-valid-digest/main.cue index a69d6fdc..7eaa1468 100644 --- a/tests/llb/fetch-container/nonexistent/image-with-valid-digest/main.cue +++ b/tests/ops/fetch-container/nonexistent/image-with-valid-digest/main.cue @@ -1,10 +1,11 @@ package testing +import "dagger.io/dagger/op" + // XXX WATCHOUT // Once buildkit has pulled that digest, it will stay cached and happily succeed WHATEVER the image name then is #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "busyboxaaa@sha256:e2af53705b841ace3ab3a44998663d4251d33ee8a9acaf71b66df4ae01c3bbe7" }, ] diff --git a/tests/ops/fetch-container/nonexistent/image/main.cue b/tests/ops/fetch-container/nonexistent/image/main.cue new file mode 100644 index 00000000..d32c238a --- /dev/null +++ b/tests/ops/fetch-container/nonexistent/image/main.cue @@ -0,0 +1,9 @@ +package testing + +import "dagger.io/dagger/op" + +#up: [ + op.#FetchContainer & { + ref: "doesnotexist" + }, +] diff --git a/tests/llb/fetch-container/nonexistent/tag/main.cue b/tests/ops/fetch-container/nonexistent/tag/main.cue similarity index 52% rename from tests/llb/fetch-container/nonexistent/tag/main.cue rename to tests/ops/fetch-container/nonexistent/tag/main.cue index a22f1b17..cc24916a 100644 --- a/tests/llb/fetch-container/nonexistent/tag/main.cue +++ b/tests/ops/fetch-container/nonexistent/tag/main.cue @@ -1,8 +1,9 @@ package testing +import "dagger.io/dagger/op" + #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine:doesnotexist" }, ] diff --git a/tests/llb/fetch-git/exist/main.cue b/tests/ops/fetch-git/exist/main.cue similarity index 69% rename from tests/llb/fetch-git/exist/main.cue rename to tests/ops/fetch-git/exist/main.cue index 86fb6506..dc8cf641 100644 --- a/tests/llb/fetch-git/exist/main.cue +++ b/tests/ops/fetch-git/exist/main.cue @@ -1,8 +1,9 @@ package testing +import "dagger.io/dagger/op" + #up: [ - { - do: "fetch-git" + op.#FetchGit & { remote: "https://github.com/blocklayerhq/acme-clothing.git" ref: "master" }, diff --git a/tests/ops/fetch-git/invalid/main.cue b/tests/ops/fetch-git/invalid/main.cue new file mode 100644 index 00000000..dac913c6 --- /dev/null +++ b/tests/ops/fetch-git/invalid/main.cue @@ -0,0 +1,8 @@ +package testing + +import "dagger.io/dagger/op" + +#up: [ + op.#FetchGit & { + }, +] diff --git a/tests/llb/fetch-git/nonexistent/bork/main.cue b/tests/ops/fetch-git/nonexistent/bork/main.cue similarity index 60% rename from tests/llb/fetch-git/nonexistent/bork/main.cue rename to tests/ops/fetch-git/nonexistent/bork/main.cue index d59b3090..9d8cab55 100644 --- a/tests/llb/fetch-git/nonexistent/bork/main.cue +++ b/tests/ops/fetch-git/nonexistent/bork/main.cue @@ -1,8 +1,9 @@ package testing +import "dagger.io/dagger/op" + #up: [ - { - do: "fetch-git" + op.#FetchGit & { remote: "pork://pork" ref: "master" }, diff --git a/tests/llb/fetch-git/nonexistent/ref/main.cue b/tests/ops/fetch-git/nonexistent/ref/main.cue similarity index 70% rename from tests/llb/fetch-git/nonexistent/ref/main.cue rename to tests/ops/fetch-git/nonexistent/ref/main.cue index 9b3a9cfd..618075ac 100644 --- a/tests/llb/fetch-git/nonexistent/ref/main.cue +++ b/tests/ops/fetch-git/nonexistent/ref/main.cue @@ -1,8 +1,9 @@ package testing +import "dagger.io/dagger/op" + #up: [ - { - do: "fetch-git" + op.#FetchGit & { remote: "https://github.com/blocklayerhq/acme-clothing.git" ref: "lalalalal" }, diff --git a/tests/llb/fetch-git/nonexistent/remote/main.cue b/tests/ops/fetch-git/nonexistent/remote/main.cue similarity index 68% rename from tests/llb/fetch-git/nonexistent/remote/main.cue rename to tests/ops/fetch-git/nonexistent/remote/main.cue index 87d32a10..4193c76f 100644 --- a/tests/llb/fetch-git/nonexistent/remote/main.cue +++ b/tests/ops/fetch-git/nonexistent/remote/main.cue @@ -1,8 +1,9 @@ package testing +import "dagger.io/dagger/op" + #up: [ - { - do: "fetch-git" + op.#FetchGit & { remote: "https://github.com/blocklayerhq/lalalala.git" ref: "master" }, diff --git a/tests/ops/load/invalid/cache/main.cue b/tests/ops/load/invalid/cache/main.cue new file mode 100644 index 00000000..5191fa53 --- /dev/null +++ b/tests/ops/load/invalid/cache/main.cue @@ -0,0 +1,39 @@ +package testing + +import "dagger.io/dagger/op" + +test1: { + string + + #up: [ + op.#Load & { + from: [ + op.#FetchContainer & { + ref: "alpine" + }, + ] + }, + op.#Export & { + source: "/etc/issue" + format: "string" + }, + ] +} + +test2: { + string + + #up: [ + op.#Load & { + from: [ + op.#FetchContainer & { + ref: "busybox" + }, + ] + }, + op.#Export & { + source: "/etc/issue" + format: "string" + }, + ] +} diff --git a/tests/ops/load/valid/component/main.cue b/tests/ops/load/valid/component/main.cue new file mode 100644 index 00000000..ff1395cc --- /dev/null +++ b/tests/ops/load/valid/component/main.cue @@ -0,0 +1,51 @@ +package testing + +import "dagger.io/dagger/op" + +component: #up: [ + op.#FetchContainer & { + ref: "alpine" + }, + op.#Exec & { + args: ["sh", "-c", """ + printf lol > /id + """] + }, +] + +test1: { + string + + #up: [ + op.#Load & { + from: component + }, + op.#Export & { + source: "/id" + format: "string" + }, + ] +} + +test2: { + string + + #up: [ + op.#Load & { + from: #up: [ + op.#FetchContainer & { + ref: "alpine" + }, + op.#Exec & { + args: ["sh", "-c", """ + printf lol > /id + """] + }, + ] + }, + op.#Export & { + source: "/id" + format: "string" + }, + ] +} diff --git a/tests/ops/load/valid/script/main.cue b/tests/ops/load/valid/script/main.cue new file mode 100644 index 00000000..d4184b09 --- /dev/null +++ b/tests/ops/load/valid/script/main.cue @@ -0,0 +1,21 @@ +package testing + +import "dagger.io/dagger/op" + +test: { + string + + #up: [ + op.#Load & { + from: [ + op.#FetchContainer & { + ref: "alpine" + }, + ] + }, + op.#Export & { + source: "/etc/issue" + format: "string" + }, + ] +} diff --git a/tests/llb/mounts/valid/cache/main.cue b/tests/ops/mounts/valid/cache/main.cue similarity index 77% rename from tests/llb/mounts/valid/cache/main.cue rename to tests/ops/mounts/valid/cache/main.cue index 7a66a40a..6e1c583f 100644 --- a/tests/llb/mounts/valid/cache/main.cue +++ b/tests/ops/mounts/valid/cache/main.cue @@ -1,23 +1,22 @@ package testing +import "dagger.io/dagger/op" + test: { string #up: [ - { - do: "load" + op.#Load & { from: [{do: "fetch-container", ref: "alpine"}] }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", """ echo "NOT SURE WHAT TO TEST YET" > /out """] dir: "/" mount: something: "cache" }, - { - do: "export" + op.#Export & { source: "/out" format: "string" }, diff --git a/tests/llb/mounts/valid/component/main.cue b/tests/ops/mounts/valid/component/main.cue similarity index 62% rename from tests/llb/mounts/valid/component/main.cue rename to tests/ops/mounts/valid/component/main.cue index d6290440..836673aa 100644 --- a/tests/llb/mounts/valid/component/main.cue +++ b/tests/ops/mounts/valid/component/main.cue @@ -1,33 +1,34 @@ package testing +import "dagger.io/dagger/op" + test: { string #up: [ - { - do: "load" - from: [{do: "fetch-container", ref: "alpine"}] + op.#Load & { + from: [ + op.#FetchContainer & { + ref: "alpine" + }, + ] }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", """ cat /mnt/test/lol > /out """] mount: "/mnt/test": from: #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", """ echo -n "hello world" > /lol """] }, ] }, - { - do: "export" + op.#Export & { source: "/out" format: "string" }, diff --git a/tests/llb/mounts/valid/script/main.cue b/tests/ops/mounts/valid/script/main.cue similarity index 65% rename from tests/llb/mounts/valid/script/main.cue rename to tests/ops/mounts/valid/script/main.cue index 00567b0f..c996543f 100644 --- a/tests/llb/mounts/valid/script/main.cue +++ b/tests/ops/mounts/valid/script/main.cue @@ -1,19 +1,22 @@ package testing +import "dagger.io/dagger/op" + test: { string #up: [ - { - do: "load" - from: [{do: "fetch-container", ref: "alpine"}] + op.#Load & { + from: [ + op.#FetchContainer & { + ref: "alpine" + }, + ] }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", """ ls -lA /lol > /out """] - dir: "/" mount: something: { input: [{ do: "fetch-container" @@ -22,8 +25,7 @@ test: { path: "/lol" } }, - { - do: "export" + op.#Export & { source: "/out" format: "string" }, diff --git a/tests/llb/mounts/valid/tmpfs/main.cue b/tests/ops/mounts/valid/tmpfs/main.cue similarity index 69% rename from tests/llb/mounts/valid/tmpfs/main.cue rename to tests/ops/mounts/valid/tmpfs/main.cue index 75258d18..3b47332d 100644 --- a/tests/llb/mounts/valid/tmpfs/main.cue +++ b/tests/ops/mounts/valid/tmpfs/main.cue @@ -1,32 +1,33 @@ package testing +import "dagger.io/dagger/op" + test: { string #up: [ - { - do: "load" - from: [{do: "fetch-container", ref: "alpine"}] + op.#Load & { + from: [ + op.#FetchContainer & { + ref: "alpine" + }, + ] }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", """ echo ok > /out echo ok > /tmpdir/out """] - dir: "/" mount: "/tmpdir": "tmpfs" }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", """ [ -f /out ] || exit 1 # content of /cache/tmp must not exist in this layer [ ! -f /tmpdir/out ] || exit 1 """] }, - { - do: "export" + op.#Export & { source: "/out" format: "string" }, diff --git a/tests/llb/push-container/inputs.yaml b/tests/ops/push-container/inputs.yaml similarity index 100% rename from tests/llb/push-container/inputs.yaml rename to tests/ops/push-container/inputs.yaml diff --git a/tests/llb/push-container/main.cue b/tests/ops/push-container/main.cue similarity index 100% rename from tests/llb/push-container/main.cue rename to tests/ops/push-container/main.cue diff --git a/tests/llb/subdir/simple/main.cue b/tests/ops/subdir/simple/main.cue similarity index 66% rename from tests/llb/subdir/simple/main.cue rename to tests/ops/subdir/simple/main.cue index 1598e7af..1cb98ffb 100644 --- a/tests/llb/subdir/simple/main.cue +++ b/tests/ops/subdir/simple/main.cue @@ -1,27 +1,24 @@ package main +import "dagger.io/dagger/op" + hello: { string #up: [ - { - do: "fetch-container" + op.#FetchContainer & { ref: "alpine" }, - { - do: "exec" + op.#Exec & { args: ["mkdir", "-p", "/tmp/foo"] }, - { - do: "exec" + op.#Exec & { args: ["sh", "-c", "echo -n world > /tmp/foo/hello"] }, - { - do: "subdir" + op.#Subdir & { dir: "/tmp/foo" }, - { - do: "export" + op.#Export & { source: "/hello" format: "string" }, diff --git a/tests/test-llb.sh b/tests/test-llb.sh deleted file mode 100644 index fdfadee6..00000000 --- a/tests/test-llb.sh +++ /dev/null @@ -1,187 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o errtrace -o functrace -o nounset -o pipefail - -# Test Directory -d=$(cd "$(dirname "${BASH_SOURCE[0]:-$PWD}")" 2>/dev/null 1>&2 && pwd) - -test::llb(){ - local dagger="$1" - - test::llb::load "$dagger" - test::llb::mount "$dagger" - test::llb::copy "$dagger" - test::llb::local "$dagger" - test::llb::fetchcontainer "$dagger" - test::llb::pushcontainer "$dagger" - test::llb::fetchgit "$dagger" - test::llb::exec "$dagger" - test::llb::export "$dagger" - test::llb::subdir "$dagger" - test::llb::dockerbuild "$dagger" -} - -test::llb::load(){ - test::one "Load: valid components" --exit=0 --stdout='{"component":{},"test1":"lol","test2":"lol"}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/load/valid/component - test::one "Load: valid script" --exit=0 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/load/valid/script - - test::one "Load: invalid caching (FIXME https://github.com/blocklayerhq/dagger/issues/44)" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/load/invalid/cache -} - -test::llb::mount(){ - test::one "Mount: tmpfs" --exit=0 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/mounts/valid/tmpfs - - test::one "Mount: cache" --exit=0 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/mounts/valid/cache - - test::one "Mount: component" --exit=0 --stdout='{"test":"hello world"}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/mounts/valid/component - - disable test::one "Mount: script (FIXME https://github.com/blocklayerhq/dagger/issues/46)" --exit=0 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/mounts/valid/script -} - -test::llb::copy(){ - test::one "Copy: valid components" --exit=0 --stdout='{"component":{},"test1":"lol","test2":"lol"}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/copy/valid/component - test::one "Copy: valid script" --exit=0 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/copy/valid/script - - disable test::one "Copy: invalid caching (FIXME https://github.com/blocklayerhq/dagger/issues/44)" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/copy/invalid/cache -} - -test::llb::local(){ - disable "" "There are no local tests right now (the feature is possibly not functioning at all: see https://github.com/blocklayerhq/dagger/issues/41)" -} - -test::llb::fetchcontainer(){ - local dagger="$1" - - # Fetch container - disable test::one "FetchContainer: missing ref (FIXME: distinguish missing inputs from incorrect config)" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-container/invalid - test::one "FetchContainer: non existent container image" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-container/nonexistent/image - test::one "FetchContainer: non existent container tag" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-container/nonexistent/tag - test::one "FetchContainer: non existent container digest" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-container/nonexistent/digest - - test::one "FetchContainer: valid containers" --exit=0 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-container/exist - - disable test::one "FetchContainer: non existent container image with valid digest (FIXME https://github.com/blocklayerhq/dagger/issues/32)" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-container/nonexistent/image-with-valid-digest -} - -test::llb::pushcontainer(){ - local dagger="$1" - - test::secret "$d"/llb/push-container/inputs.yaml "PushContainer: simple" --exit=0 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/push-container -} - -test::llb::fetchgit(){ - local dagger="$1" - - # Fetch git - test::one "FetchGit: valid" --exit=0 --stdout="{}" \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-git/exist - disable test::one "FetchGit: invalid (FIXME: distinguish missing inputs from incorrect config) " --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-git/invalid - test::one "FetchGit: non existent remote" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-git/nonexistent/remote - test::one "FetchGit: non existent ref" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-git/nonexistent/ref - test::one "FetchGit: non existent bork" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-git/nonexistent/bork -} - -test::llb::exec(){ - # Exec - test::one "Exec: invalid" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/invalid - test::one "Exec: error" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/error - test::one "Exec: simple" --exit=0 --stdout={} \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/simple - # XXX should run twice and test that the string "always output" is visible with DOCKER_OUTPUT=1 - # Alternatively, use export, but this would test multiple things then... - test::one "Exec: always" --exit=0 --stdout={} \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/always - test::one "Exec: env invalid" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/env/invalid - test::one "Exec: env valid" --exit=0 --stdout={} \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/env/valid - test::one "Exec: env with overlay" --exit=0 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute --input-string 'bar=overlay environment' "$d"/llb/exec/env/overlay - - test::one "Exec: non existent dir" --exit=0 --stdout={} \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/dir/doesnotexist - test::one "Exec: valid dir" --exit=0 --stdout={} \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/dir/exist - - disable test::one "Exec: exit code propagation (FIXME https://github.com/blocklayerhq/dagger/issues/74)" --exit=123 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/exit_code - - test::one "Exec: script with referenced non-concrete property should not be executed, and should succeed overall" --exit=0 --stdout='{"hello":"world"}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/undefined/non_concrete_referenced - # NOTE: the exec is meant to fail - and we test that as a way to confirm it has been executed - test::one "Exec: script with unreferenced undefined properties should be executed" --exit=1 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/undefined/non_concrete_not_referenced - test::one "Exec: package with optional def, not referenced, should be executed" --exit=0 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/undefined/with_pkg_def - test::one "Exec: script with optional prop, not referenced, should be executed" --exit=0 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/undefined/with_pkg_optional - disable test::one "Exec: script with non-optional prop, not referenced, should be executed (FIXME https://github.com/blocklayerhq/dagger/issues/70)" --exit=1 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/undefined/with_pkg_mandatory -} - -test::llb::export(){ - test::one "Export: json" --exit=0 --stdout='{"testMap":{"something":"something"},"testScalar":true}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/json - - test::one "Export: string" --exit=0 --stdout='{"test":"something"}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/string - - test::one "Export: string with additional constraint success" --exit=0 --stdout='{"test":"something"}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/withvalidation - - test::one "Export: many concurrent" --exit=0 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/concurrency - - test::one "Export: does not pass additional validation" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/invalid/validation - - test::one "Export: invalid format" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/invalid/format - - test::one "Export: invalid path" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/invalid/path - - test::one "Export: number" --exit=0 --stdout='{"test":-123.5}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/float - - disable test::one "Export: number (FIXME: https://github.com/blocklayerhq/dagger/issues/96)" --exit=0 --stdout='{"test":-123.5}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/number - - test::one "Export: yaml" --exit=0 --stdout='{"testMap":{"something":"something"},"testScalar":true}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/yaml - - test::one "Export: bool" --exit=0 --stdout='{"test":true}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/bool -} - -test::llb::subdir() { - test::one "Subdir: simple usage" --exit=0 --stdout='{"hello":"world"}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/subdir/simple -} - -test::llb::dockerbuild() { - test::one "Docker Build" --exit=0 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute --input-dir TestData="$d"/llb/dockerbuild/testdata "$d"/llb/dockerbuild -} diff --git a/tests/test.sh b/tests/test.sh index 9188967d..29aff873 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -18,8 +18,6 @@ d=$(cd "$(dirname "${BASH_SOURCE[0]:-$PWD}")" 2>/dev/null 1>&2 && pwd) # shellcheck source=/dev/null . "$d/test-compute.sh" # shellcheck source=/dev/null -. "$d/test-llb.sh" -# shellcheck source=/dev/null . "$d/test-stdlib.sh" # shellcheck source=/dev/null . "$d/test-examples.sh" @@ -28,7 +26,6 @@ test::all(){ local dagger="$1" test::suite "compute" && test::compute "$dagger" - test::suite "llb" && test::llb "$dagger" test::suite "stdlib" && test::stdlib "$dagger" test::suite "examples" && test::examples "$dagger" }