Skip to content

Commit 309da91

Browse files
authored
Merge pull request #47 from dcos/ci_script
Add smoke test for CI
2 parents ae311d0 + 9a44a9d commit 309da91

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

ci_smoke_test.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
# Required environment variables:
3+
# GOOGLE_APPLICATION_CREDENTIALS=the path to your service account credentials file - or - GCP_CREDENTIALS: your service account json string
4+
# GCP_PROJECT=the name of your project e.g. development-12345
5+
# TERRAFORM_PATH=the path to your terraform binary; will default to "terraform"
6+
set -euxo pipefail
7+
8+
ssh-keygen -f id_rsa -t rsa -N ''
9+
chmod 600 id_rsa
10+
11+
# download the latest terraform binary in the current working directory
12+
terraform_latest_version=$(curl -s "https://api.github.com/repos/hashicorp/terraform/releases/latest" | grep "tag_name" | grep -Po "(\d|\.)+")
13+
base_url="https://releases.hashicorp.com/terraform/{version}/terraform_{version}_linux_amd64.zip"
14+
terraform_download_url=$(echo ${base_url} | sed "s/{version}/$terraform_latest_version/g")
15+
zip="terraform.zip"
16+
wget --output-document="$zip" "$terraform_download_url"
17+
unzip "$zip"
18+
rm "$zip"
19+
20+
if [[ ! -v TERRAFORM_PATH ]]
21+
then
22+
TERRAFORM_PATH="terraform"
23+
fi
24+
25+
cd gcp
26+
if [[ ! -v GOOGLE_APPLICATION_CREDENTIALS ]]
27+
then
28+
echo "$GCP_CREDENTIALS" > creds.json
29+
export GOOGLE_APPLICATION_CREDENTIALS=${PWD}/creds.json
30+
fi
31+
${TERRAFORM_PATH} init
32+
${TERRAFORM_PATH} validate -var "gcp_project=${GCP_PROJECT}" -var "gcp_ssh_pub_key_file=${PWD}/../id_rsa.pub"
33+
${TERRAFORM_PATH} plan -var "gcp_project=${GCP_PROJECT}" -var "gcp_ssh_pub_key_file=${PWD}/../id_rsa.pub"
34+
${TERRAFORM_PATH} validate -var-file desired_cluster_profile.tfvars.example -var "gcp_project=${GCP_PROJECT}" -var "gcp_ssh_pub_key_file=${PWD}/../id_rsa.pub"
35+
${TERRAFORM_PATH} plan -var-file desired_cluster_profile.tfvars.example -var "gcp_project=${GCP_PROJECT}" -var "gcp_ssh_pub_key_file=${PWD}/../id_rsa.pub"
36+
37+
cd ../aws
38+
${TERRAFORM_PATH} init
39+
${TERRAFORM_PATH} validate
40+
${TERRAFORM_PATH} plan
41+
${TERRAFORM_PATH} validate -var-file desired_cluster_profile.tfvars.example
42+
${TERRAFORM_PATH} plan -var-file desired_cluster_profile.tfvars.example
43+
44+
cd ../azure
45+
${TERRAFORM_PATH} init
46+
${TERRAFORM_PATH} validate
47+
${TERRAFORM_PATH} plan
48+
${TERRAFORM_PATH} validate -var-file desired_cluster_profile.tfvars.example
49+
${TERRAFORM_PATH} plan -var-file desired_cluster_profile.tfvars.example

0 commit comments

Comments
 (0)