tests: migrate ops test to bats

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi
2021-04-14 16:07:17 -07:00
parent 5582f92a72
commit 381db37ca3
64 changed files with 220 additions and 190 deletions

45
tests/ops/copy/invalid/cache/main.cue vendored Normal file
View File

@@ -0,0 +1,45 @@
package testing
test1: {
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"
},
]
}
test2: {
string
#up: [
{
do: "fetch-container"
ref: "busybox"
},
{
do: "copy"
from: [{do: "fetch-container", ref: "busybox"}]
src: "/etc/issue"
dest: "/"
},
{
do: "export"
source: "/issue"
format: "string"
},
]
}

View File

@@ -0,0 +1,65 @@
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"
},
]
}

View File

@@ -0,0 +1,23 @@
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"
},
]
}

View File

@@ -0,0 +1,122 @@
package test
import (
"dagger.io/dagger"
"dagger.io/dagger/op"
)
// Set to `--input-dir=./tests/dockerbuild/testdata`
TestData: dagger.#Artifact
TestInlinedDockerfile: #up: [
op.#DockerBuild & {
dockerfile: """
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
RUN echo hello world
"""
},
]
TestOpChaining: #up: [
op.#DockerBuild & {
dockerfile: """
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
RUN echo foobar > /output
"""
},
op.#Exec & {
args: ["sh", "-c", "test $(cat /output) = foobar"]
},
]
TestBuildContext: #up: [
op.#DockerBuild & {
context: TestData
},
op.#Exec & {
args: ["sh", "-c", "test $(cat /dir/foo) = foobar"]
},
]
TestBuildContextAndDockerfile: #up: [
op.#DockerBuild & {
context: TestData
dockerfile: """
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
COPY foo /override
"""
},
op.#Exec & {
args: ["sh", "-c", "test $(cat /override) = 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,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/ops/dockerbuild/testdata/foo vendored Normal file
View File

@@ -0,0 +1 @@
foobar

View File

@@ -0,0 +1,13 @@
package testing
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["echo", "always output"]
always: true
},
]

View File

@@ -0,0 +1,16 @@
package testing
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
echo "pwd is: $(pwd)"
[ "$(pwd)" == "/thisisnonexistent" ] || exit 1
"""]
dir: "/thisisnonexistent"
},
]

View File

@@ -0,0 +1,16 @@
package testing
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
echo "pwd is: $(pwd)"
[ "$(pwd)" == "/etc" ] || exit 1
"""]
dir: "/etc"
},
]

15
tests/ops/exec/env/invalid/main.cue vendored Normal file
View File

@@ -0,0 +1,15 @@
package testing
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", #"""
echo "$foo"
"""#]
env: foo: lala: "lala"
},
]

18
tests/ops/exec/env/overlay/main.cue vendored Normal file
View File

@@ -0,0 +1,18 @@
package testing
bar: string
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
echo "foo: $foo"
[ "$foo" == "overlay environment" ] || exit 1
"""]
env: foo: bar
},
]

15
tests/ops/exec/env/valid/main.cue vendored Normal file
View File

@@ -0,0 +1,15 @@
package testing
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
[ "$foo" == "output environment" ] || exit 1
"""]
env: foo: "output environment"
},
]

View File

@@ -0,0 +1,12 @@
package testing
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["erroringout"]
},
]

View File

@@ -0,0 +1,14 @@
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: "/"
},
]

View File

@@ -0,0 +1,11 @@
package testing
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
},
]

View File

@@ -0,0 +1,12 @@
package testing
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["echo", "simple output"]
},
]

View File

@@ -0,0 +1,20 @@
package testing
hello: "world"
bar: string
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
dir: "/"
args: ["sh", "-c", """
echo \(hello)
echo "This test SHOULD fail, because this script SHOULD execute, since bar is not referenced"
exit 1
"""]
},
]

View File

@@ -0,0 +1,20 @@
package testing
hello: "world"
bar: string
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
dir: "/"
args: ["sh", "-c", """
echo \(bar)
echo "This test SHOULD succeed, because this is never going to be executed, as \(bar) is not concrete"
exit 1
"""]
},
]

View File

@@ -0,0 +1 @@
module: "dagger.io/testing"

View File

@@ -0,0 +1,17 @@
package def
#dang: string
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
dir: "/"
args: ["sh", "-c", """
echo success
"""]
},
]

View File

@@ -0,0 +1,12 @@
package testing
import (
"dagger.io/def"
)
#up: [
{
do: "load",
from: def
},
]

View File

@@ -0,0 +1 @@
module: "dagger.io/testing"

View File

@@ -0,0 +1,18 @@
package nonoptional
dang: string
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
dir: "/"
args: ["sh", "-c", """
echo "This test SHOULD fail, because this SHOULD be executed"
exit 1
"""]
},
]

View File

@@ -0,0 +1,12 @@
package testing
import (
"dagger.io/nonoptional"
)
#up: [
{
do: "load",
from: nonoptional
},
]

View File

@@ -0,0 +1 @@
module: "dagger.io/testing"

View File

@@ -0,0 +1,17 @@
package optional
dang?: string
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
dir: "/"
args: ["sh", "-c", """
echo success
"""]
},
]

View File

@@ -0,0 +1,12 @@
package testing
import (
"dagger.io/optional"
)
#up: [
{
do: "load",
from: optional
},
]

View File

@@ -0,0 +1,26 @@
package testing
test: {
bool
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
printf "true" > /tmp/out
""",
]
dir: "/"
},
{
do: "export"
// Source path in the container
source: "/tmp/out"
format: "json"
},
]
}

View File

@@ -0,0 +1,241 @@
package testing
test1: {
string
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
echo lol1 > /tmp/out
"""]
dir: "/"
always: true
},
{
do: "export"
source: "/tmp/out"
format: "string"
},
]
}
test2: {
string
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
echo lol2 > /tmp/out
"""]
dir: "/"
always: true
},
{
do: "export"
source: "/tmp/out"
format: "string"
},
]
}
test3: {
string
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
echo lol3 > /tmp/out
"""]
dir: "/"
always: true
},
{
do: "export"
source: "/tmp/out"
format: "string"
},
]
}
test4: {
string
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
echo lol4 > /tmp/out
"""]
dir: "/"
always: true
},
{
do: "export"
source: "/tmp/out"
format: "string"
},
]
}
test5: {
string
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
echo lol5 > /tmp/out
"""]
dir: "/"
always: true
},
{
do: "export"
source: "/tmp/out"
format: "string"
},
]
}
test6: {
string
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
echo lol6 > /tmp/out
"""]
dir: "/"
always: true
},
{
do: "export"
source: "/tmp/out"
format: "string"
},
]
}
test7: {
string
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
echo lol7 > /tmp/out
"""]
dir: "/"
always: true
},
{
do: "export"
source: "/tmp/out"
format: "string"
},
]
}
test8: {
string
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
echo lol8 > /tmp/out
"""]
dir: "/"
always: true
},
{
do: "export"
source: "/tmp/out"
format: "string"
},
]
}
test9: {
string
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
echo lol9 > /tmp/out
"""]
dir: "/"
always: true
},
{
do: "export"
source: "/tmp/out"
format: "string"
},
]
}
test10: {
string
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
echo lol10 > /tmp/out
"""]
dir: "/"
always: true
},
{
do: "export"
source: "/tmp/out"
format: "string"
},
]
}

View File

@@ -0,0 +1,25 @@
package testing
test: {
float
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
echo -123.5 > /tmp/out
""",
]
},
{
do: "export"
// Source path in the container
source: "/tmp/out"
format: "json"
},
]
}

View File

@@ -0,0 +1,25 @@
package testing
teststring: {
string
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
echo something > /tmp/out
""",
]
},
{
do: "export"
// Source path in the container
source: "/tmp/out"
format: "lalalalal"
},
]
}

View File

@@ -0,0 +1,18 @@
package testing
teststring: {
string
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "export"
// Source path in the container
source: "/tmp/lalala"
format: "string"
},
]
}

View File

@@ -0,0 +1,26 @@
package testing
test: {
string
=~"^NAAAA.+"
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
printf something > /tmp/out
""",
]
},
{
do: "export"
// Source path in the container
source: "/tmp/out"
format: "string"
},
]
}

View File

@@ -0,0 +1,73 @@
package testing
testScalar: {
bool
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
echo true > /tmp/out
""",
]
dir: "/"
},
{
do: "export"
// Source path in the container
source: "/tmp/out"
format: "json"
},
]
}
testMap: #up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
echo '{"something": "something"}' > /tmp/out
""",
]
dir: "/"
},
{
do: "export"
// Source path in the container
source: "/tmp/out"
format: "json"
},
]
// FIXME: lists are currently broken
// testList: {
// [...string]
// #up: [
// {
// do: "fetch-container"
// ref: "alpine"
// },
// {
// do: "exec"
// args: ["sh", "-c", """
// echo '["milk", "pumpkin pie", "eggs", "juice"]' > /tmp/out
// """,
// ]
// dir: "/"
// },
// {
// do: "export"
// // Source path in the container
// source: "/tmp/out"
// format: "json"
// },
// ]
// }

View File

@@ -0,0 +1,25 @@
package testing
test: {
number
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
echo -123.5 > /tmp/out
""",
]
},
{
do: "export"
// Source path in the container
source: "/tmp/out"
format: "json"
},
]
}

View File

@@ -0,0 +1,25 @@
package testing
test: {
string
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
printf something > /tmp/out
""",
]
},
{
do: "export"
// Source path in the container
source: "/tmp/out"
format: "string"
},
]
}

View File

@@ -0,0 +1,26 @@
package testing
test: {
string
=~"^some.+"
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
printf something > /tmp/out
""",
]
},
{
do: "export"
// Source path in the container
source: "/tmp/out"
format: "string"
},
]
}

View File

@@ -0,0 +1,75 @@
package testing
testScalar: {
bool
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
echo true > /tmp/out
""",
]
// XXX Blocked by https://github.com/blocklayerhq/dagger/issues/19
dir: "/"
},
{
do: "export"
// Source path in the container
source: "/tmp/out"
format: "yaml"
},
]
}
// FIXME: lists are currently broken
// testList: {
// [...string]
// #up: [
// {
// do: "fetch-container"
// ref: "alpine"
// },
// {
// do: "exec"
// args: ["sh", "-c", """
// echo "--- # Shopping list
// [milk, pumpkin pie, eggs, juice]" > /tmp/out
// """,
// ]
// // XXX Blocked by https://github.com/blocklayerhq/dagger/issues/19
// dir: "/"
// },
// {
// do: "export"
// // Source path in the container
// source: "/tmp/out"
// format: "yaml"
// },
// ]
// }
testMap: #up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
echo something: something > /tmp/out
""",
]
},
{
do: "export"
// Source path in the container
source: "/tmp/out"
format: "yaml"
},
]

View File

@@ -0,0 +1,36 @@
package testing
busybox1: #up: [
{
do: "fetch-container"
ref: "busybox"
},
]
busybox2: #up: [
{
do: "fetch-container"
ref: "busybox:latest"
},
]
busybox3: #up: [
{
do: "fetch-container"
ref: "busybox:1.33-musl"
},
]
busybox4: #up: [
{
do: "fetch-container"
ref: "busybox@sha256:e2af53705b841ace3ab3a44998663d4251d33ee8a9acaf71b66df4ae01c3bbe7"
},
]
busybox5: #up: [
{
do: "fetch-container"
ref: "busybox:1.33-musl@sha256:e2af53705b841ace3ab3a44998663d4251d33ee8a9acaf71b66df4ae01c3bbe7"
},
]

View File

@@ -0,0 +1,7 @@
package testing
#up: [
{
do: "fetch-container"
},
]

View File

@@ -0,0 +1,8 @@
package testing
#up: [
{
do: "fetch-container"
ref: "alpine@sha256:c6c7524e2111f22a9f7577211232d89a9e68cf5b9ed4a41ba77957c9771380a5"
},
]

View File

@@ -0,0 +1,10 @@
package testing
// 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"
ref: "busyboxaaa@sha256:e2af53705b841ace3ab3a44998663d4251d33ee8a9acaf71b66df4ae01c3bbe7"
},
]

View File

@@ -0,0 +1,8 @@
package testing
#up: [
{
do: "fetch-container"
ref: "doesnotexist"
},
]

View File

@@ -0,0 +1,8 @@
package testing
#up: [
{
do: "fetch-container"
ref: "alpine:doesnotexist"
},
]

View File

@@ -0,0 +1,9 @@
package testing
#up: [
{
do: "fetch-git"
remote: "https://github.com/blocklayerhq/acme-clothing.git"
ref: "master"
},
]

View File

@@ -0,0 +1,7 @@
package testing
#up: [
{
do: "fetch-git"
},
]

View File

@@ -0,0 +1,9 @@
package testing
#up: [
{
do: "fetch-git"
remote: "pork://pork"
ref: "master"
},
]

View File

@@ -0,0 +1,9 @@
package testing
#up: [
{
do: "fetch-git"
remote: "https://github.com/blocklayerhq/acme-clothing.git"
ref: "lalalalal"
},
]

View File

@@ -0,0 +1,9 @@
package testing
#up: [
{
do: "fetch-git"
remote: "https://github.com/blocklayerhq/lalalala.git"
ref: "master"
},
]

33
tests/ops/load/invalid/cache/main.cue vendored Normal file
View File

@@ -0,0 +1,33 @@
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"
},
]
}

View File

@@ -0,0 +1,53 @@
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"
},
]
}

View File

@@ -0,0 +1,17 @@
package testing
test: {
string
#up: [
{
do: "load"
from: [{do: "fetch-container", ref: "alpine"}]
},
{
do: "export"
source: "/etc/issue"
format: "string"
},
]
}

25
tests/ops/mounts/valid/cache/main.cue vendored Normal file
View File

@@ -0,0 +1,25 @@
package testing
test: {
string
#up: [
{
do: "load"
from: [{do: "fetch-container", ref: "alpine"}]
},
{
do: "exec"
args: ["sh", "-c", """
echo "NOT SURE WHAT TO TEST YET" > /out
"""]
dir: "/"
mount: something: "cache"
},
{
do: "export"
source: "/out"
format: "string"
},
]
}

View File

@@ -0,0 +1,35 @@
package testing
test: {
string
#up: [
{
do: "load"
from: [{do: "fetch-container", ref: "alpine"}]
},
{
do: "exec"
args: ["sh", "-c", """
cat /mnt/test/lol > /out
"""]
mount: "/mnt/test": from: #up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
echo -n "hello world" > /lol
"""]
},
]
},
{
do: "export"
source: "/out"
format: "string"
},
]
}

View File

@@ -0,0 +1,31 @@
package testing
test: {
string
#up: [
{
do: "load"
from: [{do: "fetch-container", ref: "alpine"}]
},
{
do: "exec"
args: ["sh", "-c", """
ls -lA /lol > /out
"""]
dir: "/"
mount: something: {
input: [{
do: "fetch-container"
ref: "alpine"
}]
path: "/lol"
}
},
{
do: "export"
source: "/out"
format: "string"
},
]
}

View File

@@ -0,0 +1,34 @@
package testing
test: {
string
#up: [
{
do: "load"
from: [{do: "fetch-container", ref: "alpine"}]
},
{
do: "exec"
args: ["sh", "-c", """
echo ok > /out
echo ok > /tmpdir/out
"""]
dir: "/"
mount: "/tmpdir": "tmpfs"
},
{
do: "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"
source: "/out"
format: "string"
},
]
}

View File

@@ -0,0 +1,33 @@
registry:
username: ENC[AES256_GCM,data:8AH6p9WHidanCA==,iv:ezThCQJv+bVBf8SdfSa2HFoP+eu6IZMPl5xvMOGDcps=,tag:mzR7xTKeQNDvkyd2Dm3AKw==,type:str]
token: ENC[AES256_GCM,data:68d31b3EfnQJofIt6j+iBCtDyLOBWjFqvVmejyDjIOh8oBXP,iv:PMghC2nd7jqAzrQzm/PW1YdbE0VAbEBkK0/Ri1WwduI=,tag:0JH4WbcJHvgzF4VIK4deBg==,type:str]
sops:
kms: []
gcp_kms: []
azure_kv: []
hc_vault: []
lastmodified: '2021-03-18T22:59:59Z'
mac: ENC[AES256_GCM,data:3++nHOAJaYFCEuUXim4/gOsG1ZVWt8Ab88qaqHM6jpCA2gLSyADWpB5iQfU9bM7Sq3PgCcWd5+mDHxl5Q8r9fiozrS025OLtsn7qQQQ84WaiFz9Y4Trsbe4EJXNpxYDXjLZEkEtkKs4/Dl+y2Ey3nVyIWKZEX9cPogJ64zfFS9Q=,iv:jvSwxJ8Of2Nfp1ijKItOraDO8aS6aGHQKFY61kF8JS8=,tag:I+AWPIZsPeXU30zxbgq2eQ==,type:str]
pgp:
- created_at: '2021-03-18T22:59:59Z'
enc: |
-----BEGIN PGP MESSAGE-----
hQIMAzqVY590vudzAQ//etnfnpfCo9rAkctR+Fwg/7VdVL3Rov+6gnyjUnoN1BS1
8jnBF/86AZ7uK89dTcTZCsK1hKPxeYg1kJTKpA+zfDORupzTWcMrRyjwNk5wQ2Vg
N1adUwFsBQpk8WptpsU/ro6+3yH+Nn35begs6hP2fH/EQ9XOxw5gY0kp0AFjGaKJ
tRZVrr3f2hpLESo6LILRO97UXZiGcwTn5onslECL92260cU1nqEQp+ESK7XrdYIG
99oM3eXEraKw4WuQDaDE6U135aUl6vIJWD1JZzyr3RW3+5O9pn5rpN3Wc0TbDR6+
9Fs/TjuA1h5eJzbt+lkA74BtxPOBv9O7HJnWJpXjiG0VUGHdFXoq5Tr5Ol68RQxa
BWe7IfTO6FHN0xOl1dY7cn5jtf+xlFjL86s9OkrJUFa9lbQx8L/QPCeA2Xiu4tpW
+wTSel13k8Uv/JSGgLwSohW6N4XTQYdxPkO+a1V08adwFBXaGgqxfg0rNehcS5fp
y3TEq84cOlBsaI+rYpnOTPEajtYWfTe8WFf+lBOn1vZ9EiupjZtefGX2MIWPXoaK
kVBgRvzjp4/BY68yRvdi5sZFd2nakl+DOXzouuFbzsOkxL3o9FA9aCVsXtFqqzSG
Hvq4ZJ5ivXf6vQf+s7Tgc4qxW2CQwIPZVkHhQossrWgtkQ4WDAyzfhF0YuhEnpLS
XgGNLr82LMVmempaJd7GfAR2nwGnLUTYny1KoiW/1ie6DPwLZBX/UxPOplaS5wYH
Xd3gV3smg5xZ7/rfvzKTzJ1a5yH6D3xI05UtnUWdqojONcXS9NS+P7RArngJwSs=
=m0OS
-----END PGP MESSAGE-----
fp: 6CB37404020B5F0A0B41B5BB225EBAB0B936AC65
unencrypted_suffix: _unencrypted
version: 3.6.1

View File

@@ -0,0 +1,132 @@
package main
import (
"dagger.io/dagger/op"
"dagger.io/alpine"
)
TestPushContainer: {
// Generate a random number
random: {
string
#up: [
op.#Load & {from: alpine.#Image},
op.#Exec & {
args: ["sh", "-c", "echo -n $RANDOM > /rand"]
},
op.#Export & {
source: "/rand"
},
]
}
// Push an image with a random tag
push: {
ref: "daggerio/ci-test:\(random)"
#up: [
op.#WriteFile & {
content: random
dest: "/rand"
},
op.#PushContainer & {
"ref": ref
},
]
}
// Pull the image back
pull: #up: [
op.#FetchContainer & {
ref: push.ref
},
]
// Check the content
check: #up: [
op.#Load & {from: alpine.#Image},
op.#Exec & {
args: [
"sh", "-c", #"""
test "$(cat /src/rand)" = "\#(random)"
"""#,
]
mount: "/src": from: pull
},
]
}
// Ensures image metadata is preserved in a push
TestPushContainerMetadata: {
// Generate a random number
random: {
string
#up: [
op.#Load & {from: alpine.#Image},
op.#Exec & {
args: ["sh", "-c", "echo -n $RANDOM > /rand"]
},
op.#Export & {
source: "/rand"
},
]
}
// `docker build` using an `ENV` and push the image
push: {
ref: "daggerio/ci-test:\(random)-dockerbuild"
#up: [
op.#DockerBuild & {
dockerfile: #"""
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
ENV CHECK \#(random)
"""#
},
op.#PushContainer & {
"ref": ref
},
]
}
// Pull the image down and make sure the ENV is preserved
check: #up: [
op.#FetchContainer & {
ref: push.ref
},
op.#Exec & {
args: [
"sh", "-c", #"""
env
test "$CHECK" = "\#(random)"
"""#,
]
},
]
// Do a FetchContainer followed by a PushContainer, make sure
// the ENV is preserved
pullPush: {
ref: "daggerio/ci-test:\(random)-pullpush"
#up: [
op.#FetchContainer & {
ref: push.ref
},
op.#PushContainer & {
"ref": ref
},
]
}
pullPushCheck: #up: [
op.#FetchContainer & {
ref: pullPush.ref
},
op.#Exec & {
args: [
"sh", "-c", #"""
test "$CHECK" = "\#(random)"
"""#,
]
},
]
}

View File

@@ -0,0 +1,29 @@
package main
hello: {
string
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["mkdir", "-p", "/tmp/foo"]
},
{
do: "exec"
args: ["sh", "-c", "echo -n world > /tmp/foo/hello"]
},
{
do: "subdir"
dir: "/tmp/foo"
},
{
do: "export"
source: "/hello"
format: "string"
},
]
}