Run TF tests from repo root (#4723)

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

View file

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

View file

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