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-08-13 16:35:53 +02:00
|
|
|
# Set examples private key
|
2021-08-30 16:06:39 +02:00
|
|
|
"$DAGGER_SANDBOX"/import-tutorial-key.sh
|
2021-08-12 12:47:50 +02:00
|
|
|
|
2021-08-13 16:35:53 +02:00
|
|
|
# Collect url
|
2021-08-30 16:06:39 +02:00
|
|
|
dagger -w "$DAGGER_SANDBOX" up
|
|
|
|
url=$(dagger -w "$DAGGER_SANDBOX" query -f text url)
|
2021-08-12 12:47:50 +02:00
|
|
|
|
2021-08-13 16:35:53 +02:00
|
|
|
# More commands
|
2021-08-30 16:06:39 +02:00
|
|
|
dagger -w "$DAGGER_SANDBOX" list
|
|
|
|
ls -l "$DAGGER_SANDBOX"/s3
|
|
|
|
dagger -w "$DAGGER_SANDBOX" input list
|
2021-08-12 12:47:50 +02:00
|
|
|
|
2021-08-13 16:35:53 +02:00
|
|
|
# Check output
|
2021-08-30 16:06:39 +02:00
|
|
|
run curl "$url"
|
2021-08-13 16:35:53 +02:00
|
|
|
assert_output --partial "My Todo app"
|
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
|
|
|
|
cp "$DAGGER_WORKSPACE"/multibucket/source.cue "$DAGGER_SANDBOX"/multibucket
|
|
|
|
cp "$DAGGER_WORKSPACE"/multibucket/yarn.cue "$DAGGER_SANDBOX"/multibucket
|
|
|
|
cp "$DAGGER_WORKSPACE"/multibucket/netlify.cue "$DAGGER_SANDBOX"/multibucket
|
2021-08-13 01:47:59 +02:00
|
|
|
|
2021-08-30 16:06:39 +02:00
|
|
|
dagger -w "$DAGGER_SANDBOX" doc alpha.dagger.io/netlify
|
|
|
|
dagger -w "$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-08-30 16:06:39 +02:00
|
|
|
dagger -w "$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-08-30 16:06:39 +02:00
|
|
|
cp -r "$DAGGER_WORKSPACE"/.dagger/env/multibucket "$DAGGER_SANDBOX"/.dagger/env/
|
|
|
|
|
2021-08-13 16:35:53 +02:00
|
|
|
# Add missing src input
|
2021-08-30 16:06:39 +02:00
|
|
|
dagger -w "$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-08-30 16:06:39 +02:00
|
|
|
dagger -w "$DAGGER_SANDBOX" -e multibucket up
|
|
|
|
url=$(dagger -w "$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
|
|
|
|
cp "$DAGGER_WORKSPACE"/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-08-30 16:06:39 +02:00
|
|
|
dagger -w "$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-08-30 16:06:39 +02:00
|
|
|
cp -r "$DAGGER_WORKSPACE"/.dagger/env/gcpcloudrun "$DAGGER_SANDBOX"/.dagger/env/
|
|
|
|
|
2021-08-13 16:35:53 +02:00
|
|
|
# Add missing src input
|
2021-08-30 16:06:39 +02:00
|
|
|
dagger -w "$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-08-30 16:06:39 +02:00
|
|
|
run dagger -w "$DAGGER_SANDBOX" -e gcpcloudrun up
|
2021-08-13 16:35:53 +02:00
|
|
|
assert_success
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "doc-1007-kube-kind" {
|
|
|
|
skip_unless_local_kube
|
|
|
|
|
|
|
|
#################### BASIC ####################
|
2021-08-16 16:34:07 +02:00
|
|
|
# Copy deployment to sandbox
|
2021-08-13 16:35:53 +02:00
|
|
|
copy_to_sandbox kube-kind-basic kube-kind
|
|
|
|
|
|
|
|
# Add kubeconfig
|
|
|
|
dagger -w "$DAGGER_SANDBOX" -e kube-kind-basic input text kubeconfig -f "$HOME"/.kube/config
|
|
|
|
|
|
|
|
# Up deployment
|
|
|
|
dagger -w "$DAGGER_SANDBOX" -e kube-kind-basic up
|
|
|
|
|
|
|
|
# Check deployment
|
2021-08-13 18:42:49 +02:00
|
|
|
kubectl describe deployment todoapp | grep 'True'
|
|
|
|
|
|
|
|
# Clean
|
|
|
|
kubectl delete deployments --all
|
2021-08-16 16:34:07 +02:00
|
|
|
kubectl delete services --all
|
2021-08-13 18:42:49 +02:00
|
|
|
|
2021-08-13 19:11:50 +02:00
|
|
|
#################### DEPLOYMENT ####################
|
2021-08-16 16:34:07 +02:00
|
|
|
# Copy deployment to sandbox
|
2021-08-13 19:11:50 +02:00
|
|
|
copy_to_sandbox kube-kind-deployment kube-kind
|
2021-08-13 18:42:49 +02:00
|
|
|
|
|
|
|
# Add kubeconfig
|
|
|
|
dagger -w "$DAGGER_SANDBOX" -e kube-kind-deployment input text kubeconfig -f "$HOME"/.kube/config
|
|
|
|
|
|
|
|
# Up deployment
|
|
|
|
dagger -w "$DAGGER_SANDBOX" -e kube-kind-deployment up
|
|
|
|
|
|
|
|
# Check deployment
|
|
|
|
kubectl describe deployment todoapp | grep 'True'
|
2021-08-13 16:35:53 +02:00
|
|
|
|
|
|
|
# Clean
|
|
|
|
kubectl delete deployments --all
|
2021-08-16 16:34:07 +02:00
|
|
|
kubectl delete services --all
|
2021-08-13 19:11:50 +02:00
|
|
|
|
|
|
|
#################### CUE MANIFEST ####################
|
2021-08-16 16:34:07 +02:00
|
|
|
# Copy deployment to sandbox
|
2021-08-13 19:11:50 +02:00
|
|
|
copy_to_sandbox kube-kind-cue-manifest kube-kind
|
|
|
|
|
|
|
|
# Add kubeconfig
|
|
|
|
dagger -w "$DAGGER_SANDBOX" -e kube-kind-cue-manifest input text kubeconfig -f "$HOME"/.kube/config
|
|
|
|
|
|
|
|
# Up deployment
|
|
|
|
dagger -w "$DAGGER_SANDBOX" -e kube-kind-cue-manifest up
|
|
|
|
|
|
|
|
# Check deployment
|
|
|
|
kubectl describe deployment todoapp | grep 'True'
|
|
|
|
|
|
|
|
# Clean
|
|
|
|
kubectl delete deployments --all
|
2021-08-16 16:34:07 +02:00
|
|
|
kubectl delete services --all
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "doc-1007-kube-aws" {
|
|
|
|
#################### BASIC ####################
|
|
|
|
# Copy deployment to sandbox
|
|
|
|
copy_to_sandbox kube-aws-basic kube-aws
|
|
|
|
|
|
|
|
# Up deployment
|
|
|
|
dagger -w "$DAGGER_SANDBOX" -e kube-aws-basic up
|
|
|
|
|
|
|
|
#################### DEPLOYMENT ####################
|
2021-08-30 16:06:39 +02:00
|
|
|
# Copy deployment to sandbox
|
2021-08-16 16:34:07 +02:00
|
|
|
copy_to_sandbox kube-aws-deployment kube-aws
|
|
|
|
|
|
|
|
# Up deployment
|
|
|
|
dagger -w "$DAGGER_SANDBOX" -e kube-aws-deployment up
|
|
|
|
#################### CUE MANIFEST ####################
|
2021-08-16 23:38:47 +02:00
|
|
|
# Copy deployment to sandbox
|
|
|
|
copy_to_sandbox kube-aws-cue-manifest kube-aws
|
|
|
|
|
|
|
|
# Up deployment
|
|
|
|
dagger -w "$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" {
|
|
|
|
#################### BASIC ####################
|
|
|
|
# Copy deployment to sandbox
|
|
|
|
copy_to_sandbox kube-gcp-basic kube-gcp
|
|
|
|
|
|
|
|
# Up deployment
|
|
|
|
dagger -w "$DAGGER_SANDBOX" -e kube-gcp-basic up
|
2021-08-27 16:51:48 +02:00
|
|
|
|
|
|
|
#################### DEPLOYMENT ####################
|
|
|
|
# Copy deployment to sandbox
|
|
|
|
copy_to_sandbox kube-gcp-deployment kube-gcp
|
|
|
|
|
|
|
|
# Up deployment
|
|
|
|
dagger -w "$DAGGER_SANDBOX" -e kube-gcp-deployment up
|
|
|
|
#################### CUE MANIFEST ####################
|
|
|
|
# Copy deployment to sandbox
|
|
|
|
copy_to_sandbox kube-gcp-cue-manifest kube-gcp
|
|
|
|
|
|
|
|
# Up deployment
|
|
|
|
dagger -w "$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-08-20 16:09:35 +02:00
|
|
|
skip_unless_local_localstack
|
2021-08-30 16:06:39 +02:00
|
|
|
setup_example_sandbox
|
2021-08-13 16:35:53 +02:00
|
|
|
|
|
|
|
### Create a basic plan
|
|
|
|
## Construct
|
2021-08-30 16:06:39 +02:00
|
|
|
mkdir -p "$DAGGER_SANDBOX"/cloudformation
|
|
|
|
cp "$DAGGER_WORKSPACE"/cloudformation/template.cue "$DAGGER_SANDBOX"/cloudformation
|
2021-08-13 16:35:53 +02:00
|
|
|
|
|
|
|
# Cloudformation relay
|
2021-08-30 16:06:39 +02:00
|
|
|
dagger -w "$DAGGER_SANDBOX" doc alpha.dagger.io/aws/cloudformation
|
|
|
|
cp "$DAGGER_WORKSPACE"/cloudformation/source-begin.cue "$DAGGER_SANDBOX"/cloudformation/source.cue
|
2021-08-13 16:35:53 +02:00
|
|
|
|
|
|
|
# Initialize new env
|
2021-08-30 16:06:39 +02:00
|
|
|
dagger -w "$DAGGER_SANDBOX" new 'cloudformation' -p "$DAGGER_SANDBOX"/cloudformation
|
2021-08-13 16:35:53 +02:00
|
|
|
|
|
|
|
# Finish template setup
|
2021-08-30 16:06:39 +02:00
|
|
|
cp "$DAGGER_WORKSPACE"/cloudformation/source-end.cue "$DAGGER_SANDBOX"/cloudformation/source.cue
|
|
|
|
|
2021-08-13 16:35:53 +02:00
|
|
|
# Copy corresponding env
|
2021-08-30 16:06:39 +02:00
|
|
|
cp -r "$DAGGER_WORKSPACE"/.dagger/env/cloudformation "$DAGGER_SANDBOX"/.dagger/env/
|
2021-08-13 16:35:53 +02:00
|
|
|
|
|
|
|
# Run test
|
2021-08-30 16:06:39 +02:00
|
|
|
dagger -w "$DAGGER_SANDBOX" -e cloudformation up
|
|
|
|
stackName=$(dagger -w "$DAGGER_SANDBOX" -e cloudformation query cfnStackName -f text)
|
2021-08-13 16:35:53 +02:00
|
|
|
|
|
|
|
## Cleanup
|
|
|
|
# Place back empty source
|
2021-08-30 16:06:39 +02:00
|
|
|
cp "$DAGGER_WORKSPACE"/cloudformation/source-begin.cue "$DAGGER_SANDBOX"/cloudformation/source.cue
|
|
|
|
cp "$DAGGER_WORKSPACE"/cloudformation/deletion.cue "$DAGGER_SANDBOX"/cloudformation/deletion.cue
|
2021-08-13 16:35:53 +02:00
|
|
|
# Prepare and run cloudformation cleanup
|
2021-08-30 16:06:39 +02:00
|
|
|
dagger -w "$DAGGER_SANDBOX" -e cloudformation input text stackRemoval.stackName "$stackName"
|
|
|
|
dagger -w "$DAGGER_SANDBOX" -e cloudformation up
|
2021-08-13 16:35:53 +02:00
|
|
|
|
|
|
|
### Template part
|
|
|
|
## Create convert.cue
|
2021-08-30 16:06:39 +02:00
|
|
|
cp "$DAGGER_WORKSPACE"/cloudformation/template/convert.cue "$DAGGER_SANDBOX"/cloudformation/convert.cue
|
|
|
|
rm "$DAGGER_SANDBOX"/cloudformation/source.cue "$DAGGER_SANDBOX"/cloudformation/deletion.cue
|
2021-08-13 16:35:53 +02:00
|
|
|
|
|
|
|
## Retrieve Unmarshalled JSON
|
2021-08-30 16:06:39 +02:00
|
|
|
dagger -w "$DAGGER_SANDBOX" query -e cloudformation s3Template
|
2021-08-13 16:35:53 +02:00
|
|
|
|
|
|
|
## Remove convert.cue
|
2021-08-30 16:06:39 +02:00
|
|
|
rm "$DAGGER_SANDBOX"/cloudformation/convert.cue
|
|
|
|
|
2021-08-13 16:35:53 +02:00
|
|
|
## Store the output
|
2021-08-30 16:06:39 +02:00
|
|
|
cp "$DAGGER_WORKSPACE"/cloudformation/template/template-begin.cue "$DAGGER_SANDBOX"/cloudformation/template.cue
|
|
|
|
|
2021-08-13 16:35:53 +02:00
|
|
|
# Inspect conf
|
2021-08-30 16:06:39 +02:00
|
|
|
dagger -w "$DAGGER_SANDBOX" query -e cloudformation template -f text
|
2021-08-13 16:35:53 +02:00
|
|
|
|
2021-08-30 16:06:39 +02:00
|
|
|
cp "$DAGGER_WORKSPACE"/cloudformation/template/deployment.cue "$DAGGER_SANDBOX"/cloudformation/deployment.cue
|
|
|
|
cp "$DAGGER_WORKSPACE"/cloudformation/template/template-end.cue "$DAGGER_SANDBOX"/cloudformation/template.cue
|
|
|
|
cp "$DAGGER_WORKSPACE"/cloudformation/source-end.cue "$DAGGER_SANDBOX"/cloudformation/source.cue
|
2021-08-13 16:35:53 +02:00
|
|
|
|
|
|
|
# Deploy again
|
2021-08-30 16:06:39 +02:00
|
|
|
dagger -w "$DAGGER_SANDBOX" -e cloudformation query template -f text
|
|
|
|
dagger -w "$DAGGER_SANDBOX" -e cloudformation up
|
|
|
|
dagger -w "$DAGGER_SANDBOX" -e cloudformation output list
|
2021-08-13 16:35:53 +02:00
|
|
|
|
|
|
|
## Cleanup again
|
2021-08-30 16:06:39 +02:00
|
|
|
stackName=$(dagger -w "$DAGGER_SANDBOX" -e cloudformation query cfnStackName -f text)
|
|
|
|
rm -rf "$DAGGER_SANDBOX"/cloudformation/*
|
|
|
|
|
2021-08-13 16:35:53 +02:00
|
|
|
# Place back empty source
|
2021-08-30 16:06:39 +02:00
|
|
|
cp "$DAGGER_WORKSPACE"/cloudformation/source-begin.cue "$DAGGER_SANDBOX"/cloudformation/source.cue
|
|
|
|
cp "$DAGGER_WORKSPACE"/cloudformation/deletion.cue "$DAGGER_SANDBOX"/cloudformation/deletion.cue
|
|
|
|
|
2021-08-13 16:35:53 +02:00
|
|
|
# Prepare and run cloudformation cleanup
|
2021-08-30 16:06:39 +02:00
|
|
|
dagger -w "$DAGGER_SANDBOX" -e cloudformation input text stackRemoval.stackName "$stackName"
|
|
|
|
dagger -w "$DAGGER_SANDBOX" -e cloudformation up
|
2021-08-13 12:43:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "doc-1010-dev-cue-package" {
|
2021-08-13 16:35:53 +02:00
|
|
|
# Initializing workspace
|
2021-08-30 16:06:39 +02:00
|
|
|
mkdir -p "$DAGGER_SANDBOX"/workspace
|
2021-08-13 16:35:53 +02:00
|
|
|
|
2021-08-20 16:09:35 +02:00
|
|
|
# Writing package
|
2021-08-30 16:06:39 +02:00
|
|
|
# dagger init # The sandbox is already init
|
|
|
|
mkdir -p "$DAGGER_SANDBOX"/cue.mod/pkg/github.com/tjovicic/gcpcloudrun
|
|
|
|
cp "$DAGGER_WORKSPACE"/dev-cue-package/source.cue "$DAGGER_SANDBOX"/cue.mod/pkg/github.com/tjovicic/gcpcloudrun/source.cue
|
|
|
|
cp "$DAGGER_WORKSPACE"/dev-cue-package/script.sh "$DAGGER_SANDBOX"/workspace/script.sh
|
2021-08-13 16:35:53 +02:00
|
|
|
|
2021-08-20 18:00:10 +02:00
|
|
|
# We remove the last line of the script, as bats cannot expand dagger
|
|
|
|
# to dagger() bats helper func inside bash files
|
2021-08-30 16:06:39 +02:00
|
|
|
sed '$d' <"$DAGGER_SANDBOX"/workspace/script.sh >"$DAGGER_SANDBOX"/tmpFile
|
|
|
|
mv "$DAGGER_SANDBOX"/tmpFile "$DAGGER_SANDBOX"/workspace/script.sh
|
|
|
|
|
|
|
|
chmod +x "$DAGGER_SANDBOX"/workspace/script.sh
|
|
|
|
"$DAGGER_SANDBOX"/workspace/script.sh
|
|
|
|
|
|
|
|
# Sync file from documentation
|
|
|
|
rsync -a test "$DAGGER_SANDBOX"
|
2021-08-20 18:00:10 +02:00
|
|
|
|
|
|
|
# Command removed from script.sh above
|
2021-08-30 16:06:39 +02:00
|
|
|
dagger -w "$DAGGER_SANDBOX" new staging -p "$DAGGER_SANDBOX"/test
|
|
|
|
run dagger up -w "$DAGGER_SANDBOX" -e staging
|
2021-08-20 18:00:10 +02:00
|
|
|
assert_output --partial "input=run.gcpConfig.serviceKey"
|
2021-08-30 16:06:39 +02:00
|
|
|
|
|
|
|
# Clean script.sh output
|
|
|
|
rm -rf ./test
|
2021-08-13 12:43:13 +02:00
|
|
|
}
|