2021-08-12 12:47:50 +02:00
|
|
|
## Doc commands are being extracted from this file and helpers.
|
|
|
|
## Indentation is important, please append at the end
|
|
|
|
|
|
|
|
setup() {
|
2021-08-13 16:35:53 +02:00
|
|
|
load 'helpers'
|
2021-08-12 12:47:50 +02:00
|
|
|
|
2021-08-13 16:35:53 +02:00
|
|
|
common_setup
|
2021-08-12 12:47:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Test 1003-get-started
|
|
|
|
@test "doc-1003-get-started" {
|
2021-08-30 16:06:39 +02:00
|
|
|
setup_example_sandbox
|
2021-08-12 12:47:50 +02:00
|
|
|
|
2021-10-05 19:57:21 +02:00
|
|
|
# Follow tutorial
|
2021-10-05 20:40:39 +02:00
|
|
|
mkdir -p "$DAGGER_SANDBOX"/plans/local
|
|
|
|
cp "$DAGGER_PROJECT"/getting-started/plans/todoapp.cue "$DAGGER_SANDBOX"/plans/todoapp.cue
|
|
|
|
cp "$DAGGER_PROJECT"/getting-started/plans/local/local.cue "$DAGGER_SANDBOX"/plans/local/local.cue
|
2021-10-05 19:57:21 +02:00
|
|
|
|
2021-10-05 20:40:39 +02:00
|
|
|
dagger --project "$DAGGER_SANDBOX" new 'local' -p "$DAGGER_SANDBOX"/plans/local
|
2021-10-06 03:15:38 +02:00
|
|
|
dagger --project "$DAGGER_SANDBOX" -e 'local' input socket dockerSocket /var/run/docker.sock
|
2021-10-05 19:57:21 +02:00
|
|
|
dagger --project "$DAGGER_SANDBOX" -e 'local' input dir app.source "$DAGGER_SANDBOX"
|
2021-10-05 20:40:39 +02:00
|
|
|
|
2021-11-30 06:15:53 +01:00
|
|
|
run dagger --project "$DAGGER_SANDBOX" -e 'local' up
|
|
|
|
assert_success
|
|
|
|
|
|
|
|
docker rm -f todoapp
|
|
|
|
docker rm -f registry-local
|
2021-08-13 01:47:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "doc-1004-first-env" {
|
2021-08-30 16:06:39 +02:00
|
|
|
setup_example_sandbox
|
2021-08-13 01:47:59 +02:00
|
|
|
|
2021-08-13 16:35:53 +02:00
|
|
|
# Follow tutorial
|
2021-08-30 16:06:39 +02:00
|
|
|
mkdir -p "$DAGGER_SANDBOX"/multibucket
|
2021-09-23 20:07:09 +02:00
|
|
|
cp "$DAGGER_PROJECT"/multibucket/source.cue "$DAGGER_SANDBOX"/multibucket
|
|
|
|
cp "$DAGGER_PROJECT"/multibucket/yarn.cue "$DAGGER_SANDBOX"/multibucket
|
|
|
|
cp "$DAGGER_PROJECT"/multibucket/netlify.cue "$DAGGER_SANDBOX"/multibucket
|
2021-08-13 01:47:59 +02:00
|
|
|
|
2021-09-23 20:07:09 +02:00
|
|
|
dagger --project "$DAGGER_SANDBOX" doc alpha.dagger.io/netlify
|
|
|
|
dagger --project "$DAGGER_SANDBOX" doc alpha.dagger.io/js/yarn
|
2021-08-13 01:47:59 +02:00
|
|
|
|
2021-08-13 16:35:53 +02:00
|
|
|
# Initialize new env
|
2021-09-23 20:07:09 +02:00
|
|
|
dagger --project "$DAGGER_SANDBOX" new 'multibucket' -p "$DAGGER_SANDBOX"/multibucket
|
2021-08-13 01:47:59 +02:00
|
|
|
|
2021-08-13 16:35:53 +02:00
|
|
|
# Copy corresponding env
|
2021-09-23 20:07:09 +02:00
|
|
|
cp -r "$DAGGER_PROJECT"/.dagger/env/multibucket "$DAGGER_SANDBOX"/.dagger/env/
|
2021-08-30 16:06:39 +02:00
|
|
|
|
2021-08-13 16:35:53 +02:00
|
|
|
# Add missing src input
|
2021-09-23 20:07:09 +02:00
|
|
|
dagger --project "$DAGGER_SANDBOX" -e multibucket input dir src "$DAGGER_SANDBOX"
|
2021-08-13 01:47:59 +02:00
|
|
|
|
2021-08-13 16:35:53 +02:00
|
|
|
# Run test
|
2021-09-23 20:07:09 +02:00
|
|
|
dagger --project "$DAGGER_SANDBOX" -e multibucket up
|
|
|
|
url=$(dagger --project "$DAGGER_SANDBOX" -e multibucket query -f text site.netlify.deployUrl)
|
2021-08-13 01:47:59 +02:00
|
|
|
|
2021-08-30 16:06:39 +02:00
|
|
|
# Check output
|
|
|
|
run curl "$url"
|
2021-08-13 16:35:53 +02:00
|
|
|
assert_output --partial "./static/css/main.9149988f.chunk.css"
|
2021-08-13 03:01:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "doc-1006-google-cloud-run" {
|
2021-08-30 16:06:39 +02:00
|
|
|
setup_example_sandbox
|
2021-08-13 03:01:13 +02:00
|
|
|
|
2021-08-30 16:06:39 +02:00
|
|
|
# Follow tutorial
|
|
|
|
mkdir -p "$DAGGER_SANDBOX"/gcpcloudrun
|
2021-09-23 20:07:09 +02:00
|
|
|
cp "$DAGGER_PROJECT"/gcpcloudrun/source.cue "$DAGGER_SANDBOX"/gcpcloudrun
|
2021-08-13 03:01:13 +02:00
|
|
|
|
2021-08-13 16:35:53 +02:00
|
|
|
# Initialize new env
|
2021-09-23 20:07:09 +02:00
|
|
|
dagger --project "$DAGGER_SANDBOX" new 'gcpcloudrun' -p "$DAGGER_SANDBOX"/gcpcloudrun
|
2021-08-13 03:01:13 +02:00
|
|
|
|
2021-08-13 16:35:53 +02:00
|
|
|
# Copy corresponding env
|
2021-09-23 20:07:09 +02:00
|
|
|
cp -r "$DAGGER_PROJECT"/.dagger/env/gcpcloudrun "$DAGGER_SANDBOX"/.dagger/env/
|
2021-08-30 16:06:39 +02:00
|
|
|
|
2021-08-13 16:35:53 +02:00
|
|
|
# Add missing src input
|
2021-09-23 20:07:09 +02:00
|
|
|
dagger --project "$DAGGER_SANDBOX" -e gcpcloudrun input dir src "$DAGGER_SANDBOX"
|
2021-08-13 03:01:13 +02:00
|
|
|
|
2021-08-13 16:35:53 +02:00
|
|
|
# Run test
|
2021-09-23 20:07:09 +02:00
|
|
|
run dagger --project "$DAGGER_SANDBOX" -e gcpcloudrun up
|
2021-08-13 16:35:53 +02:00
|
|
|
assert_success
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "doc-1007-kube-kind" {
|
2021-09-02 19:39:10 +02:00
|
|
|
skip "debug CI issue"
|
|
|
|
# skip_unless_local_kube
|
2021-08-13 16:35:53 +02:00
|
|
|
|
2021-09-02 19:39:10 +02:00
|
|
|
# #################### BASIC ####################
|
|
|
|
# # Copy deployment to sandbox
|
|
|
|
# copy_to_sandbox kube-kind-basic kube-kind
|
2021-08-13 16:35:53 +02:00
|
|
|
|
2021-09-02 19:39:10 +02:00
|
|
|
# # Add kubeconfig
|
2021-09-23 20:07:09 +02:00
|
|
|
# dagger --project "$DAGGER_SANDBOX" -e kube-kind-basic input text kubeconfig -f "$HOME"/.kube/config
|
2021-08-13 16:35:53 +02:00
|
|
|
|
2021-09-02 19:39:10 +02:00
|
|
|
# # Up deployment
|
2021-09-23 20:07:09 +02:00
|
|
|
# dagger --project "$DAGGER_SANDBOX" -e kube-kind-basic up
|
2021-08-13 16:35:53 +02:00
|
|
|
|
2021-09-02 19:39:10 +02:00
|
|
|
# # Check deployment
|
|
|
|
# kubectl describe deployment todoapp | grep 'True'
|
2021-08-13 18:42:49 +02:00
|
|
|
|
2021-09-02 19:39:10 +02:00
|
|
|
# # Clean
|
|
|
|
# kubectl delete deployments --all
|
|
|
|
# kubectl delete services --all
|
2021-08-13 18:42:49 +02:00
|
|
|
|
2021-09-02 19:39:10 +02:00
|
|
|
# #################### DEPLOYMENT ####################
|
|
|
|
# # Copy deployment to sandbox
|
|
|
|
# copy_to_sandbox kube-kind-deployment kube-kind
|
2021-08-13 18:42:49 +02:00
|
|
|
|
2021-09-02 19:39:10 +02:00
|
|
|
# # Add kubeconfig
|
2021-09-23 20:07:09 +02:00
|
|
|
# dagger --project "$DAGGER_SANDBOX" -e kube-kind-deployment input text kubeconfig -f "$HOME"/.kube/config
|
2021-08-13 18:42:49 +02:00
|
|
|
|
2021-09-02 19:39:10 +02:00
|
|
|
# # Up deployment
|
2021-09-23 20:07:09 +02:00
|
|
|
# dagger --project "$DAGGER_SANDBOX" -e kube-kind-deployment up
|
2021-08-13 18:42:49 +02:00
|
|
|
|
2021-09-02 19:39:10 +02:00
|
|
|
# # Check deployment
|
|
|
|
# kubectl describe deployment todoapp | grep 'True'
|
2021-08-13 16:35:53 +02:00
|
|
|
|
2021-09-02 19:39:10 +02:00
|
|
|
# # Clean
|
|
|
|
# kubectl delete deployments --all
|
|
|
|
# kubectl delete services --all
|
2021-08-13 19:11:50 +02:00
|
|
|
|
2021-09-02 19:39:10 +02:00
|
|
|
# #################### CUE MANIFEST ####################
|
|
|
|
# # Copy deployment to sandbox
|
|
|
|
# copy_to_sandbox kube-kind-cue-manifest kube-kind
|
2021-08-13 19:11:50 +02:00
|
|
|
|
2021-09-02 19:39:10 +02:00
|
|
|
# # Add kubeconfig
|
2021-09-23 20:07:09 +02:00
|
|
|
# dagger --project "$DAGGER_SANDBOX" -e kube-kind-cue-manifest input text kubeconfig -f "$HOME"/.kube/config
|
2021-08-13 19:11:50 +02:00
|
|
|
|
2021-09-02 19:39:10 +02:00
|
|
|
# # Up deployment
|
2021-09-23 20:07:09 +02:00
|
|
|
# dagger --project "$DAGGER_SANDBOX" -e kube-kind-cue-manifest up
|
2021-08-13 19:11:50 +02:00
|
|
|
|
2021-09-02 19:39:10 +02:00
|
|
|
# # Check deployment
|
|
|
|
# kubectl describe deployment todoapp | grep 'True'
|
2021-08-13 19:11:50 +02:00
|
|
|
|
2021-09-02 19:39:10 +02:00
|
|
|
# # Clean
|
|
|
|
# kubectl delete deployments --all
|
|
|
|
# kubectl delete services --all
|
2021-08-16 16:34:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "doc-1007-kube-aws" {
|
2021-09-02 19:39:10 +02:00
|
|
|
skip "debug CI issue"
|
|
|
|
# #################### BASIC ####################
|
|
|
|
# # Copy deployment to sandbox
|
|
|
|
# copy_to_sandbox kube-aws-basic kube-aws
|
|
|
|
|
|
|
|
# # Up deployment
|
2021-09-23 20:07:09 +02:00
|
|
|
# dagger --project "$DAGGER_SANDBOX" -e kube-aws-basic up
|
2021-09-02 19:39:10 +02:00
|
|
|
|
|
|
|
# #################### DEPLOYMENT ####################
|
|
|
|
# # Copy deployment to sandbox
|
|
|
|
# copy_to_sandbox kube-aws-deployment kube-aws
|
|
|
|
|
|
|
|
# # Up deployment
|
2021-09-23 20:07:09 +02:00
|
|
|
# dagger --project "$DAGGER_SANDBOX" -e kube-aws-deployment up
|
2021-09-02 19:39:10 +02:00
|
|
|
# #################### CUE MANIFEST ####################
|
|
|
|
# # Copy deployment to sandbox
|
|
|
|
# copy_to_sandbox kube-aws-cue-manifest kube-aws
|
|
|
|
|
|
|
|
# # Up deployment
|
2021-09-23 20:07:09 +02:00
|
|
|
# dagger --project "$DAGGER_SANDBOX" -e kube-aws-cue-manifest up
|
2021-08-13 04:18:56 +02:00
|
|
|
}
|
|
|
|
|
2021-08-16 23:53:35 +02:00
|
|
|
@test "doc-1007-kube-gcp" {
|
2021-09-02 19:39:10 +02:00
|
|
|
skip "debug CI issue"
|
|
|
|
# #################### BASIC ####################
|
|
|
|
# # Copy deployment to sandbox
|
|
|
|
# copy_to_sandbox kube-gcp-basic kube-gcp
|
|
|
|
|
|
|
|
# # Up deployment
|
2021-09-23 20:07:09 +02:00
|
|
|
# dagger --project "$DAGGER_SANDBOX" -e kube-gcp-basic up
|
2021-09-02 19:39:10 +02:00
|
|
|
|
|
|
|
# #################### DEPLOYMENT ####################
|
|
|
|
# # Copy deployment to sandbox
|
|
|
|
# copy_to_sandbox kube-gcp-deployment kube-gcp
|
|
|
|
|
|
|
|
# # Up deployment
|
2021-09-23 20:07:09 +02:00
|
|
|
# dagger --project "$DAGGER_SANDBOX" -e kube-gcp-deployment up
|
2021-09-02 19:39:10 +02:00
|
|
|
# #################### CUE MANIFEST ####################
|
|
|
|
# # Copy deployment to sandbox
|
|
|
|
# copy_to_sandbox kube-gcp-cue-manifest kube-gcp
|
|
|
|
|
|
|
|
# # Up deployment
|
2021-09-23 20:07:09 +02:00
|
|
|
# dagger --project "$DAGGER_SANDBOX" -e kube-gcp-cue-manifest up
|
2021-08-16 23:53:35 +02:00
|
|
|
}
|
|
|
|
|
2021-08-13 04:18:56 +02:00
|
|
|
@test "doc-1008-aws-cloudformation" {
|
2021-12-15 00:09:44 +01:00
|
|
|
skip "debug CI deadlock"
|
2021-08-13 16:35:53 +02:00
|
|
|
|
2021-12-15 00:09:44 +01:00
|
|
|
# skip_unless_local_localstack
|
|
|
|
# setup_example_sandbox
|
2021-08-13 16:35:53 +02:00
|
|
|
|
2021-12-15 00:09:44 +01:00
|
|
|
# ### Create a basic plan
|
|
|
|
# ## Construct
|
|
|
|
# mkdir -p "$DAGGER_SANDBOX"/cloudformation
|
|
|
|
# cp "$DAGGER_PROJECT"/cloudformation/template.cue "$DAGGER_SANDBOX"/cloudformation
|
2021-08-13 16:35:53 +02:00
|
|
|
|
2021-12-15 00:09:44 +01:00
|
|
|
# # Cloudformation relay
|
|
|
|
# dagger --project "$DAGGER_SANDBOX" doc alpha.dagger.io/aws/cloudformation
|
|
|
|
# cp "$DAGGER_PROJECT"/cloudformation/source-begin.cue "$DAGGER_SANDBOX"/cloudformation/source.cue
|
2021-08-13 16:35:53 +02:00
|
|
|
|
2021-12-15 00:09:44 +01:00
|
|
|
# # Initialize new env
|
|
|
|
# dagger --project "$DAGGER_SANDBOX" new 'cloudformation' -p "$DAGGER_SANDBOX"/cloudformation
|
2021-08-30 16:06:39 +02:00
|
|
|
|
2021-12-15 00:09:44 +01:00
|
|
|
# # Finish template setup
|
|
|
|
# cp "$DAGGER_PROJECT"/cloudformation/source-end.cue "$DAGGER_SANDBOX"/cloudformation/source.cue
|
2021-08-13 16:35:53 +02:00
|
|
|
|
2021-12-15 00:09:44 +01:00
|
|
|
# # Copy corresponding env
|
|
|
|
# cp -r "$DAGGER_PROJECT"/.dagger/env/cloudformation "$DAGGER_SANDBOX"/.dagger/env/
|
|
|
|
|
|
|
|
# # Run test
|
|
|
|
# dagger --project "$DAGGER_SANDBOX" -e cloudformation up
|
|
|
|
# stackName=$(dagger --project "$DAGGER_SANDBOX" -e cloudformation query cfnStackName -f text)
|
|
|
|
|
|
|
|
# ## Cleanup
|
|
|
|
# # Place back empty source
|
|
|
|
# cp "$DAGGER_PROJECT"/cloudformation/source-begin.cue "$DAGGER_SANDBOX"/cloudformation/source.cue
|
|
|
|
# cp "$DAGGER_PROJECT"/cloudformation/deletion.cue "$DAGGER_SANDBOX"/cloudformation/deletion.cue
|
|
|
|
# # Prepare and run cloudformation cleanup
|
|
|
|
# dagger --project "$DAGGER_SANDBOX" -e cloudformation input text stackRemoval.stackName "$stackName"
|
|
|
|
# dagger --project "$DAGGER_SANDBOX" -e cloudformation up
|
|
|
|
|
|
|
|
# ### Template part
|
|
|
|
# ## Create convert.cue
|
|
|
|
# cp "$DAGGER_PROJECT"/cloudformation/template/convert.cue "$DAGGER_SANDBOX"/cloudformation/convert.cue
|
|
|
|
# rm "$DAGGER_SANDBOX"/cloudformation/source.cue "$DAGGER_SANDBOX"/cloudformation/deletion.cue
|
|
|
|
|
|
|
|
# ## Retrieve Unmarshalled JSON
|
|
|
|
# dagger --project "$DAGGER_SANDBOX" query -e cloudformation s3Template
|
|
|
|
|
|
|
|
# ## Remove convert.cue
|
|
|
|
# rm "$DAGGER_SANDBOX"/cloudformation/convert.cue
|
|
|
|
|
|
|
|
# ## Store the output
|
|
|
|
# cp "$DAGGER_PROJECT"/cloudformation/template/template-begin.cue "$DAGGER_SANDBOX"/cloudformation/template.cue
|
|
|
|
|
|
|
|
# # Inspect conf
|
|
|
|
# dagger --project "$DAGGER_SANDBOX" query -e cloudformation template -f text
|
|
|
|
|
|
|
|
# cp "$DAGGER_PROJECT"/cloudformation/template/deployment.cue "$DAGGER_SANDBOX"/cloudformation/deployment.cue
|
|
|
|
# cp "$DAGGER_PROJECT"/cloudformation/template/template-end.cue "$DAGGER_SANDBOX"/cloudformation/template.cue
|
|
|
|
# cp "$DAGGER_PROJECT"/cloudformation/source-end.cue "$DAGGER_SANDBOX"/cloudformation/source.cue
|
|
|
|
|
|
|
|
# # Deploy again
|
|
|
|
# dagger --project "$DAGGER_SANDBOX" -e cloudformation query template -f text
|
|
|
|
# dagger --project "$DAGGER_SANDBOX" -e cloudformation up
|
|
|
|
# dagger --project "$DAGGER_SANDBOX" -e cloudformation output list
|
|
|
|
|
|
|
|
# ## Cleanup again
|
|
|
|
# stackName=$(dagger --project "$DAGGER_SANDBOX" -e cloudformation query cfnStackName -f text)
|
|
|
|
# rm -rf "$DAGGER_SANDBOX"/cloudformation/*
|
|
|
|
|
|
|
|
# # Place back empty source
|
|
|
|
# cp "$DAGGER_PROJECT"/cloudformation/source-begin.cue "$DAGGER_SANDBOX"/cloudformation/source.cue
|
|
|
|
# cp "$DAGGER_PROJECT"/cloudformation/deletion.cue "$DAGGER_SANDBOX"/cloudformation/deletion.cue
|
|
|
|
|
|
|
|
# # Prepare and run cloudformation cleanup
|
|
|
|
# dagger --project "$DAGGER_SANDBOX" -e cloudformation input text stackRemoval.stackName "$stackName"
|
|
|
|
# dagger --project "$DAGGER_SANDBOX" -e cloudformation up
|
2021-08-13 12:43:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "doc-1010-dev-cue-package" {
|
2021-12-15 00:09:44 +01:00
|
|
|
skip "debug CI deadlock"
|
|
|
|
|
|
|
|
# # Initializing project
|
|
|
|
# mkdir -p "$DAGGER_SANDBOX"/project
|
2021-08-13 16:35:53 +02:00
|
|
|
|
2021-12-15 00:09:44 +01:00
|
|
|
# # Writing package
|
|
|
|
# # dagger init # The sandbox is already init
|
2021-12-14 11:01:31 +01:00
|
|
|
# mkdir -p "$DAGGER_SANDBOX"/cue.mod/pkg/github.com/username/gcpcloudrun
|
|
|
|
# cp "$DAGGER_PROJECT"/dev-cue-package/source.cue "$DAGGER_SANDBOX"/cue.mod/pkg/github.com/username/gcpcloudrun/source.cue
|
2021-12-15 00:09:44 +01:00
|
|
|
# cp "$DAGGER_PROJECT"/dev-cue-package/script.sh "$DAGGER_SANDBOX"/project/script.sh
|
2021-08-13 16:35:53 +02:00
|
|
|
|
2021-12-15 00:09:44 +01:00
|
|
|
# # We remove the last line of the script, as bats cannot expand dagger
|
|
|
|
# # to dagger() bats helper func inside bash files
|
|
|
|
# sed '$d' <"$DAGGER_SANDBOX"/project/script.sh >"$DAGGER_SANDBOX"/tmpFile
|
|
|
|
# mv "$DAGGER_SANDBOX"/tmpFile "$DAGGER_SANDBOX"/project/script.sh
|
2021-08-30 16:06:39 +02:00
|
|
|
|
2021-12-15 00:09:44 +01:00
|
|
|
# chmod +x "$DAGGER_SANDBOX"/project/script.sh
|
|
|
|
# "$DAGGER_SANDBOX"/project/script.sh
|
2021-08-30 16:06:39 +02:00
|
|
|
|
2021-12-15 00:09:44 +01:00
|
|
|
# # Sync file from documentation
|
|
|
|
# rsync -a test "$DAGGER_SANDBOX"
|
2021-08-20 18:00:10 +02:00
|
|
|
|
2021-12-15 00:09:44 +01:00
|
|
|
# # Command removed from script.sh above
|
|
|
|
# dagger --project "$DAGGER_SANDBOX" new staging -p "$DAGGER_SANDBOX"/test
|
|
|
|
# run dagger up --project "$DAGGER_SANDBOX" -e staging
|
|
|
|
# assert_output --partial "input=run.gcpConfig.serviceKey"
|
2021-08-30 16:06:39 +02:00
|
|
|
|
2021-12-15 00:09:44 +01:00
|
|
|
# # Clean script.sh output
|
|
|
|
# rm -rf ./test
|
2021-08-13 12:43:13 +02:00
|
|
|
}
|