Skip to content

Commit

Permalink
Merge pull request #17 from LudovicTOURMAN/master
Browse files Browse the repository at this point in the history
Rework getWorkflowRunId() when run-name is provided
  • Loading branch information
fbiesse authored Jun 19, 2024
2 parents 00dba38 + be690ca commit e845bf7
Show file tree
Hide file tree
Showing 15 changed files with 480 additions and 145 deletions.
74 changes: 68 additions & 6 deletions .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ jobs:
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:
Expand All @@ -105,7 +107,7 @@ jobs:
failing-test:
needs: [build]
runs-on: ubuntu-latest
name: "failing-test [trigger+wait|by workflow filename|shoud report failure]"
name: "failing-test [trigger+wait|by workflow filename|should report failure]"
steps:
- name: Check out repository
uses: actions/checkout@v3
Expand All @@ -121,7 +123,9 @@ jobs:
workflow: failing.yml
token: ${{ secrets.PERSONAL_TOKEN }}
wait-for-completion-interval: 10s
wait-for-completion-timeout: 5m
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
Expand All @@ -136,7 +140,7 @@ jobs:
timeout-test:
needs: [build]
runs-on: ubuntu-latest
name: "timeout-test [trigger+wait|by workflow filename|shoud report timed_out]"
name: "timeout-test [trigger+wait|by workflow filename|should report timed_out]"
steps:
- name: Check out repository
uses: actions/checkout@v3
Expand All @@ -153,6 +157,8 @@ jobs:
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:
Expand All @@ -166,7 +172,7 @@ jobs:
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]"
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
Expand All @@ -183,6 +189,8 @@ jobs:
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
Expand All @@ -198,10 +206,63 @@ jobs:
# - name: Invoke external workflow using this action
# uses: ./
# with:
# workflow: Deploy To Kubernetes
# workflow: Deploy To Kubernetes
# repo: benc-uk/dapr-store
# token: ${{ secrets.PERSONAL_TOKEN }}
# ref: master
# 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:
Expand All @@ -211,6 +272,7 @@ jobs:
- failing-test
- timeout-test
- print-workflow-logs-test
- parallel-runs-test
runs-on: ubuntu-latest
steps:
- name: Check out repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/echo-1.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Message Echo 1

on:
on:
workflow_dispatch:
inputs:
message:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/echo-2.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Message Echo 2

on:
on:
workflow_dispatch:
inputs:
message:
Expand All @@ -13,4 +13,4 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Echo message
run: echo '${{ github.event.inputs.message }}'
run: echo '${{ github.event.inputs.message }}'
2 changes: 1 addition & 1 deletion .github/workflows/failing.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Failing

on:
on:
workflow_dispatch:

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/long-running.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Long running

on:
on:
workflow_dispatch:

jobs:
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/named-run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Named run
run-name: ${{ inputs.run-name }}

on:
workflow_dispatch:
inputs:
run-name:
description: 'The distinct run name used to retrieve the run ID. Defaults to the workflow name'
type: string
required: false
environment:
description: 'The environment name'
type: string
required: true

jobs:
echo:
runs-on: ubuntu-latest
steps:
- name: Sleep
run: sleep 10s
- name: Echo message
run: |
echo '### Env: ${{ github.event.inputs.environment }} ###'
8 changes: 4 additions & 4 deletions .github/workflows/retrieve-logs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Retrieve logs

on:
on:
workflow_dispatch:

jobs:
Expand All @@ -13,14 +13,14 @@ jobs:
do
echo "Hello $i"
sleep 0.1
done
done
timeout:
runs-on: ubuntu-latest
steps:
- name: Sleep
run: sleep 1200s

more-real-example:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/timeout.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Timeout

on:
on:
workflow_dispatch:

jobs:
Expand Down
Loading

0 comments on commit e845bf7

Please sign in to comment.