Skip to content

Merge pull request #457 from BillAnastasiadis/horror_code #1154

Merge pull request #457 from BillAnastasiadis/horror_code

Merge pull request #457 from BillAnastasiadis/horror_code #1154

Workflow file for this run

name: Terraform
on:
push:
branches:
- 'main'
pull_request:
paths:
- 'terraform/**'
- '.github/workflows/terraform.yml'
env:
PYTEST_ADDOPTS: "--color=yes"
PYTHON_VERSION: 3.11
TF_PLUGIN_CACHE_DIR: "/home/runner/.terraform.d/plugin-cache"
TF_VERSION: 1.5.7
TFTESTS_FOLDER: "terraform/tests"
jobs:
terraform:
runs-on: ubuntu-latest
strategy:
matrix:
provider: ['azure', 'gcp', 'aws']
defaults:
run:
shell: bash
working-directory: terraform/${{ matrix.provider }}
steps:
- name: Checkout
uses: actions/checkout@v3
# Install the specific version of Terraform that the project support and
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: ${{ env.TF_VERSION }}
terraform_wrapper: false
# Initialize each CSP Terraform working directory
# by creating initial files, downloading modules, etc.
- name: Terraform Init
run: terraform init
# Checks that all Terraform configuration files adhere to a canonical format
- name: Terraform Format
run: terraform fmt -check -recursive -diff
# Validate
- name: Terraform Validate
run: terraform validate
tftest:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
# Install the specific version of Terraform that the project support and
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: ${{ env.TF_VERSION }}
terraform_wrapper: false
- name: Run tftests
run: |
mkdir -p ${{ env.TF_PLUGIN_CACHE_DIR }}
pip install -r ${{ env.TFTESTS_FOLDER }}/requirements.txt
pytest -vv -o log_cli=true -o log_cli_level=10 ${{ env.TFTESTS_FOLDER }}