-
Notifications
You must be signed in to change notification settings - Fork 13
73 lines (60 loc) · 1.8 KB
/
terraform.yml
File metadata and controls
73 lines (60 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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 }}