Skip to content

Commit e845bf7

Browse files
authored
Merge pull request #17 from LudovicTOURMAN/master
Rework getWorkflowRunId() when run-name is provided
2 parents 00dba38 + be690ca commit e845bf7

File tree

15 files changed

+480
-145
lines changed

15 files changed

+480
-145
lines changed

.github/workflows/build-test.yaml

Lines changed: 68 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ jobs:
9292
token: ${{ secrets.PERSONAL_TOKEN }}
9393
wait-for-completion-interval: 10s
9494
wait-for-completion-timeout: 5m
95+
display-workflow-run-url-interval: 10s
96+
display-workflow-run-url-timeout: 5m
9597
continue-on-error: true
9698
- uses: nick-invision/assert-action@v1
9799
with:
@@ -105,7 +107,7 @@ jobs:
105107
failing-test:
106108
needs: [build]
107109
runs-on: ubuntu-latest
108-
name: "failing-test [trigger+wait|by workflow filename|shoud report failure]"
110+
name: "failing-test [trigger+wait|by workflow filename|should report failure]"
109111
steps:
110112
- name: Check out repository
111113
uses: actions/checkout@v3
@@ -121,7 +123,9 @@ jobs:
121123
workflow: failing.yml
122124
token: ${{ secrets.PERSONAL_TOKEN }}
123125
wait-for-completion-interval: 10s
124-
wait-for-completion-timeout: 5m
126+
wait-for-completion-timeout: 60s
127+
display-workflow-run-url-interval: 10s
128+
display-workflow-run-url-timeout: 60s
125129
continue-on-error: true
126130
- run: echo "worflow-conclusion=${{ steps.failing-workflow.outputs.workflow-conclusion }}"
127131
- uses: nick-invision/assert-action@v1
@@ -136,7 +140,7 @@ jobs:
136140
timeout-test:
137141
needs: [build]
138142
runs-on: ubuntu-latest
139-
name: "timeout-test [trigger+wait|by workflow filename|shoud report timed_out]"
143+
name: "timeout-test [trigger+wait|by workflow filename|should report timed_out]"
140144
steps:
141145
- name: Check out repository
142146
uses: actions/checkout@v3
@@ -153,6 +157,8 @@ jobs:
153157
token: ${{ secrets.PERSONAL_TOKEN }}
154158
wait-for-completion-interval: 10s
155159
wait-for-completion-timeout: 30s
160+
display-workflow-run-url-interval: 10s
161+
display-workflow-run-url-timeout: 30s
156162
continue-on-error: true
157163
- uses: nick-invision/assert-action@v1
158164
with:
@@ -166,7 +172,7 @@ jobs:
166172
print-workflow-logs-test:
167173
needs: [build]
168174
runs-on: ubuntu-latest
169-
name: "print-workflow-logs-test [trigger+wait|by workflow filename|print logs|shoud report timed_out]"
175+
name: "print-workflow-logs-test [trigger+wait|by workflow filename|print logs|should report timed_out]"
170176
steps:
171177
- name: Check out repository
172178
uses: actions/checkout@v3
@@ -183,6 +189,8 @@ jobs:
183189
token: ${{ secrets.PERSONAL_TOKEN }}
184190
wait-for-completion-interval: 10s
185191
wait-for-completion-timeout: 120s
192+
display-workflow-run-url-interval: 10s
193+
display-workflow-run-url-timeout: 120s
186194
workflow-logs: print
187195
continue-on-error: true
188196
- uses: nick-invision/assert-action@v1
@@ -198,10 +206,63 @@ jobs:
198206
# - name: Invoke external workflow using this action
199207
# uses: ./
200208
# with:
201-
# workflow: Deploy To Kubernetes
209+
# workflow: Deploy To Kubernetes
202210
# repo: benc-uk/dapr-store
203211
# token: ${{ secrets.PERSONAL_TOKEN }}
204-
# ref: master
212+
# ref: master
213+
214+
parallel-runs-test:
215+
needs: [build]
216+
runs-on: ubuntu-latest
217+
name: "parallel-runs-test [trigger+wait|by workflow filename|should succeed]"
218+
strategy:
219+
fail-fast: false
220+
matrix:
221+
environment:
222+
- trunk
223+
- staging
224+
env:
225+
RUN_NAME: ${{ github.repository }}/actions/runs/${{ github.run_id }}/envs/${{ matrix.environment }}
226+
steps:
227+
- name: Check out repository
228+
uses: actions/checkout@v3
229+
- name: Download dist
230+
uses: actions/download-artifact@v3
231+
with:
232+
name: build
233+
path: dist
234+
- name: Invoke 'named-run' workflow for this environment and wait for result using this action
235+
id: named-run-workflow
236+
uses: ./
237+
with:
238+
workflow: named-run.yml
239+
token: ${{ secrets.PERSONAL_TOKEN }}
240+
run-name: ${{ env.RUN_NAME }}
241+
wait-for-completion-interval: 10s
242+
wait-for-completion-timeout: 120s
243+
display-workflow-run-url-interval: 10s
244+
display-workflow-run-url-timeout: 120s
245+
workflow-logs: json-output
246+
inputs: >-
247+
{
248+
"run-name": "${{ env.RUN_NAME }}",
249+
"environment": "${{ matrix.environment }}"
250+
}
251+
continue-on-error: true
252+
- uses: nick-invision/assert-action@v1
253+
with:
254+
expected: success
255+
actual: ${{ steps.named-run-workflow.outputs.workflow-conclusion }}
256+
- uses: nick-invision/assert-action@v1
257+
with:
258+
expected: success
259+
actual: ${{ steps.named-run-workflow.outcome }}
260+
- uses: nick-invision/assert-action@v1
261+
env:
262+
EXPECTED_LOG_MESSAGE: "### Env: ${{ matrix.environment }} ###"
263+
with:
264+
expected: true
265+
actual: ${{ contains(fromJson(steps.named-run-workflow.outputs.workflow-logs).echo.*.message, env.EXPECTED_LOG_MESSAGE) }}
205266

206267
deploy:
207268
needs:
@@ -211,6 +272,7 @@ jobs:
211272
- failing-test
212273
- timeout-test
213274
- print-workflow-logs-test
275+
- parallel-runs-test
214276
runs-on: ubuntu-latest
215277
steps:
216278
- name: Check out repository

.github/workflows/echo-1.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Message Echo 1
22

3-
on:
3+
on:
44
workflow_dispatch:
55
inputs:
66
message:

.github/workflows/echo-2.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Message Echo 2
22

3-
on:
3+
on:
44
workflow_dispatch:
55
inputs:
66
message:
@@ -13,4 +13,4 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Echo message
16-
run: echo '${{ github.event.inputs.message }}'
16+
run: echo '${{ github.event.inputs.message }}'

.github/workflows/failing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Failing
22

3-
on:
3+
on:
44
workflow_dispatch:
55

66
jobs:

.github/workflows/long-running.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Long running
22

3-
on:
3+
on:
44
workflow_dispatch:
55

66
jobs:

.github/workflows/named-run.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Named run
2+
run-name: ${{ inputs.run-name }}
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
run-name:
8+
description: 'The distinct run name used to retrieve the run ID. Defaults to the workflow name'
9+
type: string
10+
required: false
11+
environment:
12+
description: 'The environment name'
13+
type: string
14+
required: true
15+
16+
jobs:
17+
echo:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Sleep
21+
run: sleep 10s
22+
- name: Echo message
23+
run: |
24+
echo '### Env: ${{ github.event.inputs.environment }} ###'

.github/workflows/retrieve-logs.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Retrieve logs
22

3-
on:
3+
on:
44
workflow_dispatch:
55

66
jobs:
@@ -13,14 +13,14 @@ jobs:
1313
do
1414
echo "Hello $i"
1515
sleep 0.1
16-
done
17-
16+
done
17+
1818
timeout:
1919
runs-on: ubuntu-latest
2020
steps:
2121
- name: Sleep
2222
run: sleep 1200s
23-
23+
2424
more-real-example:
2525
runs-on: ubuntu-latest
2626
steps:

.github/workflows/timeout.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Timeout
22

3-
on:
3+
on:
44
workflow_dispatch:
55

66
jobs:

0 commit comments

Comments
 (0)