-
Notifications
You must be signed in to change notification settings - Fork 1
261 lines (221 loc) · 6.58 KB
/
tests.yml
File metadata and controls
261 lines (221 loc) · 6.58 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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
name: Test action
on:
push:
jobs:
should-set-image-and-apply-config:
name: Should set image and apply config
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: dimw/mockbin-action@v1
with:
commands: |
kubectl
kustomize
- name: Act
uses: './'
with:
resource-directory: './'
images: my-image
- uses: dimw/mockbin-action@v1
with:
commands: kustomize
assert-args: |
["edit", "set", "image", "my-image"]
["build"]
- uses: dimw/mockbin-action@v1
with:
commands: kubectl
assert-args: '["apply", "--kubeconfig=", "--dry-run=none", "--filename", "-"]'
should-set-secrets:
name: Should set secrets
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: dimw/mockbin-action@v1
with:
commands: |
kubectl
kustomize
- name: Act
uses: './'
with:
resource-directory: './'
secrets-name: my-secrets
secrets: |
foo=bar
- name: Secrets file must be present
run: |
if [[! -f "secrets.env" || "$(cat secrets.env)" != "$(echo -n 'foo=bar\n')" ]]; then
exit 1
fi
- uses: dimw/mockbin-action@v1
with:
commands: kustomize
assert-args: |
["edit", "add", "secret", "my-secrets", "--from-env-file=secrets.env"]
["build"]
- uses: dimw/mockbin-action@v1
with:
commands: kubectl
assert-args: '["apply", "--kubeconfig=", "--dry-run=none", "--filename", "-"]'
should-set-secrets-from-file:
name: Should set secrets from files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: dimw/mockbin-action@v1
with:
commands: |
kubectl
kustomize
- name: Prepare secret files
working-directory: ./
run: |
touch ./foo.secret
touch ./bar.secret
- name: Act
uses: './'
with:
resource-directory: './'
secrets-name: my-secrets
secrets-from-files: |
fooSecret=foo.secret
barSecret=bar.secret
- uses: dimw/mockbin-action@v1
with:
commands: kustomize
assert-args: |
["edit", "add", "secret", "my-secrets", "--from-file=fooSecret=foo.secret"]
["edit", "add", "secret", "my-secrets", "--from-file=barSecret=bar.secret"]
["build"]
- uses: dimw/mockbin-action@v1
with:
commands: kubectl
assert-args: '["apply", "--kubeconfig=", "--dry-run=none", "--filename", "-"]'
should-set-configmap:
name: Should set configmap
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: dimw/mockbin-action@v1
with:
commands: |
kubectl
kustomize
- name: Act
uses: './'
with:
resource-directory: './'
configmap-name: my-configmap
configmap: |
some=config
- name: Secrets file must be present
run: |
if [[! -f "configmap.env" || "$(cat configmap.env)" != "$(echo -n 'some=config\n')" ]]; then
exit 1
fi
- uses: dimw/mockbin-action@v1
with:
commands: kustomize
assert-args: |
["edit", "add", "configmap", "my-configmap", "--from-env-file=configmap.env"]
["build"]
- uses: dimw/mockbin-action@v1
with:
commands: kubectl
assert-args: '["apply", "--kubeconfig=", "--dry-run=none", "--filename", "-"]'
should-set-configmap-from-files:
name: Should set configmap from files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: dimw/mockbin-action@v1
with:
commands: |
kubectl
kustomize
- name: Prepare config files
working-directory: ./
run: |
touch ./foo.config
touch ./bar.config
- name: Act
uses: './'
with:
resource-directory: './'
configmap-name: my-configmap
configmap-from-files: |
fooConfig=foo.config
barConfig=bar.config
- uses: dimw/mockbin-action@v1
with:
commands: kustomize
assert-args: |
["edit", "add", "configmap", "my-configmap", "--from-file=fooConfig=foo.config"]
["edit", "add", "configmap", "my-configmap", "--from-file=barConfig=bar.config"]
["build"]
- uses: dimw/mockbin-action@v1
with:
commands: kubectl
assert-args: '["apply", "--kubeconfig=", "--dry-run=none", "--filename", "-"]'
should-dry-run-server:
name: Should dry-run on server
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: dimw/mockbin-action@v1
with:
commands: |
kubectl
kustomize
- name: Act
uses: './'
with:
resource-directory: './'
dry-run: server
- uses: dimw/mockbin-action@v1
with:
commands: kubectl
assert-args: '["apply", "--kubeconfig=", "--dry-run=server", "--filename", "-"]'
should-use-kube-config-data:
name: Should use custom .kube/config
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: dimw/mockbin-action@v1
with:
commands: |
kubectl
kustomize
- name: Act
uses: './'
with:
resource-directory: './'
kube-config-data: |-
foo: bar
- uses: dimw/mockbin-action@v1
with:
commands: kubectl
assert-args: |
["apply", "--kubeconfig=${{ github.workspace }}/.k8s-deploy-action-kube-config-[a-z0-9]+.yml", "--dry-run=none", "--filename", "-"]
should-call-kubectl-apply-with-params:
name: Should call kubectl apply with additional parameters
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: dimw/mockbin-action@v1
with:
commands: |
kubectl
kustomize
- name: Act
uses: './'
with:
resource-directory: './'
kubectl-params: '--foo=bar'
- uses: dimw/mockbin-action@v1
with:
commands: kubectl
assert-args: |
["apply", "--foo=bar", "--kubeconfig=", "--dry-run=none", "--filename", "-"]