package testing
import (
"dagger.io/dagger"
"dagger.io/dagger/op"
"dagger.io/alpine"
)
registry: {
username: string
secret: dagger.#Secret
}
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)"
op.#DockerLogin & {
registry
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: [
args: [
"sh", "-c", #"""
test "$(cat /src/rand)" = "\#(random)"
"""#,
mount: "/src": from: pull
// Ensures image metadata is preserved in a push
TestPushContainerMetadata: {
// `docker build` using an `ENV` and push the image
ref: "daggerio/ci-test:\(random)-dockerbuild"
op.#DockerBuild & {
dockerfile: #"""
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
ENV CHECK \#(random)
"""#
// Pull the image down and make sure the ENV is preserved
env
test "$CHECK" = "\#(random)"
// Do a FetchContainer followed by a PushContainer, make sure
// the ENV is preserved
pullPush: {
ref: "daggerio/ci-test:\(random)-pullpush"
pullPushCheck: #up: [
ref: pullPush.ref