mirror of
https://github.com/servo/servo.git
synced 2025-09-07 21:48:21 +01:00
ci: Move runner-timeout to composite action (#38503)
We are hitting the limit of 20 workflow references in servo. To help mitigate this somewhat, we migrate the timeout job to a composite action, which should be able to support our needs just as well. Testing: [try run of this PR](https://github.com/servo/servo/actions/runs/16783916103/job/47529580725). [try run with unconditional cancel](https://github.com/servo/servo/actions/runs/16784074213/job/47530099654). This reduces our workflow count by one, slightly helping to address #36143 Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
This commit is contained in:
parent
edf80576d5
commit
c055e8b456
5 changed files with 73 additions and 54 deletions
37
.github/actions/runner-timeout/action.yml
vendored
Normal file
37
.github/actions/runner-timeout/action.yml
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
# In the unlikely event a self-hosted runner was selected and reserved but it
|
||||
# goes down before the workload starts, cancel the workflow run.
|
||||
name: Detect self-hosted runner assigment timeout
|
||||
description: "Cancel the workflow run if a self-hosted runner was selected, but the job failed to start"
|
||||
inputs:
|
||||
unique-id:
|
||||
required: true
|
||||
description: "Unique ID of the runner"
|
||||
github_token:
|
||||
required: true
|
||||
description: "Must be able to do github API calls and cancel jobs."
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Wait a bit
|
||||
shell: bash
|
||||
run: sleep 120
|
||||
|
||||
- name: Cancel if workload job is still queued
|
||||
shell: bash
|
||||
run: |
|
||||
run_url=/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||
export GH_TOKEN=${{ inputs.github_token }}
|
||||
|
||||
if [ "$(gh api "$run_url/jobs" \
|
||||
| jq -er --arg id '${{ inputs.unique-id }}' \
|
||||
'.jobs[] | select(.name | contains("[" + $id + "]")) | .status'
|
||||
)" = queued ]; then
|
||||
echo 'Timeout waiting for runner assignment!'
|
||||
echo 'Hint: does this repo have permission to access the runner group?'
|
||||
echo 'Hint: https://github.com/organizations/servo/settings/actions/runner-groups'
|
||||
echo
|
||||
echo 'Cancelling workflow run'
|
||||
gh api "$run_url/cancel" --method POST
|
||||
exit 1
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue