2022-02-11 23:28:25 +01:00
|
|
|
package netlify
|
2022-02-09 01:26:12 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"dagger.io/dagger"
|
2022-03-26 16:09:21 +01:00
|
|
|
"dagger.io/dagger/core"
|
2022-02-09 01:26:12 +01:00
|
|
|
|
2022-02-11 23:28:25 +01:00
|
|
|
"universe.dagger.io/docker"
|
2022-02-09 01:26:12 +01:00
|
|
|
"universe.dagger.io/netlify"
|
2022-02-11 23:28:25 +01:00
|
|
|
|
|
|
|
"universe.dagger.io/netlify/test/testutils"
|
2022-02-09 01:26:12 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
dagger.#Plan & {
|
2022-03-08 22:45:28 +01:00
|
|
|
client: commands: sops: {
|
2022-02-09 01:26:12 +01:00
|
|
|
name: "sops"
|
2022-03-30 23:05:17 +02:00
|
|
|
args: ["-d", "../../secrets_sops.yaml"]
|
2022-03-08 22:45:28 +01:00
|
|
|
stdout: dagger.#Secret
|
2022-02-09 01:26:12 +01:00
|
|
|
}
|
|
|
|
|
2022-03-09 19:45:46 +01:00
|
|
|
actions: test: {
|
2022-02-11 23:28:25 +01:00
|
|
|
|
|
|
|
// Configuration common to all tests
|
|
|
|
common: {
|
2022-03-26 16:09:21 +01:00
|
|
|
testSecrets: core.#DecodeSecret & {
|
2022-03-08 22:45:28 +01:00
|
|
|
input: client.commands.sops.stdout
|
2022-02-09 01:26:12 +01:00
|
|
|
format: "yaml"
|
|
|
|
}
|
|
|
|
|
2022-03-30 23:05:17 +02:00
|
|
|
token: testSecrets.output.NETLIFY_TOKEN.contents
|
2022-02-11 23:28:25 +01:00
|
|
|
|
2022-02-09 01:26:12 +01:00
|
|
|
marker: "hello world"
|
|
|
|
|
2022-03-26 16:09:21 +01:00
|
|
|
data: core.#WriteFile & {
|
2022-02-16 19:37:16 +01:00
|
|
|
input: dagger.#Scratch
|
2022-02-09 01:26:12 +01:00
|
|
|
path: "index.html"
|
|
|
|
contents: marker
|
|
|
|
}
|
2022-02-11 23:28:25 +01:00
|
|
|
}
|
2022-02-09 01:26:12 +01:00
|
|
|
|
2022-02-11 23:28:25 +01:00
|
|
|
// Test: deploy a simple site to Netlify
|
|
|
|
simple: {
|
2022-02-09 01:26:12 +01:00
|
|
|
// Deploy to netlify
|
|
|
|
deploy: netlify.#Deploy & {
|
2022-03-30 23:05:17 +02:00
|
|
|
team: "dagger-test"
|
2022-02-11 23:28:25 +01:00
|
|
|
token: common.token
|
|
|
|
site: "dagger-test"
|
|
|
|
contents: common.data.output
|
|
|
|
}
|
2022-02-09 01:26:12 +01:00
|
|
|
|
2022-02-11 23:28:25 +01:00
|
|
|
verify: testutils.#AssertURL & {
|
|
|
|
url: deploy.deployUrl
|
|
|
|
contents: common.marker
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test: deploy to Netlify with a custom image
|
|
|
|
swapImage: {
|
|
|
|
// Deploy to netlify
|
|
|
|
deploy: netlify.#Deploy & {
|
2022-03-30 23:05:17 +02:00
|
|
|
team: "dagger-test"
|
2022-02-11 23:28:25 +01:00
|
|
|
token: common.token
|
2022-02-09 01:26:12 +01:00
|
|
|
site: "dagger-test"
|
2022-02-11 23:28:25 +01:00
|
|
|
contents: common.data.output
|
|
|
|
container: input: customImage.output
|
2022-02-09 01:26:12 +01:00
|
|
|
}
|
|
|
|
|
2022-02-11 23:28:25 +01:00
|
|
|
customImage: docker.#Build & {
|
|
|
|
steps: [
|
|
|
|
docker.#Pull & {
|
|
|
|
source: "alpine"
|
|
|
|
},
|
|
|
|
docker.#Run & {
|
|
|
|
command: {
|
|
|
|
name: "apk"
|
|
|
|
args: [
|
|
|
|
"add",
|
|
|
|
"--no-cache",
|
|
|
|
"yarn",
|
|
|
|
"bash",
|
|
|
|
"rsync",
|
|
|
|
"curl",
|
|
|
|
"jq",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
docker.#Run & {
|
|
|
|
command: {
|
|
|
|
name: "yarn"
|
|
|
|
args: ["global", "add", "netlify-cli"]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
]
|
2022-02-09 01:26:12 +01:00
|
|
|
}
|
|
|
|
|
2022-02-11 23:28:25 +01:00
|
|
|
verify: testutils.#AssertURL & {
|
|
|
|
url: deploy.deployUrl
|
|
|
|
contents: common.marker
|
2022-02-09 01:26:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|