forked from benc-uk/workflow-dispatch
-
Notifications
You must be signed in to change notification settings - Fork 48
289 lines (276 loc) · 8.7 KB
/
build-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
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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
name: Build & Test
on:
push:
branches: [ master ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '20'
- name: Build with ncc
run: |
npm install -g yarn
yarn install
yarn run build
- name: Archive dist
uses: actions/upload-artifact@v3
with:
name: build
path: dist
echo-1-test:
needs: [build]
runs-on: ubuntu-latest
name: "echo-1-test [trigger|by workflow name]"
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Download dist
uses: actions/download-artifact@v3
with:
name: build
path: dist
- name: Invoke echo 1 workflow using this action (do not wait for completion)
uses: ./
with:
workflow: Message Echo 1
token: ${{ secrets.PERSONAL_TOKEN }}
inputs: '{"message": "blah blah"}'
wait-for-completion: false
echo-2-test:
needs: [build]
runs-on: ubuntu-latest
name: "echo-2-test [trigger|by workflow filename]"
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Download dist
uses: actions/download-artifact@v3
with:
name: build
path: dist
- name: Invoke echo 2 workflow using this action
uses: ./
with:
workflow: echo-2.yaml
token: ${{ secrets.PERSONAL_TOKEN }}
wait-for-completion: false
# - name: Invoke echo 1 workflow by id
# uses: ./
# with:
# workflow: '1854247'
# token: ${{ secrets.PERSONAL_TOKEN }}
# inputs: '{"message": "Mango jam"}'
# wait-for-completion: false
long-running-test:
needs: [build]
runs-on: ubuntu-latest
name: "long-running-test [trigger+wait|by workflow filename|shoud succeed]"
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Download dist
uses: actions/download-artifact@v3
with:
name: build
path: dist
- name: Invoke 'long-running' workflow and wait for result using this action
id: long-running-workflow
uses: ./
with:
workflow: long-running.yml
token: ${{ secrets.PERSONAL_TOKEN }}
wait-for-completion-interval: 10s
wait-for-completion-timeout: 5m
display-workflow-run-url-interval: 10s
display-workflow-run-url-timeout: 5m
continue-on-error: true
- uses: nick-invision/assert-action@v1
with:
expected: success
actual: ${{ steps.long-running-workflow.outputs.workflow-conclusion }}
- uses: nick-invision/assert-action@v1
with:
expected: success
actual: ${{ steps.long-running-workflow.outcome }}
failing-test:
needs: [build]
runs-on: ubuntu-latest
name: "failing-test [trigger+wait|by workflow filename|should report failure]"
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Download dist
uses: actions/download-artifact@v3
with:
name: build
path: dist
- name: Invoke 'failing' workflow and wait for result using this action
id: failing-workflow
uses: ./
with:
workflow: failing.yml
token: ${{ secrets.PERSONAL_TOKEN }}
wait-for-completion-interval: 10s
wait-for-completion-timeout: 60s
display-workflow-run-url-interval: 10s
display-workflow-run-url-timeout: 60s
continue-on-error: true
- run: echo "worflow-conclusion=${{ steps.failing-workflow.outputs.workflow-conclusion }}"
- uses: nick-invision/assert-action@v1
with:
expected: failure
actual: ${{ steps.failing-workflow.outputs.workflow-conclusion }}
- uses: nick-invision/assert-action@v1
with:
expected: failure
actual: ${{ steps.failing-workflow.outcome }}
timeout-test:
needs: [build]
runs-on: ubuntu-latest
name: "timeout-test [trigger+wait|by workflow filename|should report timed_out]"
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Download dist
uses: actions/download-artifact@v3
with:
name: build
path: dist
- name: Invoke 'timeout' workflow and wait for result using this action
id: timeout-workflow
uses: ./
with:
workflow: timeout.yml
token: ${{ secrets.PERSONAL_TOKEN }}
wait-for-completion-interval: 10s
wait-for-completion-timeout: 30s
display-workflow-run-url-interval: 10s
display-workflow-run-url-timeout: 30s
continue-on-error: true
- uses: nick-invision/assert-action@v1
with:
expected: timed_out
actual: ${{ steps.timeout-workflow.outputs.workflow-conclusion }}
- uses: nick-invision/assert-action@v1
with:
expected: failure
actual: ${{ steps.timeout-workflow.outcome }}
print-workflow-logs-test:
needs: [build]
runs-on: ubuntu-latest
name: "print-workflow-logs-test [trigger+wait|by workflow filename|print logs|should report timed_out]"
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Download dist
uses: actions/download-artifact@v3
with:
name: build
path: dist
- name: Invoke 'retrieve-logs' workflow and wait for result using this action
id: print-workflow-logs
uses: ./
with:
workflow: retrieve-logs.yml
token: ${{ secrets.PERSONAL_TOKEN }}
wait-for-completion-interval: 10s
wait-for-completion-timeout: 120s
display-workflow-run-url-interval: 10s
display-workflow-run-url-timeout: 120s
workflow-logs: print
continue-on-error: true
- uses: nick-invision/assert-action@v1
with:
expected: timed_out
actual: ${{ steps.print-workflow-logs.outputs.workflow-conclusion }}
- uses: nick-invision/assert-action@v1
with:
expected: failure
actual: ${{ steps.print-workflow-logs.outcome }}
# TODO: add assertions on logs
# - name: Invoke external workflow using this action
# uses: ./
# with:
# workflow: Deploy To Kubernetes
# repo: benc-uk/dapr-store
# token: ${{ secrets.PERSONAL_TOKEN }}
# ref: master
parallel-runs-test:
needs: [build]
runs-on: ubuntu-latest
name: "parallel-runs-test [trigger+wait|by workflow filename|should succeed]"
strategy:
fail-fast: false
matrix:
environment:
- trunk
- staging
env:
RUN_NAME: ${{ github.repository }}/actions/runs/${{ github.run_id }}/envs/${{ matrix.environment }}
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Download dist
uses: actions/download-artifact@v3
with:
name: build
path: dist
- name: Invoke 'named-run' workflow for this environment and wait for result using this action
id: named-run-workflow
uses: ./
with:
workflow: named-run.yml
token: ${{ secrets.PERSONAL_TOKEN }}
run-name: ${{ env.RUN_NAME }}
wait-for-completion-interval: 10s
wait-for-completion-timeout: 120s
display-workflow-run-url-interval: 10s
display-workflow-run-url-timeout: 120s
workflow-logs: json-output
inputs: >-
{
"run-name": "${{ env.RUN_NAME }}",
"environment": "${{ matrix.environment }}"
}
continue-on-error: true
- uses: nick-invision/assert-action@v1
with:
expected: success
actual: ${{ steps.named-run-workflow.outputs.workflow-conclusion }}
- uses: nick-invision/assert-action@v1
with:
expected: success
actual: ${{ steps.named-run-workflow.outcome }}
- uses: nick-invision/assert-action@v1
env:
EXPECTED_LOG_MESSAGE: "### Env: ${{ matrix.environment }} ###"
with:
expected: true
actual: ${{ contains(fromJson(steps.named-run-workflow.outputs.workflow-logs).echo.*.message, env.EXPECTED_LOG_MESSAGE) }}
deploy:
needs:
- echo-1-test
- echo-2-test
- long-running-test
- failing-test
- timeout-test
- print-workflow-logs-test
- parallel-runs-test
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Download dist
uses: actions/download-artifact@v3
with:
name: build
path: dist
- name: Update repo with build
uses: mikeal/publish-to-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}