Run TF tests from repo root (#4723)

pull/4734/head
Maxime Guyot 2019-05-09 08:40:49 +02:00 committed by Kubernetes Prow Robot
parent f0572e59e7
commit 3776000fc4
3 changed files with 12 additions and 12 deletions

View File

@ -9,10 +9,9 @@
# Set Ansible config
- cp ansible.cfg ~/.ansible.cfg
# Prepare inventory
- cp -LRp contrib/terraform/$PROVIDER/sample-inventory inventory/$CLUSTER
- cd inventory/$CLUSTER
- ln -s ../../contrib/terraform/$PROVIDER/hosts
- terraform init ../../contrib/terraform/$PROVIDER
- cp contrib/terraform/$PROVIDER/sample-inventory/cluster.tf .
- ln -s contrib/terraform/$PROVIDER/hosts
- terraform init contrib/terraform/$PROVIDER
# Copy SSH keypair
- mkdir -p ~/.ssh
- echo "$PACKET_PRIVATE_KEY" | base64 -d > ~/.ssh/id_rsa
@ -24,8 +23,8 @@
stage: unit-tests
only: ['master', /^pr-.*$/]
script:
- terraform validate -var-file=cluster.tf ../../contrib/terraform/$PROVIDER
- terraform fmt -check -diff ../../contrib/terraform/$PROVIDER
- terraform validate -var-file=cluster.tf contrib/terraform/$PROVIDER
- terraform fmt -check -diff contrib/terraform/$PROVIDER
.terraform_apply:
extends: .terraform_install
@ -37,8 +36,9 @@
ANSIBLE_INVENTORY: hosts
CI_PLATFORM: tf
script:
- cd ../../tests && make create-${CI_PLATFORM} -s ; cd -
- ansible-playbook ../../cluster.yml --become
- cd tests && make create-${CI_PLATFORM} -s ; cd -
- ansible-playbook cluster.yml --become
# - tests/scripts/testcases_prepare.sh
after_script:
# Cleanup regardless of exit code
- ./tests/scripts/testcases_cleanup.sh

View File

@ -1,5 +1,5 @@
#!/bin/bash
set -euxo pipefail
cd "../inventory/$CLUSTER"
terraform apply -auto-approve "../../contrib/terraform/$PROVIDER"
cd ..
terraform apply -auto-approve "contrib/terraform/$PROVIDER"

View File

@ -1,5 +1,5 @@
#!/bin/bash
set -euxo pipefail
cd "../inventory/$CLUSTER"
terraform destroy -auto-approve "../../contrib/terraform/$PROVIDER"
cd ..
terraform destroy -auto-approve "contrib/terraform/$PROVIDER"