engine.#Build support
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
committed by
Sam Alba
parent
13e7236c8b
commit
2467fb1920
@@ -60,7 +60,6 @@ setup() {
|
||||
assert_failure
|
||||
}
|
||||
|
||||
|
||||
@test "task: #Mkdir" {
|
||||
# Make directory
|
||||
cd "$TESTDIR"/tasks/mkdir
|
||||
@@ -74,4 +73,16 @@ setup() {
|
||||
cd "$TESTDIR"/tasks/mkdir
|
||||
run "$DAGGER" --europa up ./mkdir_failure_disable_parents.cue
|
||||
assert_failure
|
||||
}
|
||||
}
|
||||
|
||||
@test "task: #Build" {
|
||||
cd "$TESTDIR"/tasks/build
|
||||
|
||||
"$DAGGER" --europa up ./dockerfile.cue
|
||||
"$DAGGER" --europa up ./inlined_dockerfile.cue
|
||||
"$DAGGER" --europa up ./dockerfile_path.cue
|
||||
"$DAGGER" --europa up ./build_args.cue
|
||||
"$DAGGER" --europa up ./image_config.cue
|
||||
"$DAGGER" --europa up ./labels.cue
|
||||
"$DAGGER" --europa up ./platform.cue
|
||||
}
|
||||
|
19
tests/tasks/build/build_args.cue
Normal file
19
tests/tasks/build/build_args.cue
Normal file
@@ -0,0 +1,19 @@
|
||||
package testing
|
||||
|
||||
import (
|
||||
"alpha.dagger.io/europa/dagger/engine"
|
||||
)
|
||||
|
||||
engine.#Plan & {
|
||||
inputs: directories: testdata: path: "./testdata"
|
||||
|
||||
actions: build: engine.#Build & {
|
||||
source: inputs.directories.testdata.contents
|
||||
dockerfile: contents: """
|
||||
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
|
||||
ARG TEST=foo
|
||||
RUN test "${TEST}" = "bar"
|
||||
"""
|
||||
buildArg: TEST: "bar"
|
||||
}
|
||||
}
|
1
tests/tasks/build/cue.mod/module.cue
Normal file
1
tests/tasks/build/cue.mod/module.cue
Normal file
@@ -0,0 +1 @@
|
||||
module: ""
|
3
tests/tasks/build/cue.mod/pkg/.gitignore
vendored
Normal file
3
tests/tasks/build/cue.mod/pkg/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# generated by dagger
|
||||
alpha.dagger.io
|
||||
dagger.lock
|
20
tests/tasks/build/dockerfile.cue
Normal file
20
tests/tasks/build/dockerfile.cue
Normal file
@@ -0,0 +1,20 @@
|
||||
package testing
|
||||
|
||||
import (
|
||||
"alpha.dagger.io/europa/dagger/engine"
|
||||
)
|
||||
|
||||
engine.#Plan & {
|
||||
inputs: directories: testdata: path: "./testdata"
|
||||
|
||||
actions: {
|
||||
build: engine.#Build & {
|
||||
source: inputs.directories.testdata.contents
|
||||
}
|
||||
|
||||
verify: engine.#Exec & {
|
||||
input: build.output
|
||||
args: ["sh", "-c", "test $(cat /dir/foo) = foobar"]
|
||||
}
|
||||
}
|
||||
}
|
21
tests/tasks/build/dockerfile_path.cue
Normal file
21
tests/tasks/build/dockerfile_path.cue
Normal file
@@ -0,0 +1,21 @@
|
||||
package testing
|
||||
|
||||
import (
|
||||
"alpha.dagger.io/europa/dagger/engine"
|
||||
)
|
||||
|
||||
engine.#Plan & {
|
||||
inputs: directories: testdata: path: "./testdata"
|
||||
|
||||
actions: {
|
||||
build: engine.#Build & {
|
||||
source: inputs.directories.testdata.contents
|
||||
dockerfile: path: "./dockerfilepath/Dockerfile.custom"
|
||||
}
|
||||
|
||||
verify: engine.#Exec & {
|
||||
input: build.output
|
||||
args: ["sh", "-c", "test $(cat /test) = dockerfilePath"]
|
||||
}
|
||||
}
|
||||
}
|
26
tests/tasks/build/image_config.cue
Normal file
26
tests/tasks/build/image_config.cue
Normal file
@@ -0,0 +1,26 @@
|
||||
package testing
|
||||
|
||||
import (
|
||||
"alpha.dagger.io/europa/dagger/engine"
|
||||
)
|
||||
|
||||
engine.#Plan & {
|
||||
inputs: directories: testdata: path: "./testdata"
|
||||
|
||||
actions: {
|
||||
// FIXME: this doesn't test anything beside not crashing
|
||||
build: engine.#Build & {
|
||||
source: inputs.directories.testdata.contents
|
||||
dockerfile: contents: """
|
||||
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
|
||||
ENV test foobar
|
||||
CMD /test-cmd
|
||||
"""
|
||||
} & {
|
||||
config: {
|
||||
Env: ["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "test=foobar"]
|
||||
Cmd: ["/bin/sh", "-c", "/test-cmd"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
94
tests/tasks/build/inlined_dockerfile.cue
Normal file
94
tests/tasks/build/inlined_dockerfile.cue
Normal file
@@ -0,0 +1,94 @@
|
||||
package testing
|
||||
|
||||
import (
|
||||
"alpha.dagger.io/europa/dagger/engine"
|
||||
)
|
||||
|
||||
engine.#Plan & {
|
||||
inputs: directories: testdata: path: "./testdata"
|
||||
|
||||
actions: {
|
||||
build: engine.#Build & {
|
||||
source: inputs.directories.testdata.contents
|
||||
dockerfile: contents: """
|
||||
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
|
||||
RUN echo foobar > /output
|
||||
"""
|
||||
}
|
||||
|
||||
verify: engine.#Exec & {
|
||||
input: build.output
|
||||
args: ["sh", "-c", "test $(cat /output) = foobar"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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"
|
||||
// """#]
|
||||
// },
|
||||
// ]
|
20
tests/tasks/build/labels.cue
Normal file
20
tests/tasks/build/labels.cue
Normal file
@@ -0,0 +1,20 @@
|
||||
package testing
|
||||
|
||||
import (
|
||||
"alpha.dagger.io/europa/dagger/engine"
|
||||
)
|
||||
|
||||
engine.#Plan & {
|
||||
inputs: directories: testdata: path: "./testdata"
|
||||
|
||||
actions: {
|
||||
// FIXME: this doesn't test anything beside not crashing
|
||||
build: engine.#Build & {
|
||||
source: inputs.directories.testdata.contents
|
||||
dockerfile: contents: """
|
||||
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
|
||||
"""
|
||||
label: FOO: "bar"
|
||||
}
|
||||
}
|
||||
}
|
20
tests/tasks/build/platform.cue
Normal file
20
tests/tasks/build/platform.cue
Normal file
@@ -0,0 +1,20 @@
|
||||
package testing
|
||||
|
||||
import (
|
||||
"alpha.dagger.io/europa/dagger/engine"
|
||||
)
|
||||
|
||||
engine.#Plan & {
|
||||
inputs: directories: testdata: path: "./testdata"
|
||||
|
||||
actions: {
|
||||
// FIXME: this doesn't test anything beside not crashing
|
||||
build: engine.#Build & {
|
||||
source: inputs.directories.testdata.contents
|
||||
dockerfile: contents: """
|
||||
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
|
||||
"""
|
||||
platforms: ["linux/amd64"]
|
||||
}
|
||||
}
|
||||
}
|
3
tests/tasks/build/testdata/Dockerfile
vendored
Normal file
3
tests/tasks/build/testdata/Dockerfile
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
|
||||
COPY . /dir
|
||||
RUN test $(cat /dir/foo) = foobar
|
2
tests/tasks/build/testdata/dockerfilepath/Dockerfile.custom
vendored
Normal file
2
tests/tasks/build/testdata/dockerfilepath/Dockerfile.custom
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
|
||||
RUN echo dockerfilePath > /test
|
1
tests/tasks/build/testdata/foo
vendored
Normal file
1
tests/tasks/build/testdata/foo
vendored
Normal file
@@ -0,0 +1 @@
|
||||
foobar
|
Reference in New Issue
Block a user