-
-
Notifications
You must be signed in to change notification settings - Fork 159
185 lines (162 loc) · 4.72 KB
/
test-test.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
174
175
176
177
178
179
180
181
182
183
184
185
name: Test terraform-test
on:
- pull_request
permissions:
contents: read
jobs:
default:
runs-on: ubuntu-24.04
name: Default inputs
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Test
uses: ./terraform-test
id: test
with:
path: tests/workflows/test-test/local
- name: Check Passed
env:
FAILURE_REASON: ${{ steps.test.outputs.failure-reason }}
run: |
if [[ "$FAILURE_REASON" != "" ]]; then
echo "::error:: failure-reason not set correctly"
exit 1
fi
filter:
runs-on: ubuntu-24.04
name: Default path with a filter
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Test
uses: ./terraform-test
id: test
with:
path: tests/workflows/test-test/local
test_filter: tests/main.tftest.hcl
- name: Check Passed
env:
FAILURE_REASON: ${{ steps.test.outputs.failure-reason }}
run: |
if [[ "$FAILURE_REASON" != "" ]]; then
echo "::error:: failure-reason not set correctly"
exit 1
fi
test_dir:
runs-on: ubuntu-24.04
name: Custom test directory
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Test
uses: ./terraform-test
id: test
with:
path: tests/workflows/test-test/local
test_directory: custom-test-dir
test_filter: |
custom-test-dir/another.tftest.hcl
custom-test-dir/a-third.tftest.hcl
- name: Check Passed
env:
FAILURE_REASON: ${{ steps.test.outputs.failure-reason }}
run: |
if [[ "$FAILURE_REASON" != "" ]]; then
echo "::error:: failure-reason not set correctly"
exit 1
fi
nonexistent_test_dir:
runs-on: ubuntu-24.04
name: Missing test directory
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Test
uses: ./terraform-test
id: nonexistent_test_dir
continue-on-error: true
with:
path: tests/workflows/test-test/local
test_directory: i-dont-exist
- name: Check failure
env:
OUTCOME: ${{ steps.nonexistent_test_dir.outcome }}
FAILURE_REASON: ${{ steps.nonexistent_test_dir.outputs.failure-reason }}
run: |
if [[ "$OUTCOME" != "failure" ]]; then
echo "Test did not fail correctly"
exit 1
fi
if [[ "$FAILURE_REASON" != "no-tests" ]]; then
echo "::error:: failure-reason not set correctly"
exit 1
fi
faulty_filter:
runs-on: ubuntu-24.04
name: Filter matches no tests
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Test
uses: ./terraform-test
id: faulty_filter
continue-on-error: true
with:
path: tests/workflows/test-test/local
test_filter: |
tests/this-test-does-not-exist.tftest.hcl
tests/nor-does-this-one.tftest.hcl
- name: Check failure
env:
OUTCOME: ${{ steps.faulty_filter.outcome }}
FAILURE_REASON: ${{ steps.faulty_filter.outputs.failure-reason }}
run: |
if [[ "$OUTCOME" != "failure" ]]; then
echo "Test did not fail correctly"
exit 1
fi
if [[ "$FAILURE_REASON" != "no-tests" ]]; then
echo "::error:: failure-reason not set correctly"
exit 1
fi
failing:
runs-on: ubuntu-24.04
name: A failing test using variables
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Test
uses: ./terraform-test
id: failing
continue-on-error: true
with:
path: tests/workflows/test-test/local
test_filter: tests/main.tftest.hcl
variables: |
length = 1
- name: Check failure-reason
env:
OUTCOME: ${{ steps.failing.outcome }}
FAILURE_REASON: ${{ steps.failing.outputs.failure-reason }}
run: |
if [[ "$OUTCOME" != "failure" ]]; then
echo "Test did not fail correctly"
exit 1
fi
if [[ "$FAILURE_REASON" != "tests-failed" ]]; then
echo "::error:: failure-reason not set correctly"
exit 1
fi