engine.#Build support

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi
2021-12-20 19:52:22 +01:00
committed by Sam Alba
parent 13e7236c8b
commit 2467fb1920
15 changed files with 469 additions and 3 deletions

View File

@@ -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
}

View 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"
}
}

View File

@@ -0,0 +1 @@
module: ""

View File

@@ -0,0 +1,3 @@
# generated by dagger
alpha.dagger.io
dagger.lock

View 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"]
}
}
}

View 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"]
}
}
}

View 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"]
}
}
}
}

View 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"
// """#]
// },
// ]

View 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"
}
}
}

View 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
View File

@@ -0,0 +1,3 @@
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
COPY . /dir
RUN test $(cat /dir/foo) = foobar

View File

@@ -0,0 +1,2 @@
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
RUN echo dockerfilePath > /test

1
tests/tasks/build/testdata/foo vendored Normal file
View File

@@ -0,0 +1 @@
foobar