forked from the-actions-org/workflow-dispatch
-
Notifications
You must be signed in to change notification settings - Fork 1
227 lines (215 loc) · 6.47 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
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
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|shoud 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: 5m
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|shoud 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
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|shoud 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
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
deploy:
needs:
- echo-1-test
- echo-2-test
- long-running-test
- failing-test
- timeout-test
- print-workflow-logs-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 }}