-
Notifications
You must be signed in to change notification settings - Fork 4
173 lines (140 loc) · 4.47 KB
/
ci.yaml
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: "Continuous Integration"
on:
push:
branches: [master]
pull_request: {}
env:
AWS_REGION: eu-west-1
jobs:
terraform-fmt:
name: Check formatting
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Terraform 1.x
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.x
- name: terraform fmt
run: terraform fmt -recursive -check -diff
terraform-docs:
name: Check documentation
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup terraform-docs
env:
VERSION: "0.14.1"
run: |
set -e
mkdir -p /tmp/terraform-docs/bin
cd /tmp/terraform-docs/bin
curl -sSLo terraform-docs.tar.gz https://terraform-docs.io/dl/v$VERSION/terraform-docs-v$VERSION-$(uname)-amd64.tar.gz
tar -xzf terraform-docs.tar.gz
chmod +x terraform-docs
rm terraform-docs.tar.gz
echo /tmp/terraform-docs/bin >>$GITHUB_PATH
- name: terraform docs
run: tools/bin/check-all-docs
download_providers:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
tf_version:
- "0.12.x"
- "0.13.x"
- "0.14.x"
- "1.x"
name: "[terraform ${{ matrix.tf_version }}] Download providers"
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: ${{ matrix.tf_version }}
- name: Setup providers cache
id: cache_providers
uses: actions/cache@v2
with:
path: |
./.terraform/plugins
./.terraform/providers
key: ${{ runner.os }}-terraform-${{ matrix.tf_version }}-providers-${{ hashFiles('./versions.tf') }}
- name: Download providers
id: download_providers
if: steps.cache_providers.outputs.cache-hit != 'true'
run: terraform init -backend=false
terraform-validate-modules:
needs: [download_providers]
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
tf_version:
- "0.12.x"
- "0.13.x"
- "0.14.x"
- "1.x"
name: "[terraform ${{ matrix.tf_version }}] Validate modules"
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: ${{ matrix.tf_version }}
- name: Download cached providers
uses: codequest-eu/restore-cache-action@master
with:
path: |
./.terraform/plugins
./.terraform/providers
key: ${{ runner.os }}-terraform-${{ matrix.tf_version }}-providers-${{ hashFiles('./versions.tf') }}
- name: terraform validate
run: |
case '${{ matrix.tf_version }}' in
0.12.*) plugins="$PWD/.terraform/plugins/linux_amd64" ;;
0.13.*) plugins="$PWD/.terraform/plugins" ;;
*) plugins="$PWD/.terraform/providers" ;;
esac
export TF_CLI_ARGS_init="-plugin-dir='$plugins'"
tools/bin/validate-all-modules
terraform-validate-examples:
needs: [download_providers]
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
tf_version:
- "0.12.x"
- "0.13.x"
- "0.14.x"
- "1.x"
name: "[terraform ${{ matrix.tf_version }}] Validate examples"
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: ${{ matrix.tf_version }}
- name: Download cached providers
uses: codequest-eu/restore-cache-action@master
with:
path: |
./.terraform/plugins
./.terraform/providers
key: ${{ runner.os }}-terraform-${{ matrix.tf_version }}-providers-${{ hashFiles('./versions.tf') }}
- name: terraform validate
run: |
case '${{ matrix.tf_version }}' in
0.12.*) plugins="$PWD/.terraform/plugins/linux_amd64" ;;
0.13.*) plugins="$PWD/.terraform/plugins" ;;
*) plugins="$PWD/.terraform/providers" ;;
esac
export TF_CLI_ARGS_init="-plugin-dir='$plugins'"
tools/bin/validate-all-examples