-
-
Notifications
You must be signed in to change notification settings - Fork 159
152 lines (131 loc) · 3.92 KB
/
test-validate.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
name: Test terraform-validate
on:
- pull_request
permissions:
contents: read
jobs:
valid:
runs-on: ubuntu-24.04
name: valid
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: validate
uses: ./terraform-validate
id: validate
with:
path: tests/workflows/test-validate/valid
- name: Check valid
env:
FAILURE_REASON: ${{ steps.validate.outputs.failure-reason }}
run: |
if [[ "$FAILURE_REASON" != "" ]]; then
echo "::error:: failure-reason not set correctly"
exit 1
fi
invalid:
runs-on: ubuntu-24.04
name: Invalid terraform configuration
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: validate
uses: ./terraform-validate
id: validate
continue-on-error: true
with:
path: tests/workflows/test-validate/invalid
- name: Check invalid
env:
OUTCOME: ${{ steps.validate.outcome }}
FAILURE_REASON: ${{ steps.validate.outputs.failure-reason }}
run: |
if [[ "$OUTCOME" != "failure" ]]; then
echo "Validate did not fail correctly"
exit 1
fi
if [[ "$FAILURE_REASON" != "validate-failed" ]]; then
echo "::error:: failure-reason not set correctly"
exit 1
fi
validate_workspace:
runs-on: ubuntu-24.04
name: Use workspace name during validation
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: validate prod
uses: ./terraform-validate
with:
path: tests/workflows/test-validate/workspace_eval
workspace: prod
- name: validate dev
uses: ./terraform-validate
with:
path: tests/workflows/test-validate/workspace_eval
workspace: dev
- name: validate nonexistant workspace
uses: ./terraform-validate
id: validate
continue-on-error: true
with:
path: tests/workflows/test-validate/workspace_eval
- name: Check invalid
env:
OUTCOME: ${{ steps.validate.outcome }}
FAILURE_REASON: ${{ steps.validate.outputs.failure-reason }}
run: |
if [[ "$OUTCOME" != "failure" ]]; then
echo "Validate did not fail correctly"
exit 1
fi
if [[ "$FAILURE_REASON" != "validate-failed" ]]; then
echo "::error:: failure-reason not set correctly"
exit 1
fi
validate_remote_workspace:
runs-on: ubuntu-24.04
name: Use workspace name during validation
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: validate prod
uses: ./terraform-validate
with:
path: tests/workflows/test-validate/workspace_eval_remote
workspace: prod
validate_unterminated_string:
runs-on: ubuntu-24.04
name: Validate with unterminated string
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: validate
uses: ./terraform-validate
with:
path: tests/workflows/test-validate/unterminated-string
id: validate
continue-on-error: true
- name: Check invalid
env:
OUTCOME: ${{ steps.validate.outcome }}
FAILURE_REASON: ${{ steps.validate.outputs.failure-reason }}
run: |
if [[ "$OUTCOME" != "failure" ]]; then
echo "Validate did not fail correctly"
exit 1
fi
if [[ "$FAILURE_REASON" != "validate-failed" ]]; then
echo "::error:: failure-reason not set correctly"
exit 1
fi