diff --git a/cmd/dagger/cmd/root.go b/cmd/dagger/cmd/root.go index 8700340e..c872f3f4 100644 --- a/cmd/dagger/cmd/root.go +++ b/cmd/dagger/cmd/root.go @@ -38,7 +38,6 @@ func init() { } rootCmd.AddCommand( - upCmd, versionCmd, docCmd, doCmd, diff --git a/cmd/dagger/cmd/up.go b/cmd/dagger/cmd/up.go deleted file mode 100644 index 8073380e..00000000 --- a/cmd/dagger/cmd/up.go +++ /dev/null @@ -1,98 +0,0 @@ -package cmd - -import ( - "context" - "os" - - "cuelang.org/go/cue" - "go.dagger.io/dagger/cmd/dagger/cmd/common" - "go.dagger.io/dagger/cmd/dagger/logger" - "go.dagger.io/dagger/plan" - "go.dagger.io/dagger/solver" - "golang.org/x/term" - - "github.com/spf13/cobra" - "github.com/spf13/viper" -) - -var upCmd = &cobra.Command{ - // FIXME: this command will be removed soon - Hidden: true, - Deprecated: "please use `dagger do ACTION` instead", - - Use: "up", - Short: "Bring an environment online with latest plan and inputs", - Args: cobra.MaximumNArgs(1), - PreRun: func(cmd *cobra.Command, args []string) { - // Fix Viper bug for duplicate flags: - // https://github.com/spf13/viper/issues/233 - if err := viper.BindPFlags(cmd.Flags()); err != nil { - panic(err) - } - }, - Run: func(cmd *cobra.Command, args []string) { - var ( - lg = logger.New() - tty *logger.TTYOutput - err error - ) - - if f := viper.GetString("log-format"); f == "tty" || f == "auto" && term.IsTerminal(int(os.Stdout.Fd())) { - tty, err = logger.NewTTYOutput(os.Stderr) - if err != nil { - lg.Fatal().Err(err).Msg("failed to initialize TTY logger") - } - tty.Start() - defer tty.Stop() - - lg = lg.Output(tty) - } - - ctx := lg.WithContext(cmd.Context()) - cl := common.NewClient(ctx) - - p, err := plan.Load(ctx, plan.Config{ - Args: args, - With: viper.GetStringSlice("with"), - Target: viper.GetString("target"), - }) - if err != nil { - lg.Fatal().Err(err).Msg("failed to load plan") - } - - doneCh := common.TrackCommand(ctx, cmd) - err = cl.Do(ctx, p.Context(), func(ctx context.Context, s solver.Solver) error { - return p.Do(ctx, cue.ParsePath(viper.GetString("target")), s) - }) - <-doneCh - - if err != nil { - lg.Fatal().Err(err).Msg("failed to up environment") - } - }, -} - -// func checkUniverseVersion(ctx context.Context, projectPath string) bool { -// lg := log.Ctx(ctx) - -// isLatest, err := mod.IsUniverseLatest(ctx, projectPath) -// if err != nil { -// lg.Debug().Err(err).Msg("failed to check universe version") -// return false -// } -// if !isLatest { -// return true -// } -// lg.Debug().Msg("universe is up to date") -// return false -// } - -func init() { - upCmd.Flags().BoolP("force", "f", false, "Force up, disable inputs check") - upCmd.Flags().StringArrayP("with", "w", []string{}, "") - upCmd.Flags().StringP("target", "t", "", "Run a single target of the DAG (for debugging only)") - - if err := viper.BindPFlags(upCmd.Flags()); err != nil { - panic(err) - } -} diff --git a/pkg/universe.dagger.io/alpine/test/test.bats b/pkg/universe.dagger.io/alpine/test/test.bats index 4c4c4c7b..e48cf996 100644 --- a/pkg/universe.dagger.io/alpine/test/test.bats +++ b/pkg/universe.dagger.io/alpine/test/test.bats @@ -4,5 +4,5 @@ setup() { common_setup } @test "alpine" { - dagger up + dagger "do" -p ./test.cue test } diff --git a/pkg/universe.dagger.io/alpine/test/test.cue b/pkg/universe.dagger.io/alpine/test/test.cue index 26831d38..1c99cab2 100644 --- a/pkg/universe.dagger.io/alpine/test/test.cue +++ b/pkg/universe.dagger.io/alpine/test/test.cue @@ -8,7 +8,7 @@ import ( ) dagger.#Plan & { - actions: tests: { + actions: test: { // Test: customize alpine version alpineVersion: { build: alpine.#Build & { diff --git a/pkg/universe.dagger.io/aws/cli/test/test.bats b/pkg/universe.dagger.io/aws/cli/test/test.bats index acea47fb..91f36049 100644 --- a/pkg/universe.dagger.io/aws/cli/test/test.bats +++ b/pkg/universe.dagger.io/aws/cli/test/test.bats @@ -5,5 +5,5 @@ setup() { } @test "aws/cli" { - dagger up ./sts_get_caller_identity.cue + dagger "do" -p ./sts_get_caller_identity.cue verify } diff --git a/pkg/universe.dagger.io/aws/test/test.bats b/pkg/universe.dagger.io/aws/test/test.bats index a1003bb8..8513f0d4 100644 --- a/pkg/universe.dagger.io/aws/test/test.bats +++ b/pkg/universe.dagger.io/aws/test/test.bats @@ -5,7 +5,7 @@ setup() { } @test "aws" { - dagger up ./default_version.cue - dagger up ./credentials.cue - dagger up ./config_file.cue + dagger "do" -p ./default_version.cue getVersion + dagger "do" -p ./credentials.cue verify + dagger "do" -p ./config_file.cue verify } diff --git a/pkg/universe.dagger.io/bash/test/test.bats b/pkg/universe.dagger.io/bash/test/test.bats index 52dc4dc7..a5591fba 100644 --- a/pkg/universe.dagger.io/bash/test/test.bats +++ b/pkg/universe.dagger.io/bash/test/test.bats @@ -5,6 +5,6 @@ setup() { } @test "bash" { - dagger up + dagger "do" -p ./test.cue test } diff --git a/pkg/universe.dagger.io/bash/test/test.cue b/pkg/universe.dagger.io/bash/test/test.cue index f11ccdc7..0620f8a0 100644 --- a/pkg/universe.dagger.io/bash/test/test.cue +++ b/pkg/universe.dagger.io/bash/test/test.cue @@ -8,7 +8,7 @@ import ( ) dagger.#Plan & { - actions: tests: { + actions: test: { _pull: docker.#Pull & { source: "index.docker.io/debian" diff --git a/pkg/universe.dagger.io/docker/test/build.cue b/pkg/universe.dagger.io/docker/test/build.cue index d2dbda36..38da4da3 100644 --- a/pkg/universe.dagger.io/docker/test/build.cue +++ b/pkg/universe.dagger.io/docker/test/build.cue @@ -8,7 +8,7 @@ import ( ) dagger.#Plan & { - actions: tests: build: { + actions: test: build: { // Test: simple docker.#Build simple: { #testValue: "hello world" diff --git a/pkg/universe.dagger.io/docker/test/image.cue b/pkg/universe.dagger.io/docker/test/image.cue index 818ba1ac..69c5f7a5 100644 --- a/pkg/universe.dagger.io/docker/test/image.cue +++ b/pkg/universe.dagger.io/docker/test/image.cue @@ -7,7 +7,7 @@ import ( dagger.#Plan & { - actions: tests: image: { + actions: test: image: { // Test: change image config with docker.#Set set: { diff --git a/pkg/universe.dagger.io/docker/test/run.cue b/pkg/universe.dagger.io/docker/test/run.cue index 7bd336f2..82b97275 100644 --- a/pkg/universe.dagger.io/docker/test/run.cue +++ b/pkg/universe.dagger.io/docker/test/run.cue @@ -8,7 +8,7 @@ import ( ) dagger.#Plan & { - actions: tests: run: { + actions: test: run: { _build: alpine.#Build _image: _build.output diff --git a/pkg/universe.dagger.io/docker/test/test.bats b/pkg/universe.dagger.io/docker/test/test.bats index f8fbedda..f95740d7 100644 --- a/pkg/universe.dagger.io/docker/test/test.bats +++ b/pkg/universe.dagger.io/docker/test/test.bats @@ -5,5 +5,5 @@ setup() { } @test "docker" { - dagger up + dagger "do" -p ./ test } diff --git a/pkg/universe.dagger.io/go/test/build.cue b/pkg/universe.dagger.io/go/test/build.cue index 9184ae4d..0c380fe4 100644 --- a/pkg/universe.dagger.io/go/test/build.cue +++ b/pkg/universe.dagger.io/go/test/build.cue @@ -10,7 +10,7 @@ import ( dagger.#Plan & { client: filesystem: "./data/hello": read: contents: dagger.#FS - actions: tests: build: { + actions: test: { _baseImage: alpine.#Build simple: { diff --git a/pkg/universe.dagger.io/go/test/container.cue b/pkg/universe.dagger.io/go/test/container.cue index 4ca4bd6f..82aad0c5 100644 --- a/pkg/universe.dagger.io/go/test/container.cue +++ b/pkg/universe.dagger.io/go/test/container.cue @@ -7,7 +7,7 @@ import ( ) dagger.#Plan & { - actions: tests: container: { + actions: test: { _source: dagger.#Scratch & {} simple: go.#Container & { diff --git a/pkg/universe.dagger.io/go/test/image.cue b/pkg/universe.dagger.io/go/test/image.cue index 5a7ecbbb..4a72a987 100644 --- a/pkg/universe.dagger.io/go/test/image.cue +++ b/pkg/universe.dagger.io/go/test/image.cue @@ -7,7 +7,7 @@ import ( ) dagger.#Plan & { - actions: tests: image: { + actions: test: { _source: dagger.#Scratch & {} simple: { diff --git a/pkg/universe.dagger.io/go/test/test.bats b/pkg/universe.dagger.io/go/test/test.bats index d9190e3b..fcefcd44 100644 --- a/pkg/universe.dagger.io/go/test/test.bats +++ b/pkg/universe.dagger.io/go/test/test.bats @@ -5,8 +5,8 @@ setup() { } @test "bash" { - dagger up ./build.cue - dagger up ./container.cue - dagger up ./image.cue - dagger up ./test.cue + dagger "do" -p ./build.cue test + dagger "do" -p ./container.cue test + dagger "do" -p ./image.cue test + dagger "do" -p ./test.cue test } diff --git a/pkg/universe.dagger.io/go/test/test.cue b/pkg/universe.dagger.io/go/test/test.cue index 5563d88b..778191eb 100644 --- a/pkg/universe.dagger.io/go/test/test.cue +++ b/pkg/universe.dagger.io/go/test/test.cue @@ -8,7 +8,7 @@ import ( dagger.#Plan & { client: filesystem: "./data/hello": read: contents: dagger.#FS - actions: tests: test: simple: go.#Test & { + actions: test: go.#Test & { source: client.filesystem."./data/hello".read.contents package: "./greeting" } diff --git a/pkg/universe.dagger.io/netlify/test/test.bats b/pkg/universe.dagger.io/netlify/test/test.bats index 29f6d1d1..08116444 100644 --- a/pkg/universe.dagger.io/netlify/test/test.bats +++ b/pkg/universe.dagger.io/netlify/test/test.bats @@ -5,5 +5,5 @@ setup() { } @test "netlify" { - dagger up + dagger "do" test } diff --git a/pkg/universe.dagger.io/netlify/test/test.cue b/pkg/universe.dagger.io/netlify/test/test.cue index acf354b8..57d8a8b2 100644 --- a/pkg/universe.dagger.io/netlify/test/test.cue +++ b/pkg/universe.dagger.io/netlify/test/test.cue @@ -16,7 +16,7 @@ dagger.#Plan & { stdout: dagger.#Secret } - actions: tests: { + actions: test: { // Configuration common to all tests common: { diff --git a/pkg/universe.dagger.io/yarn/test/test.bats b/pkg/universe.dagger.io/yarn/test/test.bats index 3491a2e6..eb938b12 100644 --- a/pkg/universe.dagger.io/yarn/test/test.bats +++ b/pkg/universe.dagger.io/yarn/test/test.bats @@ -5,5 +5,5 @@ setup() { } @test "yarn" { - dagger up + dagger "do" test } diff --git a/pkg/universe.dagger.io/yarn/test/test.cue b/pkg/universe.dagger.io/yarn/test/test.cue index 41ec2497..bc761558 100644 --- a/pkg/universe.dagger.io/yarn/test/test.cue +++ b/pkg/universe.dagger.io/yarn/test/test.cue @@ -13,7 +13,7 @@ dagger.#Plan & { "./data/bar": read: contents: dagger.#FS } - actions: tests: { + actions: test: { // Configuration for all tests common: { diff --git a/tests/plan.bats b/tests/plan.bats index bbeeed18..2d6b4866 100644 --- a/tests/plan.bats +++ b/tests/plan.bats @@ -199,12 +199,12 @@ setup() { cd "$TESTDIR" # Run with amd64 platform - run "$DAGGER" up ./plan/platform/config_platform_linux_amd64.cue + run "$DAGGER" "do" -p./plan/platform/config_platform_linux_amd64.cue verify # Run with arm64 platform - run "$DAGGER" up ./plan/platform/config_platform_linux_arm64.cue + run "$DAGGER" "do" -p./plan/platform/config_platform_linux_arm64.cue verify # Run with invalid platform - run "$DAGGER" up ./plan/platform/config_platform_failure_invalid_platform.cue + run "$DAGGER" "do" -p./plan/platform/config_platform_failure_invalid_platform.cue verify assert_failure } diff --git a/tests/tasks.bats b/tests/tasks.bats index b26a6c4e..39340cb6 100644 --- a/tests/tasks.bats +++ b/tests/tasks.bats @@ -2,153 +2,129 @@ setup() { load 'helpers' common_setup + cd "$TESTDIR" || exit } @test "task: #Pull" { - cd "$TESTDIR"/tasks/pull - "$DAGGER" up ./pull.cue -} - -@test "task: #Pull with auth" { - cd "$TESTDIR" - "$DAGGER" up ./tasks/pull/pull_auth.cue + "$DAGGER" "do" -p ./tasks/pull/pull.cue pull + "$DAGGER" "do" -p ./tasks/pull/pull_auth.cue pull } @test "task: #Push" { - cd "$TESTDIR" - "$DAGGER" up ./tasks/push/push.cue + "$DAGGER" "do" -p ./tasks/push/push.cue pullContent } @test "task: #ReadFile" { - cd "$TESTDIR"/tasks/readfile - "$DAGGER" up + "$DAGGER" "do" -p ./tasks/readfile/readfile.cue readfile } @test "task: #WriteFile" { - cd "$TESTDIR"/tasks/writefile - "$DAGGER" up ./writefile.cue -} - -@test "task: #WriteFile failure: different contents" { - cd "$TESTDIR"/tasks/writefile - run "$DAGGER" up ./writefile_failure_diff_contents.cue + "$DAGGER" "do" -p ./tasks/writefile/writefile.cue readfile + run "$DAGGER" "do" -p ./tasks/writefile/writefile_failure_diff_contents.cue readfile assert_failure } @test "task: #Exec" { - cd "$TESTDIR"/tasks/exec - "$DAGGER" up ./args.cue - "$DAGGER" up ./env.cue - "$DAGGER" up ./env_secret.cue - "$DAGGER" up ./hosts.cue + cd ./tasks/exec + "$DAGGER" "do" -p ./args.cue verify + "$DAGGER" "do" -p ./env.cue verify + "$DAGGER" "do" -p ./env_secret.cue verify + "$DAGGER" "do" -p ./hosts.cue verify - "$DAGGER" up ./mount_cache.cue - "$DAGGER" up ./mount_fs.cue - TESTSECRET="hello world" "$DAGGER" up ./mount_secret.cue - "$DAGGER" up ./mount_tmp.cue - "$DAGGER" up ./mount_service.cue + "$DAGGER" "do" -p ./mount_cache.cue test + "$DAGGER" "do" -p ./mount_fs.cue test + TESTSECRET="hello world" "$DAGGER" "do" -p ./mount_secret.cue test + "$DAGGER" "do" -p ./mount_tmp.cue verify + "$DAGGER" "do" -p ./mount_service.cue verify - "$DAGGER" up ./user.cue - "$DAGGER" up ./workdir.cue + "$DAGGER" "do" -p ./user.cue test + "$DAGGER" "do" -p ./workdir.cue verify } @test "task: #Copy" { - cd "$TESTDIR"/tasks/copy - "$DAGGER" up ./copy_exec.cue - "$DAGGER" up ./copy_file.cue + "$DAGGER" "do" -p ./tasks/copy/copy_exec.cue test + "$DAGGER" "do" -p ./tasks/copy/copy_file.cue test - run "$DAGGER" up ./copy_exec_invalid.cue + run "$DAGGER" "do" -p ./tasks/copy/copy_exec_invalid.cue test assert_failure } @test "task: #Mkdir" { # Make directory - cd "$TESTDIR"/tasks/mkdir - "$DAGGER" up ./mkdir.cue + "$DAGGER" "do" -p ./tasks/mkdir/mkdir.cue readChecker # Create parents - cd "$TESTDIR"/tasks/mkdir - "$DAGGER" up ./mkdir_parents.cue + "$DAGGER" "do" -p ./tasks/mkdir/mkdir_parents.cue readChecker # Disable parents creation - cd "$TESTDIR"/tasks/mkdir - run "$DAGGER" up ./mkdir_failure_disable_parents.cue + run "$DAGGER" "do" -p ./tasks/mkdir/mkdir_failure_disable_parents.cue readChecker assert_failure } @test "task: #Dockerfile" { cd "$TESTDIR"/tasks/dockerfile - - "$DAGGER" up ./dockerfile.cue - "$DAGGER" up ./inlined_dockerfile.cue - "$DAGGER" up ./inlined_dockerfile_heredoc.cue - "$DAGGER" up ./dockerfile_path.cue - "$DAGGER" up ./build_args.cue - "$DAGGER" up ./image_config.cue - "$DAGGER" up ./labels.cue - "$DAGGER" up ./platform.cue - "$DAGGER" up ./build_auth.cue + "$DAGGER" "do" -p ./dockerfile.cue + "$DAGGER" "do" -p ./inlined_dockerfile.cue verify + "$DAGGER" "do" -p ./inlined_dockerfile_heredoc.cue verify + "$DAGGER" "do" -p ./dockerfile_path.cue verify + "$DAGGER" "do" -p ./build_args.cue build + "$DAGGER" "do" -p ./image_config.cue build + "$DAGGER" "do" -p ./labels.cue build + "$DAGGER" "do" -p ./platform.cue build + "$DAGGER" "do" -p ./build_auth.cue build } + @test "task: #Scratch" { - cd "$TESTDIR"/tasks/scratch - "$DAGGER" up ./scratch.cue -l debug - "$DAGGER" up ./scratch_build_scratch.cue -l debug - "$DAGGER" up ./scratch_writefile.cue -l debug + "$DAGGER" "do" -p ./tasks/scratch/scratch.cue exec + "$DAGGER" "do" -p ./tasks/scratch/scratch_build_scratch.cue build + "$DAGGER" "do" -p ./tasks/scratch/scratch_writefile.cue readfile } @test "task: #Subdir" { - cd "$TESTDIR"/tasks/subdir - "$DAGGER" up ./subdir_simple.cue + "$DAGGER" "do" -p ./tasks/subdir/subdir_simple.cue verify - run "$DAGGER" up ./subdir_invalid_path.cue + run "$DAGGER" "do" -p ./tasks/subdir/subdir_invalid_path.cue verify assert_failure - run "$DAGGER" up ./subdir_invalid_exec.cue + run "$DAGGER" "do" -p ./tasks/subdir/subdir_invalid_exec.cue verify assert_failure } @test "task: #GitPull" { - cd "$TESTDIR" - "$DAGGER" up ./tasks/gitpull/exists.cue - "$DAGGER" up ./tasks/gitpull/git_dir.cue - "$DAGGER" up ./tasks/gitpull/private_repo.cue + "$DAGGER" "do" -p ./tasks/gitpull/exists.cue gitPull + "$DAGGER" "do" -p ./tasks/gitpull/git_dir.cue verify + "$DAGGER" "do" -p ./tasks/gitpull/private_repo.cue testContent - run "$DAGGER" up ./tasks/gitpull/invalid.cue + run "$DAGGER" "do" -p ./tasks/gitpull/invalid.cue invalid assert_failure - run "$DAGGER" up ./tasks/gitpull/bad_remote.cue + run "$DAGGER" "do" -p ./tasks/gitpull/bad_remote.cue badremote assert_failure - run "$DAGGER" up ./tasks/gitpull/bad_ref.cue + run "$DAGGER" "do" -p ./tasks/gitpull/bad_ref.cue badref assert_failure } @test "task: #HTTPFetch" { - cd "$TESTDIR" - "$DAGGER" up ./tasks/httpfetch/exist.cue - run "$DAGGER" up ./tasks/httpfetch/not_exist.cue + "$DAGGER" "do" -p ./tasks/httpfetch/exist.cue fetch + run "$DAGGER" "do" -p ./tasks/httpfetch/not_exist.cue fetch assert_failure } @test "task: #NewSecret" { - cd "$TESTDIR"/tasks/newsecret - - "$DAGGER" up ./newsecret.cue + "$DAGGER" "do" -p ./tasks/newsecret/newsecret.cue verify } @test "task: #TrimSecret" { - cd "$TESTDIR"/tasks/trimsecret - - "$DAGGER" up ./trimsecret.cue + "$DAGGER" "do" -p ./tasks/trimsecret/trimsecret.cue verify } @test "task: #Source" { - cd "$TESTDIR"/tasks/source - "$DAGGER" up ./source.cue - "$DAGGER" up ./source_include_exclude.cue - "$DAGGER" up ./source_relative.cue + "$DAGGER" "do" -p ./tasks/source/source.cue test + "$DAGGER" "do" -p ./tasks/source/source_include_exclude.cue test + "$DAGGER" "do" -p ./tasks/source/source_relative.cue verifyHello - run "$DAGGER" up ./source_invalid_path.cue + run "$DAGGER" "do" -p ./tasks/source/source_invalid_path.cue source assert_failure - run "$DAGGER" up ./source_not_exist.cue + run "$DAGGER" "do" -p ./tasks/source/source_not_exist.cue source assert_failure } diff --git a/tests/tasks/copy/copy_exec.cue b/tests/tasks/copy/copy_exec.cue index 72ece6b4..c93b7669 100644 --- a/tests/tasks/copy/copy_exec.cue +++ b/tests/tasks/copy/copy_exec.cue @@ -19,28 +19,29 @@ dagger.#Plan & { """#, ] } + test: { + verify_file: dagger.#ReadFile & { + input: exec.output + path: "/output.txt" + } & { + // assert result + contents: "hello world" + } - verify_file: dagger.#ReadFile & { - input: exec.output - path: "/output.txt" - } & { - // assert result - contents: "hello world" - } + copy: dagger.#Copy & { + input: image.output + contents: exec.output + source: "/output.txt" + dest: "/output.txt" + } - copy: dagger.#Copy & { - input: image.output - contents: exec.output - source: "/output.txt" - dest: "/output.txt" - } - - verify_copy: dagger.#ReadFile & { - input: copy.output - path: "/output.txt" - } & { - // assert result - contents: "hello world" + verify_copy: dagger.#ReadFile & { + input: copy.output + path: "/output.txt" + } & { + // assert result + contents: "hello world" + } } } } diff --git a/tests/tasks/copy/copy_exec_invalid.cue b/tests/tasks/copy/copy_exec_invalid.cue index 56cc2ece..15482935 100644 --- a/tests/tasks/copy/copy_exec_invalid.cue +++ b/tests/tasks/copy/copy_exec_invalid.cue @@ -20,26 +20,28 @@ dagger.#Plan & { ] } - verify_file: dagger.#ReadFile & { - input: exec.output - path: "/output.txt" - } & { - // assert result - contents: "hello world from dagger" - } + test: { + verify_file: dagger.#ReadFile & { + input: exec.output + path: "/output.txt" + } & { + // assert result + contents: "hello world from dagger" + } - copy: dagger.#Copy & { - input: image.output - contents: exec.output - source: "/output.txt" - dest: "/output.txt" - } - verify_copy: dagger.#ReadFile & { - input: copy.output - path: "/output.txt" - } & { - // assert result - contents: "hello world" + copy: dagger.#Copy & { + input: image.output + contents: exec.output + source: "/output.txt" + dest: "/output.txt" + } + verify_copy: dagger.#ReadFile & { + input: copy.output + path: "/output.txt" + } & { + // assert result + contents: "hello world" + } } } } diff --git a/tests/tasks/copy/copy_file.cue b/tests/tasks/copy/copy_file.cue index 2fca47e2..a9d5526a 100644 --- a/tests/tasks/copy/copy_file.cue +++ b/tests/tasks/copy/copy_file.cue @@ -14,27 +14,29 @@ dagger.#Plan & { source: "busybox:1.34.1-glibc@sha256:ec98391b8f0911db08be2ee6c46813eeac17b9625b402ea1ce45dcfcd05d78d6" } - verify_alpine_3_15_0: dagger.#ReadFile & { - input: alpine3_15_0.output - path: "/etc/alpine-release" - } & { - // assert result - contents: "3.15.0\n" - } + test: { + verify_alpine_3_15_0: dagger.#ReadFile & { + input: alpine3_15_0.output + path: "/etc/alpine-release" + } & { + // assert result + contents: "3.15.0\n" + } - copy: dagger.#Copy & { - input: busybox1_34_1.output - contents: alpine3_15_0.output - source: "/etc/alpine-release" - dest: "/alpine3_15_0_release" - } + copy: dagger.#Copy & { + input: busybox1_34_1.output + contents: alpine3_15_0.output + source: "/etc/alpine-release" + dest: "/alpine3_15_0_release" + } - verify_copy: dagger.#ReadFile & { - input: copy.output - path: "/alpine3_15_0_release" - } & { - // assert result - contents: "3.15.0\n" + verify_copy: dagger.#ReadFile & { + input: copy.output + path: "/alpine3_15_0_release" + } & { + // assert result + contents: "3.15.0\n" + } } } } diff --git a/tests/tasks/dockerfile/inlined_dockerfile.cue b/tests/tasks/dockerfile/inlined_dockerfile.cue index 741613f3..ca59eb39 100644 --- a/tests/tasks/dockerfile/inlined_dockerfile.cue +++ b/tests/tasks/dockerfile/inlined_dockerfile.cue @@ -22,73 +22,3 @@ dagger.#Plan & { } } } - -// TestDockerfilePath: #up: [ -// op.#DockerBuild & { -// context: TestData -// dockerfilePath: "./dockerfilepath/Dockerfile.custom" -// }, -// op.#Exec & { -// args: ["sh", "-c", "test $(cat /test) = dockerfilePath"] -// }, -// ] - -// TestBuildArgs: #up: [ -// op.#DockerBuild & { -// dockerfile: """ -// FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d -// ARG TEST=foo -// RUN test "${TEST}" = "bar" -// """ -// buildArg: TEST: "bar" -// }, -// ] - -// // FIXME: this doesn't test anything beside not crashing -// TestBuildLabels: #up: [ -// op.#DockerBuild & { -// dockerfile: """ -// FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d -// """ -// label: FOO: "bar" -// }, -// ] - -// // FIXME: this doesn't test anything beside not crashing -// TestBuildPlatform: #up: [ -// op.#DockerBuild & { -// dockerfile: """ -// FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d -// """ -// platforms: ["linux/amd64"] -// }, -// ] - -// TestImageMetadata: #up: [ -// op.#DockerBuild & { -// dockerfile: """ -// FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d -// ENV CHECK foobar -// ENV DOUBLECHECK test -// """ -// }, -// op.#Exec & { -// args: ["sh", "-c", #""" -// env -// test "$CHECK" = "foobar" -// """#] -// }, -// ] - -// // Make sure the metadata is carried over with a `Load` -// TestImageMetadataIndirect: #up: [ -// op.#Load & { -// from: TestImageMetadata -// }, -// op.#Exec & { -// args: ["sh", "-c", #""" -// env -// test "$DOUBLECHECK" = "test" -// """#] -// }, -// ] diff --git a/tests/tasks/dockerfile/inlined_dockerfile_heredoc.cue b/tests/tasks/dockerfile/inlined_dockerfile_heredoc.cue index 69542e7c..5e17cd16 100644 --- a/tests/tasks/dockerfile/inlined_dockerfile_heredoc.cue +++ b/tests/tasks/dockerfile/inlined_dockerfile_heredoc.cue @@ -23,73 +23,3 @@ dagger.#Plan & { } } } - -// TestDockerfilePath: #up: [ -// op.#DockerBuild & { -// context: TestData -// dockerfilePath: "./dockerfilepath/Dockerfile.custom" -// }, -// op.#Exec & { -// args: ["sh", "-c", "test $(cat /test) = dockerfilePath"] -// }, -// ] - -// TestBuildArgs: #up: [ -// op.#DockerBuild & { -// dockerfile: """ -// FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d -// ARG TEST=foo -// RUN test "${TEST}" = "bar" -// """ -// buildArg: TEST: "bar" -// }, -// ] - -// // FIXME: this doesn't test anything beside not crashing -// TestBuildLabels: #up: [ -// op.#DockerBuild & { -// dockerfile: """ -// FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d -// """ -// label: FOO: "bar" -// }, -// ] - -// // FIXME: this doesn't test anything beside not crashing -// TestBuildPlatform: #up: [ -// op.#DockerBuild & { -// dockerfile: """ -// FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d -// """ -// platforms: ["linux/amd64"] -// }, -// ] - -// TestImageMetadata: #up: [ -// op.#DockerBuild & { -// dockerfile: """ -// FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d -// ENV CHECK foobar -// ENV DOUBLECHECK test -// """ -// }, -// op.#Exec & { -// args: ["sh", "-c", #""" -// env -// test "$CHECK" = "foobar" -// """#] -// }, -// ] - -// // Make sure the metadata is carried over with a `Load` -// TestImageMetadataIndirect: #up: [ -// op.#Load & { -// from: TestImageMetadata -// }, -// op.#Exec & { -// args: ["sh", "-c", #""" -// env -// test "$DOUBLECHECK" = "test" -// """#] -// }, -// ] diff --git a/tests/tasks/exec/env_secret.cue b/tests/tasks/exec/env_secret.cue index 2e290992..150d9395 100644 --- a/tests/tasks/exec/env_secret.cue +++ b/tests/tasks/exec/env_secret.cue @@ -6,6 +6,7 @@ import ( dagger.#Plan & { client: filesystem: "secret.txt": read: contents: dagger.#Secret + actions: { image: dagger.#Pull & { source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3" diff --git a/tests/tasks/exec/mount_cache.cue b/tests/tasks/exec/mount_cache.cue index 06706897..e344c7a7 100644 --- a/tests/tasks/exec/mount_cache.cue +++ b/tests/tasks/exec/mount_cache.cue @@ -28,36 +28,38 @@ dagger.#Plan & { ] } - verify: dagger.#Exec & { - input: image.output - mounts: cache: { - dest: "/cache" - contents: exec.mounts.cache.contents + test: { + verify: dagger.#Exec & { + input: image.output + mounts: cache: { + dest: "/cache" + contents: exec.mounts.cache.contents + } + args: [ + "sh", "-c", + #""" + test -f /cache/output.txt + test "$(cat /cache/output.txt)" = "hello world" + """#, + ] } - args: [ - "sh", "-c", - #""" - test -f /cache/output.txt - test "$(cat /cache/output.txt)" = "hello world" - """#, - ] - } - otherCache: dagger.#CacheDir & { - id: "othercache" - } - verifyOtherCache: dagger.#Exec & { - input: image.output - mounts: cache: { - dest: "/cache" - contents: otherCache + otherCache: dagger.#CacheDir & { + id: "othercache" + } + verifyOtherCache: dagger.#Exec & { + input: image.output + mounts: cache: { + dest: "/cache" + contents: otherCache + } + args: [ + "sh", "-c", + #""" + test ! -f /cache/output.txt + """#, + ] } - args: [ - "sh", "-c", - #""" - test ! -f /cache/output.txt - """#, - ] } } } diff --git a/tests/tasks/exec/mount_fs.cue b/tests/tasks/exec/mount_fs.cue index 0296e820..1bf0827e 100644 --- a/tests/tasks/exec/mount_fs.cue +++ b/tests/tasks/exec/mount_fs.cue @@ -20,52 +20,54 @@ dagger.#Plan & { ] } - verify: dagger.#Exec & { - input: image.output - mounts: fs: { - dest: "/target" - contents: exec.output + test: { + verify: dagger.#Exec & { + input: image.output + mounts: fs: { + dest: "/target" + contents: exec.output + } + args: [ + "sh", "-c", + #""" + test "$(cat /target/output.txt)" = "hello world" + touch /target/rw + """#, + ] } - args: [ - "sh", "-c", - #""" - test "$(cat /target/output.txt)" = "hello world" - touch /target/rw - """#, - ] - } - verifyRO: dagger.#Exec & { - input: image.output - mounts: fs: { - dest: "/target" - contents: exec.output - ro: true + verifyRO: dagger.#Exec & { + input: image.output + mounts: fs: { + dest: "/target" + contents: exec.output + ro: true + } + args: [ + "sh", "-c", + #""" + test "$(cat /target/output.txt)" = "hello world" + + touch /target/ro && exit 1 + true + """#, + ] } - args: [ - "sh", "-c", - #""" - test "$(cat /target/output.txt)" = "hello world" - touch /target/ro && exit 1 - true - """#, - ] - } - - verifySource: dagger.#Exec & { - input: image.output - mounts: fs: { - dest: "/target.txt" - contents: exec.output - source: "/output.txt" + verifySource: dagger.#Exec & { + input: image.output + mounts: fs: { + dest: "/target.txt" + contents: exec.output + source: "/output.txt" + } + args: [ + "sh", "-c", + #""" + test "$(cat /target.txt)" = "hello world" + """#, + ] } - args: [ - "sh", "-c", - #""" - test "$(cat /target.txt)" = "hello world" - """#, - ] } } } diff --git a/tests/tasks/exec/mount_secret.cue b/tests/tasks/exec/mount_secret.cue index d00ebbc7..babd2ed6 100644 --- a/tests/tasks/exec/mount_secret.cue +++ b/tests/tasks/exec/mount_secret.cue @@ -11,39 +11,40 @@ dagger.#Plan & { source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3" } - verify: dagger.#Exec & { - input: image.output - mounts: secret: { - dest: "/run/secrets/test" - contents: client.env.TESTSECRET + test: { + verify: dagger.#Exec & { + input: image.output + mounts: secret: { + dest: "/run/secrets/test" + contents: client.env.TESTSECRET + } + args: [ + "sh", "-c", + #""" + test "$(cat /run/secrets/test)" = "hello world" + ls -l /run/secrets/test | grep -- "-r--------" + """#, + ] } - args: [ - "sh", "-c", - #""" - test "$(cat /run/secrets/test)" = "hello world" - ls -l /run/secrets/test | grep -- "-r--------" - """#, - ] - } - verifyPerm: dagger.#Exec & { - input: image.output - mounts: secret: { - dest: "/run/secrets/test" - contents: client.env.TESTSECRET - uid: 42 - gid: 24 - mask: 0o666 + verifyPerm: dagger.#Exec & { + input: image.output + mounts: secret: { + dest: "/run/secrets/test" + contents: client.env.TESTSECRET + uid: 42 + gid: 24 + mask: 0o666 + } + args: [ + "sh", "-c", + #""" + ls -l /run/secrets/test | grep -- "-rw-rw-rw-" + ls -l /run/secrets/test | grep -- "42" + ls -l /run/secrets/test | grep -- "24" + """#, + ] } - args: [ - "sh", "-c", - #""" - ls -l /run/secrets/test | grep -- "-rw-rw-rw-" - ls -l /run/secrets/test | grep -- "42" - ls -l /run/secrets/test | grep -- "24" - """#, - ] } - } } diff --git a/tests/tasks/exec/user.cue b/tests/tasks/exec/user.cue index 0c9f5429..bca459a0 100644 --- a/tests/tasks/exec/user.cue +++ b/tests/tasks/exec/user.cue @@ -14,28 +14,28 @@ dagger.#Plan & { input: image.output args: ["adduser", "-D", "test"] } + test: { + verifyUsername: dagger.#Exec & { + input: addUser.output + user: "test" + args: [ + "sh", "-c", + #""" + test "$(whoami)" = "test" + """#, + ] + } - verifyUsername: dagger.#Exec & { - input: addUser.output - user: "test" - args: [ - "sh", "-c", - #""" - test "$(whoami)" = "test" - """#, - ] + verifyUserID: dagger.#Exec & { + input: addUser.output + user: "1000" + args: [ + "sh", "-c", + #""" + test "$(whoami)" = "test" + """#, + ] + } } - - verifyUserID: dagger.#Exec & { - input: addUser.output - user: "1000" - args: [ - "sh", "-c", - #""" - test "$(whoami)" = "test" - """#, - ] - } - } } diff --git a/tests/tasks/source/source.cue b/tests/tasks/source/source.cue index 76988b7f..47b1cf44 100644 --- a/tests/tasks/source/source.cue +++ b/tests/tasks/source/source.cue @@ -23,20 +23,22 @@ dagger.#Plan & { args: ["/src/test.sh"] } - verifyHello: dagger.#ReadFile & { - input: source.output - path: "/world.txt" - } & { - // assert result - contents: "world\n" - } + test: { + verifyHello: dagger.#ReadFile & { + input: source.output + path: "/world.txt" + } & { + // assert result + contents: "world\n" + } - verifyWorld: dagger.#ReadFile & { - input: exec.output - path: "/test.txt" - } & { - // assert result - contents: "hello world" + verifyWorld: dagger.#ReadFile & { + input: exec.output + path: "/test.txt" + } & { + // assert result + contents: "hello world" + } } } }