(feat): Expose exponential backoff parameters as GitHub Action parameters #276
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 'Build and Test' | |
on: # rebuild any PRs and main branch changes | |
pull_request: | |
workflow_dispatch: | |
push: | |
branches: | |
- "main" | |
jobs: | |
integration-tests: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
actions: write | |
env: | |
INTEGRATION_TEST_WORKFLOW_FILE: "integration-tests.yml" | |
INTEGRATION_TEST_WORKFLOW_ID: 64701969 # This ID Will Change On Fork | |
steps: | |
- uses: actions/checkout@v4 | |
- id: nvmrc | |
name: Extract Node.JS Version | |
shell: bash | |
run: | | |
echo "node-version=$(cat .nvmrc)" >> "${GITHUB_OUTPUT}" | |
- name: Set Node.JS | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "${{ steps.nvmrc.outputs.node-version }}" | |
- id: clean-dist | |
shell: bash | |
run: | | |
# Clean the existing dist/ folder so that we only test fresh | |
# compiled code | |
rm -rf dist/ | |
- run: | | |
npm ci | |
- run: | | |
npm run all | |
- uses: ./ | |
id: fail-ref-workflow-dispatch | |
name: "Dispatch Workflow using workflow_dispatch Method, to a Non-existent Branch" | |
continue-on-error: true | |
with: | |
dispatch-method: "workflow_dispatch" | |
repo: "${{ github.event.repository.name }}" | |
owner: "${{ github.repository_owner }}" | |
ref: "non-existent-branch/${{ github.run_id }}" # This branch cannot realistically exist | |
workflow: "${{ env.INTEGRATION_TEST_WORKFLOW_FILE }}" | |
token: "${{ secrets.GITHUB_TOKEN }}" | |
workflow-inputs: '{"placeholder": "placeholder"}' | |
- uses: ./ | |
id: fail-file-workflow-dispatch | |
name: "Dispatch Workflow using workflow_dispatch Method, to a Non-existent Workflow File" | |
continue-on-error: true | |
with: | |
dispatch-method: "workflow_dispatch" | |
repo: "${{ github.event.repository.name }}" | |
owner: "${{ github.repository_owner }}" | |
ref: "main" | |
workflow: "${{ github.run_id }}.yml" # This workflow file cannot realistically exist | |
token: "${{ secrets.GITHUB_TOKEN }}" | |
workflow-inputs: '{"placeholder": "placeholder"}' | |
- uses: ./ | |
id: fail-inputs-workflow-dispatch | |
name: "Dispatch Workflow using workflow_dispatch Method, with an unsupported workflow inputs" | |
continue-on-error: true | |
with: | |
dispatch-method: "workflow_dispatch" | |
repo: "${{ github.event.repository.name }}" | |
owner: "${{ github.repository_owner }}" | |
ref: "main" | |
workflow: "${{ env.INTEGRATION_TEST_WORKFLOW_FILE }}" | |
token: "${{ secrets.GITHUB_TOKEN }}" | |
workflow-inputs: '{"placeholder": 0}' # 0 is not a string type | |
- id: verify-fail-workflow-dispatch | |
name: "Verify Action Outputs for worflow-dispatch" | |
shell: bash | |
run: | | |
set -euo pipefail | |
if [[ "${{ steps.fail-ref-workflow-dispatch.outcome }}" != "failure" ]]; then | |
>&2 echo "🔴 fail-ref-workflow-dispatch step was expected to fail"; exit 1 | |
fi | |
if [[ "${{ steps.fail-file-workflow-dispatch.outcome }}" != "failure" ]]; then | |
>&2 echo "🔴 fail-file-workflow-dispatch step was expected to fail"; exit 1 | |
fi | |
if [[ "${{ steps.fail-inputs-workflow-dispatch.outcome }}" != "failure" ]]; then | |
>&2 echo "🔴 fail-inputs-workflow-dispatch step was expected to fail"; exit 1 | |
fi | |
- uses: ./ | |
id: workflow-dispatch | |
name: "Dispatch Using workflow_dispatch Method" | |
with: | |
dispatch-method: "workflow_dispatch" | |
repo: "${{ github.event.repository.name }}" | |
owner: "${{ github.repository_owner }}" | |
ref: "refs/heads/main" | |
workflow: "${{ env.INTEGRATION_TEST_WORKFLOW_FILE }}" | |
token: "${{ secrets.GITHUB_TOKEN }}" | |
workflow-inputs: | | |
{ | |
"string-type": "placeholder", | |
"number-type": "1", | |
"boolean-type": "true" | |
} | |
- uses: ./ | |
id: repository-dispatch-custom-backoff | |
name: "Dispatch Using repositroy_dispatch Method and custom exponential backoff parameters" | |
with: | |
dispatch-method: "repository_dispatch" | |
event-type: "repository-dispatch" | |
repo: "${{ github.event.repository.name }}" | |
owner: "${{ github.repository_owner }}" | |
token: "${{ secrets.GITHUB_TOKEN }}" | |
workflow-inputs: | | |
{ | |
"string-type": "placeholder", | |
"nested": { | |
"number-type": 1, | |
"boolean-type": true | |
} | |
} | |
starting-delay-ms: 150 | |
max-attempts: 3 | |
time-multiple: 1.5 | |
- uses: ./ | |
id: wait-repository-dispatch | |
name: "Dispatch Using repository_dispatch Method And Wait For Run-ID" | |
with: | |
dispatch-method: "repository_dispatch" | |
event-type: "repository-dispatch" | |
repo: "${{ github.event.repository.name }}" | |
owner: "${{ github.repository_owner }}" | |
token: "${{ secrets.GITHUB_TOKEN }}" | |
workflow-inputs: | | |
{ | |
"string-type": "placeholder", | |
"nested": { | |
"number-type": 1, | |
"boolean-type": true | |
} | |
} | |
discover: true | |
- id: verify-repository-dispatch-outcome | |
name: Await Run ID ${{ steps.wait-repository-dispatch.outputs.run-id }} | |
uses: codex-/await-remote-run@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
repo: ${{ github.event.repository.name }} | |
owner: ${{ github.repository_owner }} | |
run_id: ${{ steps.wait-repository-dispatch.outputs.run-id }} | |
- id: verify-repository-dispatch-outputs | |
name: "Verify Action Outputs for repository-dispatch" | |
shell: bash | |
run: | | |
set -euo pipefail | |
# wait-repository-dispatch | |
if [[ -z "${{ steps.wait-repository-dispatch.outputs.run-id }}" ]]; then | |
>&2 echo "🔴 wait-repository-dispatch step should output 'run-id'"; exit 1 | |
fi | |
if [[ -z "${{ steps.wait-repository-dispatch.outputs.run-url }}" ]]; then | |
>&2 echo "🔴 wait-repository-dispatch step should output 'run-url'"; exit 1 | |
fi |