2021-08-31 14:39:45 +02:00
|
|
|
# Instead of setup, this runs only once
|
|
|
|
setup_file() {
|
2021-09-09 13:03:07 +02:00
|
|
|
load 'helpers'
|
2021-08-31 14:39:45 +02:00
|
|
|
|
2021-09-09 13:03:07 +02:00
|
|
|
setup_localstack
|
2021-08-31 14:39:45 +02:00
|
|
|
}
|
|
|
|
|
2021-06-09 21:08:03 +02:00
|
|
|
setup() {
|
2021-09-09 13:03:07 +02:00
|
|
|
load 'helpers'
|
2021-06-09 21:08:03 +02:00
|
|
|
|
2021-09-09 13:03:07 +02:00
|
|
|
common_setup
|
2021-06-09 21:08:03 +02:00
|
|
|
}
|
|
|
|
|
2021-06-23 16:31:42 +02:00
|
|
|
@test "cue-sanity-check" {
|
2021-12-22 23:17:24 +01:00
|
|
|
skip "Docs generation already validates the cue code of the library - disabled to avoid duplication"
|
2021-09-09 13:03:07 +02:00
|
|
|
dagger -e sanity-check up
|
2021-06-23 16:31:42 +02:00
|
|
|
}
|
|
|
|
|
2021-06-09 20:37:05 +02:00
|
|
|
@test "os" {
|
2021-09-09 13:03:07 +02:00
|
|
|
dagger -e os up
|
2021-06-09 20:37:05 +02:00
|
|
|
}
|
|
|
|
|
2021-06-17 15:20:47 +02:00
|
|
|
@test "go" {
|
2021-09-09 13:03:07 +02:00
|
|
|
dagger -e go up
|
2021-06-17 15:20:47 +02:00
|
|
|
}
|
|
|
|
|
2021-10-19 15:06:14 +02:00
|
|
|
@test "http" {
|
2021-11-23 18:33:28 +01:00
|
|
|
dagger -e http up
|
|
|
|
CONTAINER=$(docker container ls -q --filter "name=daggerci-test-wait-*")
|
|
|
|
docker stop "$CONTAINER" && docker rm "$CONTAINER"
|
2021-10-19 15:06:14 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 12:50:49 +02:00
|
|
|
@test "js/yarn" {
|
2021-09-09 13:03:07 +02:00
|
|
|
dagger -e js-yarn up
|
2021-06-10 12:50:49 +02:00
|
|
|
}
|
|
|
|
|
2021-06-29 12:11:57 +02:00
|
|
|
@test "java/maven" {
|
2021-09-09 13:03:07 +02:00
|
|
|
dagger -e java-maven up
|
2021-06-29 12:11:57 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 12:29:49 +02:00
|
|
|
@test "alpine" {
|
2021-09-09 13:03:07 +02:00
|
|
|
dagger -e alpine up
|
2021-06-10 12:29:49 +02:00
|
|
|
}
|
|
|
|
|
2021-06-09 21:08:03 +02:00
|
|
|
@test "netlify" {
|
2022-01-11 11:43:35 +01:00
|
|
|
skip "Temporary skip due to a regression in one of netlify's libraries"
|
2021-09-09 13:03:07 +02:00
|
|
|
dagger -e netlify up
|
2021-06-09 21:08:03 +02:00
|
|
|
}
|
|
|
|
|
2021-06-16 10:00:01 +02:00
|
|
|
@test "git" {
|
2021-09-09 13:03:07 +02:00
|
|
|
# Fetch repo
|
|
|
|
dagger -e git-repo up
|
2021-09-01 18:49:21 +02:00
|
|
|
|
2021-09-09 13:03:07 +02:00
|
|
|
# Commit & push
|
|
|
|
dagger -e git-commit up
|
2021-06-16 10:00:01 +02:00
|
|
|
}
|
|
|
|
|
2021-06-23 12:46:56 +02:00
|
|
|
@test "os.#Container" {
|
2021-09-09 13:03:07 +02:00
|
|
|
dagger -e os-container up
|
2021-06-23 12:46:56 +02:00
|
|
|
}
|
|
|
|
|
2021-06-09 21:08:03 +02:00
|
|
|
@test "aws: ecr" {
|
2021-09-09 13:03:07 +02:00
|
|
|
dagger -e aws-ecr up
|
2021-06-09 21:08:03 +02:00
|
|
|
}
|
|
|
|
|
2021-08-18 15:09:28 +02:00
|
|
|
@test "aws: ecr/localstack" {
|
2021-09-09 13:03:07 +02:00
|
|
|
skip_unless_local_localstack
|
2021-08-18 15:09:28 +02:00
|
|
|
|
2021-09-09 13:03:07 +02:00
|
|
|
dagger -e aws-ecr-localstack up
|
2021-08-18 15:09:28 +02:00
|
|
|
}
|
|
|
|
|
2021-06-09 21:08:03 +02:00
|
|
|
@test "aws: s3" {
|
2021-09-09 13:03:07 +02:00
|
|
|
dagger -e aws-s3 up
|
2021-06-09 21:08:03 +02:00
|
|
|
}
|
|
|
|
|
2021-08-18 15:09:28 +02:00
|
|
|
@test "aws: s3/localstack" {
|
2021-09-09 13:03:07 +02:00
|
|
|
skip_unless_local_localstack
|
2021-08-18 15:09:28 +02:00
|
|
|
|
2021-09-09 13:03:07 +02:00
|
|
|
dagger -e aws-s3-localstack up
|
2021-08-18 15:09:28 +02:00
|
|
|
}
|
|
|
|
|
2021-06-18 18:03:59 +02:00
|
|
|
@test "aws: eks" {
|
2022-01-11 12:46:40 +01:00
|
|
|
skip "Temporary skip until porting to localstack"
|
2021-09-09 13:03:07 +02:00
|
|
|
dagger -e aws-eks up
|
2021-06-18 18:03:59 +02:00
|
|
|
}
|
|
|
|
|
2021-06-09 21:08:03 +02:00
|
|
|
@test "docker run: local" {
|
2021-09-22 02:21:32 +02:00
|
|
|
dagger -e docker-run-local up
|
2021-06-09 21:08:03 +02:00
|
|
|
}
|
|
|
|
|
2021-09-28 17:33:02 +02:00
|
|
|
@test "docker run: ports" {
|
|
|
|
dagger -e docker-run-ports up
|
|
|
|
CONTAINER=$(docker container ls -q --filter "name=daggerci-test-ports-*")
|
2021-11-23 19:22:19 +01:00
|
|
|
SECONDS=0
|
|
|
|
while [[ "$(docker inspect --format '{{json .State.Status }}' todoapp | grep -m 1 'running')" != "running" && $SECONDS -lt 45 ]]; do sleep 1 ; done
|
2021-09-28 17:33:02 +02:00
|
|
|
run curl -f -LI http://localhost:8080
|
|
|
|
assert_output --partial '200 OK'
|
2021-09-28 17:52:49 +02:00
|
|
|
docker stop "$CONTAINER" && docker rm "$CONTAINER"
|
2021-09-28 17:33:02 +02:00
|
|
|
}
|
|
|
|
|
2021-06-18 18:03:59 +02:00
|
|
|
@test "docker build" {
|
2021-09-09 13:03:07 +02:00
|
|
|
dagger -e docker-build up
|
2021-06-18 18:03:59 +02:00
|
|
|
}
|
|
|
|
|
2021-06-12 17:11:27 +02:00
|
|
|
@test "docker push and pull" {
|
|
|
|
# Push image
|
|
|
|
dagger -e docker-push up
|
|
|
|
|
|
|
|
# Get image reference
|
2021-06-12 17:11:41 +02:00
|
|
|
dagger -e docker-pull input text ref "$(dagger -e docker-push query -c TestPush.push.ref | tr -d '\n' | tr -d '\"')"
|
2021-06-12 17:11:27 +02:00
|
|
|
|
|
|
|
# Pull image
|
|
|
|
dagger -e docker-pull up
|
|
|
|
}
|
|
|
|
|
2021-07-01 15:48:03 +02:00
|
|
|
@test "docker push: multi registry" {
|
2021-09-09 13:03:07 +02:00
|
|
|
run dagger -e docker-push-multi-registry up
|
2021-07-01 15:48:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "docker push: invalid credential" {
|
2021-06-12 17:11:27 +02:00
|
|
|
# Push image (SHOULD FAIL)
|
2021-06-12 17:11:41 +02:00
|
|
|
run dagger -e docker-push-invalid-creds up
|
2021-06-12 17:11:27 +02:00
|
|
|
assert_failure
|
|
|
|
}
|
|
|
|
|
2021-06-11 09:53:14 +02:00
|
|
|
@test "docker command: ssh" {
|
2021-09-09 13:03:07 +02:00
|
|
|
dagger -e docker-command-ssh up
|
2021-06-11 09:53:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "docker command: ssh with key passphrase" {
|
2021-09-09 13:03:07 +02:00
|
|
|
dagger -e docker-command-ssh-key-passphrase up
|
2021-06-11 09:53:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "docker command: ssh with wrong key passphrase" {
|
2021-09-09 13:03:07 +02:00
|
|
|
run dagger -e docker-command-ssh-wrong-key-passphrase up
|
|
|
|
assert_failure
|
2021-06-11 09:53:14 +02:00
|
|
|
}
|
|
|
|
|
2021-10-13 00:38:09 +02:00
|
|
|
@test "docker load" {
|
|
|
|
dagger -e docker-load up
|
|
|
|
}
|
|
|
|
|
2021-06-25 15:40:49 +02:00
|
|
|
@test "docker compose" {
|
2021-09-09 13:03:07 +02:00
|
|
|
dagger -e docker-compose up
|
2021-06-17 17:12:51 +02:00
|
|
|
}
|
|
|
|
|
2021-06-09 21:08:03 +02:00
|
|
|
@test "docker run: ssh" {
|
2021-09-09 13:03:07 +02:00
|
|
|
dagger -e docker-run-ssh up
|
2021-06-09 21:08:03 +02:00
|
|
|
}
|
|
|
|
|
2021-06-18 18:03:59 +02:00
|
|
|
@test "kubernetes: deployment" {
|
2021-09-09 13:03:07 +02:00
|
|
|
skip_unless_local_kube
|
2021-06-18 18:03:59 +02:00
|
|
|
|
2021-09-09 13:03:07 +02:00
|
|
|
# Copy deployment to sandbox
|
|
|
|
copy_to_sandbox kubernetes-deployment kubernetes
|
2021-06-18 19:15:48 +02:00
|
|
|
|
2021-10-20 22:10:11 +02:00
|
|
|
# Query
|
|
|
|
dagger --project "$DAGGER_SANDBOX" -e kubernetes-deployment query
|
|
|
|
|
2021-09-09 13:03:07 +02:00
|
|
|
# Set kubeconfig
|
2021-09-23 20:07:09 +02:00
|
|
|
dagger --project "$DAGGER_SANDBOX" -e kubernetes-deployment input text TestKubeconfig -f "$HOME"/.kube/config
|
2021-06-18 18:03:59 +02:00
|
|
|
|
2021-09-23 20:07:09 +02:00
|
|
|
dagger --project "$DAGGER_SANDBOX" -e kubernetes-deployment up
|
2021-06-18 18:03:59 +02:00
|
|
|
|
2021-09-09 13:03:07 +02:00
|
|
|
# Unset kubeconfig
|
2021-09-23 20:07:09 +02:00
|
|
|
dagger --project "$DAGGER_SANDBOX" -e kubernetes-deployment input unset TestKubeconfig
|
2021-06-18 18:03:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "kubernetes: kustomize" {
|
2021-09-09 13:03:07 +02:00
|
|
|
dagger -e kubernetes-kustomize up
|
2021-06-18 18:03:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "kubernetes: helm" {
|
2021-09-09 13:03:07 +02:00
|
|
|
skip_unless_local_kube
|
2021-06-18 18:03:59 +02:00
|
|
|
|
2021-09-09 13:03:07 +02:00
|
|
|
# Copy deployment to sandbox
|
|
|
|
copy_to_sandbox kubernetes-helm kubernetes
|
2021-06-18 19:15:48 +02:00
|
|
|
|
2021-09-09 13:03:07 +02:00
|
|
|
# Set kubeconfig
|
2021-09-23 20:07:09 +02:00
|
|
|
dagger --project "$DAGGER_SANDBOX" -e kubernetes-helm input text TestKubeconfig -f "$HOME"/.kube/config
|
2021-06-18 18:03:59 +02:00
|
|
|
|
2021-09-23 20:07:09 +02:00
|
|
|
dagger --project "$DAGGER_SANDBOX" -e kubernetes-helm up
|
2021-06-18 18:03:59 +02:00
|
|
|
|
2021-09-09 13:03:07 +02:00
|
|
|
# Unset kubeconfig
|
2021-09-23 20:07:09 +02:00
|
|
|
dagger --project "$DAGGER_SANDBOX" -e kubernetes-helm input unset TestKubeconfig
|
2021-06-18 18:03:59 +02:00
|
|
|
}
|
|
|
|
|
2021-06-09 21:08:03 +02:00
|
|
|
@test "google cloud: gcr" {
|
2021-09-09 13:03:07 +02:00
|
|
|
dagger -e google-gcr up
|
2021-06-09 21:08:03 +02:00
|
|
|
}
|
|
|
|
|
2021-06-30 12:18:21 +02:00
|
|
|
@test "google cloud: gcs" {
|
2021-09-09 13:03:07 +02:00
|
|
|
dagger -e google-gcs up
|
2021-06-30 12:18:21 +02:00
|
|
|
}
|
2021-06-30 06:31:23 +02:00
|
|
|
|
2021-06-09 21:08:03 +02:00
|
|
|
@test "google cloud: gke" {
|
2021-10-13 00:38:09 +02:00
|
|
|
dagger -e google-gke up
|
2021-06-09 21:08:03 +02:00
|
|
|
}
|
2021-06-21 11:26:54 +02:00
|
|
|
|
2021-08-30 00:43:17 +02:00
|
|
|
@test "google cloud: secretmanager" {
|
|
|
|
run dagger -e google-secretmanager up
|
|
|
|
assert_success
|
|
|
|
|
|
|
|
# ensure the secret has been created
|
|
|
|
run dagger query -e google-secretmanager TestSecrets.secret.references.databasePassword -f text
|
|
|
|
assert_success
|
|
|
|
assert_output --regexp '^projects\/[0-9]+\/secrets\/databasePassword'
|
|
|
|
}
|
|
|
|
|
2021-06-21 11:26:54 +02:00
|
|
|
@test "google cloud: cloudrun" {
|
2021-09-09 13:03:07 +02:00
|
|
|
dagger -e google-cloudrun up
|
2021-06-21 11:26:54 +02:00
|
|
|
}
|
2021-06-22 12:30:48 +02:00
|
|
|
|
2021-06-18 18:03:59 +02:00
|
|
|
@test "terraform" {
|
2021-09-09 13:03:07 +02:00
|
|
|
# it must fail because of a missing var
|
|
|
|
run dagger -e terraform up
|
|
|
|
assert_failure
|
2021-06-18 18:03:59 +02:00
|
|
|
|
2021-09-09 13:03:07 +02:00
|
|
|
# Copy deployment to sandbox
|
|
|
|
copy_to_sandbox terraform terraform
|
2021-06-18 19:15:48 +02:00
|
|
|
|
2021-09-09 13:03:07 +02:00
|
|
|
# Add the var and try again
|
2021-09-23 20:07:09 +02:00
|
|
|
run dagger --project "$DAGGER_SANDBOX" -e terraform input text TestTerraform.apply.tfvars.input "42"
|
|
|
|
run dagger --project "$DAGGER_SANDBOX" -e terraform up
|
2021-09-09 13:03:07 +02:00
|
|
|
assert_success
|
2021-06-18 18:03:59 +02:00
|
|
|
|
2021-09-09 13:03:07 +02:00
|
|
|
# ensure the tfvar was passed correctly
|
2021-09-23 20:07:09 +02:00
|
|
|
run dagger --project "$DAGGER_SANDBOX" query -e terraform TestTerraform.apply.output.input.value -f text
|
2021-09-09 13:03:07 +02:00
|
|
|
assert_success
|
|
|
|
assert_output "42"
|
2021-06-18 18:03:59 +02:00
|
|
|
|
2021-09-09 13:03:07 +02:00
|
|
|
# ensure the random value is always the same
|
|
|
|
# this proves we're effectively using the s3 backend
|
2021-09-23 20:07:09 +02:00
|
|
|
run dagger --project "$DAGGER_SANDBOX" query -e terraform TestTerraform.apply.output.random.value -f json
|
2021-09-09 13:03:07 +02:00
|
|
|
assert_success
|
|
|
|
assert_output "36"
|
2021-06-18 18:03:59 +02:00
|
|
|
|
2021-09-09 13:03:07 +02:00
|
|
|
# Unset input
|
2021-09-23 20:07:09 +02:00
|
|
|
run dagger --project "$DAGGER_SANDBOX" -e terraform input unset TestTerraform.apply.tfvars.input
|
2021-09-09 13:03:07 +02:00
|
|
|
assert_success
|
2021-06-22 12:30:48 +02:00
|
|
|
}
|
2021-08-10 19:20:16 +02:00
|
|
|
|
2021-08-11 15:16:56 +02:00
|
|
|
@test "azure-resourcegroup" {
|
2021-09-09 13:03:07 +02:00
|
|
|
skip "Azure CI infra not implemented yet - manually tested and working"
|
|
|
|
#dagger -e azure-resourcegroup up
|
2021-08-17 11:23:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "azure-storage" {
|
2021-09-09 13:03:07 +02:00
|
|
|
skip "Azure CI infra not implemented yet - manually tested and working"
|
|
|
|
#dagger -e azure-storage up
|
2021-08-30 23:03:04 +02:00
|
|
|
}
|
2021-08-13 16:43:06 +02:00
|
|
|
|
|
|
|
@test "argocd" {
|
2021-09-09 13:03:07 +02:00
|
|
|
skip_unless_local_kube
|
|
|
|
|
|
|
|
# Deploy argoCD infra
|
2021-09-09 15:14:49 +02:00
|
|
|
dagger -e argocd-infra input text TestKubeconfig -f "$HOME"/.kube/config
|
|
|
|
dagger -e argocd-infra up
|
2021-09-09 13:03:07 +02:00
|
|
|
|
2021-09-10 15:37:37 +02:00
|
|
|
# Wait for infra to be ready
|
2021-11-02 13:34:42 +01:00
|
|
|
kubectl -n argocd wait --for=condition=available deployment -l "app.kubernetes.io/part-of=argocd" --timeout=100s
|
2021-09-10 15:37:37 +02:00
|
|
|
|
2021-09-09 15:14:49 +02:00
|
|
|
# Forward port
|
2021-09-10 11:13:10 +02:00
|
|
|
# We need to kill subprocess to avoid infinity loop
|
2021-09-09 15:14:49 +02:00
|
|
|
kubectl port-forward svc/argocd-server -n argocd 8080:443 >/dev/null 2>/dev/null &
|
2021-09-10 11:13:10 +02:00
|
|
|
sleep 3 || (pkill kubectl && exit 1)
|
2021-09-09 15:14:49 +02:00
|
|
|
|
|
|
|
# Run test
|
2021-09-10 11:13:10 +02:00
|
|
|
dagger -e argocd input secret TestConfig.argocdConfig.basicAuth.password "$(kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d)" || (pkill kubectl && exit 1)
|
|
|
|
dagger -e argocd up || (pkill kubectl && exit 1)
|
|
|
|
dagger -e argocd input unset TestConfig.argocdConfig.basicAuth.password || (pkill kubectl && exit 1)
|
2021-09-09 13:03:07 +02:00
|
|
|
|
|
|
|
# Kill Pid
|
2021-09-10 11:13:10 +02:00
|
|
|
pgrep kubectl && pkill kubectl
|
2021-09-10 16:29:29 +02:00
|
|
|
|
|
|
|
# Check output
|
|
|
|
run dagger -e argocd query TestArgoCDStatus.status.outputs.health -f json
|
|
|
|
assert_success
|
|
|
|
assert_output "\"Healthy\""
|
2021-08-13 16:43:06 +02:00
|
|
|
}
|
2021-09-10 06:41:45 +02:00
|
|
|
|
|
|
|
@test "azure-stapp" {
|
|
|
|
skip "Azure CI infra not implemented yet - manually tested and working"
|
|
|
|
#dagger -e azure-stapp up
|
2021-09-22 02:21:32 +02:00
|
|
|
}
|
2021-10-28 01:37:52 +02:00
|
|
|
|
|
|
|
@test "trivy" {
|
|
|
|
dagger -e trivy up
|
2021-12-14 01:12:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "bats" {
|
|
|
|
dagger -e bats up
|
|
|
|
}
|