mirror of
https://github.com/servo/servo
synced 2026-04-25 17:15:48 +02:00
Compare commits
3 Commits
f9cfd05af8
...
ci-tool
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
952bd2b199 | ||
|
|
dd1d3a3a32 | ||
|
|
a599b9db42 |
45
.github/workflows/linux.yml
vendored
45
.github/workflows/linux.yml
vendored
@@ -99,23 +99,40 @@ jobs:
|
||||
# Runs the underlying job (“workload”) on a self-hosted runner if available,
|
||||
# with the help of a `runner-select` job and a `runner-timeout` job.
|
||||
runner-select:
|
||||
uses: ./.github/workflows/self-hosted-runner-select.yml
|
||||
secrets: inherit
|
||||
with:
|
||||
# Before updating the GH action runner image for the nightly job, ensure
|
||||
# that the system has a glibc version that is compatible with the one
|
||||
# used by the wpt.fyi runners.
|
||||
github-hosted-runner-label: ubuntu-22.04
|
||||
self-hosted-image-name: servo-ubuntu2204
|
||||
force-github-hosted-runner: ${{ inputs.upload || inputs.force-github-hosted-runner }}
|
||||
outputs:
|
||||
unique-id: ${{ steps.select.outputs.unique_id }}
|
||||
selected-runner-label: ${{ steps.select.outputs.selected_runner_label }}
|
||||
is-self-hosted: ${{ steps.select.outputs.is_self_hosted }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: delan/servo-ci@main
|
||||
- name: Select and reserve best available runner
|
||||
id: select
|
||||
# Before updating the GH action runner image for the nightly job, ensure
|
||||
# that the system has a glibc version that is compatible with the one
|
||||
# used by the wpt.fyi runners.
|
||||
run: |
|
||||
ci runner select \
|
||||
--github-repository '${{ github.repository }}' \
|
||||
--github-run-id '${{ github.run_id }}' \
|
||||
--monitor-api-token '${{ secrets.SERVO_CI_MONITOR_API_TOKEN }}' \
|
||||
--github-hosted-runner-label 'ubuntu-22.04' \
|
||||
--self-hosted-image-name 'servo-ubuntu2204' \
|
||||
--force-github-hosted-runner '${{ inputs.upload || inputs.force-github-hosted-runner }}'
|
||||
runner-timeout:
|
||||
needs:
|
||||
- runner-select
|
||||
uses: ./.github/workflows/self-hosted-runner-timeout.yml
|
||||
secrets: inherit
|
||||
with:
|
||||
unique-id: ${{ needs.runner-select.outputs.unique-id }}
|
||||
is-self-hosted: ${{ fromJSON(needs.runner-select.outputs.is-self-hosted) }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: delan/servo-ci@main
|
||||
- name: Cancel if workload job is still queued
|
||||
run: |
|
||||
ci runner timeout \
|
||||
--wait-time 120 \
|
||||
--unique-id '${{ needs.runner-select.outputs.unique-id }}' \
|
||||
--github-repository '${{ github.repository }}' \
|
||||
--github-run-id '${{ github.run_id }}' \
|
||||
--github-token '${{ secrets.GITHUB_TOKEN }}'
|
||||
|
||||
build:
|
||||
needs:
|
||||
|
||||
39
.github/workflows/mac.yml
vendored
39
.github/workflows/mac.yml
vendored
@@ -85,20 +85,37 @@ jobs:
|
||||
# Runs the underlying job (“workload”) on a self-hosted runner if available,
|
||||
# with the help of a `runner-select` job and a `runner-timeout` job.
|
||||
runner-select:
|
||||
uses: ./.github/workflows/self-hosted-runner-select.yml
|
||||
secrets: inherit
|
||||
with:
|
||||
github-hosted-runner-label: macos-13
|
||||
self-hosted-image-name: servo-macos13
|
||||
force-github-hosted-runner: ${{ inputs.force-github-hosted-runner }}
|
||||
outputs:
|
||||
unique-id: ${{ steps.select.outputs.unique_id }}
|
||||
selected-runner-label: ${{ steps.select.outputs.selected_runner_label }}
|
||||
is-self-hosted: ${{ steps.select.outputs.is_self_hosted }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: delan/servo-ci@main
|
||||
- name: Select and reserve best available runner
|
||||
id: select
|
||||
run: |
|
||||
ci runner select \
|
||||
--github-repository '${{ github.repository }}' \
|
||||
--github-run-id '${{ github.run_id }}' \
|
||||
--monitor-api-token '${{ secrets.SERVO_CI_MONITOR_API_TOKEN }}' \
|
||||
--github-hosted-runner-label 'macos-13' \
|
||||
--self-hosted-image-name 'servo-macos13' \
|
||||
--force-github-hosted-runner '${{ inputs.force-github-hosted-runner }}'
|
||||
runner-timeout:
|
||||
needs:
|
||||
- runner-select
|
||||
uses: ./.github/workflows/self-hosted-runner-timeout.yml
|
||||
secrets: inherit
|
||||
with:
|
||||
unique-id: ${{ needs.runner-select.outputs.unique-id }}
|
||||
is-self-hosted: ${{ fromJSON(needs.runner-select.outputs.is-self-hosted) }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: delan/servo-ci@main
|
||||
- name: Cancel if workload job is still queued
|
||||
run: |
|
||||
ci runner timeout \
|
||||
--wait-time 120 \
|
||||
--unique-id '${{ needs.runner-select.outputs.unique-id }}' \
|
||||
--github-repository '${{ github.repository }}' \
|
||||
--github-run-id '${{ github.run_id }}' \
|
||||
--github-token '${{ secrets.GITHUB_TOKEN }}'
|
||||
|
||||
build:
|
||||
needs:
|
||||
|
||||
100
.github/workflows/self-hosted-runner-select.yml
vendored
100
.github/workflows/self-hosted-runner-select.yml
vendored
@@ -1,100 +0,0 @@
|
||||
name: Select Self-hosted Runner
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
github-hosted-runner-label:
|
||||
required: true
|
||||
type: string
|
||||
self-hosted-image-name:
|
||||
required: true
|
||||
type: string
|
||||
self-hosted-runner-scope:
|
||||
required: false
|
||||
type: string
|
||||
default: /orgs/${{ github.repository_owner }}/actions/runners
|
||||
force-github-hosted-runner:
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
outputs:
|
||||
unique-id:
|
||||
value: ${{ jobs.runner-select.outputs.unique-id }}
|
||||
selected-runner-label:
|
||||
value: ${{ jobs.runner-select.outputs.selected-runner-label }}
|
||||
is-self-hosted:
|
||||
value: ${{ jobs.runner-select.outputs.is-self-hosted }}
|
||||
|
||||
jobs:
|
||||
# Selects a self-hosted runner if available, or else a GitHub-hosted runner.
|
||||
# We generate a unique id for the workload, then ask our monitor API to
|
||||
# reserve a self-hosted runner for us.
|
||||
runner-select:
|
||||
name: Select Runner
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
unique-id: ${{ steps.select.outputs.unique_id }}
|
||||
selected-runner-label: ${{ steps.select.outputs.selected_runner_label }}
|
||||
is-self-hosted: ${{ steps.select.outputs.is_self_hosted }}
|
||||
steps:
|
||||
- name: Select and reserve best available runner
|
||||
id: select
|
||||
run: |
|
||||
github_hosted_runner_label='${{ inputs.github-hosted-runner-label }}'
|
||||
self_hosted_image_name='${{ inputs.self-hosted-image-name }}'
|
||||
self_hosted_runner_scope='${{ inputs.self-hosted-runner-scope }}'
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
fall_back_to_github_hosted() {
|
||||
echo 'Falling back to GitHub-hosted runner'
|
||||
echo "selected_runner_label=$github_hosted_runner_label" | tee -a $GITHUB_OUTPUT
|
||||
echo 'is_self_hosted=false' | tee -a $GITHUB_OUTPUT
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Generate a unique id that allows the workload job to find the runner
|
||||
# we are reserving for it (via runner labels), and allows the timeout
|
||||
# job to find the workload job run (via the job’s friendly name), even
|
||||
# if there are multiple instances in the workflow call tree.
|
||||
unique_id=$(uuidgen)
|
||||
echo "unique_id=$unique_id" | tee -a $GITHUB_OUTPUT
|
||||
|
||||
# Disable self-hosted runners by creating a repository variable named
|
||||
# NO_SELF_HOSTED_RUNNERS with any non-empty value.
|
||||
# <https://github.com/servo/servo/settings/variables/actions>
|
||||
if [ -n '${{ vars.NO_SELF_HOSTED_RUNNERS }}' ]; then
|
||||
echo 'NO_SELF_HOSTED_RUNNERS is set!'
|
||||
fall_back_to_github_hosted
|
||||
fi
|
||||
|
||||
if [ '${{ inputs.force-github-hosted-runner }}' = true ]; then
|
||||
echo 'inputs.force-github-hosted-runner is set!'
|
||||
fall_back_to_github_hosted
|
||||
fi
|
||||
|
||||
for monitor_api_base_url in $(printf \%s\\n \
|
||||
https://ci0.servo.org \
|
||||
https://ci1.servo.org \
|
||||
https://ci2.servo.org \
|
||||
| shuf); do
|
||||
# Use the monitor API to reserve a runner. If we get an object with
|
||||
# runner details, we succeeded. If we get null, we failed.
|
||||
take_runner_url=$monitor_api_base_url/profile/$self_hosted_image_name/take\?unique_id=$unique_id\&qualified_repo=${{ github.repository }}\&run_id=${{ github.run_id }}
|
||||
result=$(mktemp)
|
||||
echo
|
||||
echo POST "$take_runner_url"
|
||||
if curl -sS --fail-with-body --connect-timeout 5 --max-time 30 -X POST "$take_runner_url" \
|
||||
-H 'Authorization: Bearer ${{ secrets.SERVO_CI_MONITOR_API_TOKEN }}' > $result \
|
||||
&& jq -e . $result > /dev/null; then
|
||||
echo
|
||||
echo "selected_runner_label=reserved-for:$unique_id" | tee -a $GITHUB_OUTPUT
|
||||
echo 'is_self_hosted=true' | tee -a $GITHUB_OUTPUT
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
||||
cat $result
|
||||
echo
|
||||
echo
|
||||
echo 'No self-hosted runners available!'
|
||||
fall_back_to_github_hosted
|
||||
39
.github/workflows/self-hosted-runner-timeout.yml
vendored
39
.github/workflows/self-hosted-runner-timeout.yml
vendored
@@ -1,39 +0,0 @@
|
||||
name: Detect Self-hosted Runner Timeout
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
unique-id:
|
||||
required: true
|
||||
type: string
|
||||
is-self-hosted:
|
||||
required: true
|
||||
type: boolean
|
||||
|
||||
jobs:
|
||||
# In the unlikely event a self-hosted runner was selected and reserved but it
|
||||
# goes down before the workload starts, cancel the workflow run.
|
||||
runner-timeout:
|
||||
if: ${{ inputs.is-self-hosted }}
|
||||
name: Detect Runner Timeout
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Wait a bit
|
||||
run: sleep 120
|
||||
|
||||
- name: Cancel if workload job is still queued
|
||||
run: |
|
||||
run_url=/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||
export GH_TOKEN=${{ secrets.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
|
||||
39
.github/workflows/windows.yml
vendored
39
.github/workflows/windows.yml
vendored
@@ -76,20 +76,37 @@ jobs:
|
||||
# Runs the underlying job (“workload”) on a self-hosted runner if available,
|
||||
# with the help of a `runner-select` job and a `runner-timeout` job.
|
||||
runner-select:
|
||||
uses: ./.github/workflows/self-hosted-runner-select.yml
|
||||
secrets: inherit
|
||||
with:
|
||||
github-hosted-runner-label: windows-2022
|
||||
self-hosted-image-name: servo-windows10
|
||||
force-github-hosted-runner: ${{ inputs.force-github-hosted-runner }}
|
||||
outputs:
|
||||
unique-id: ${{ steps.select.outputs.unique_id }}
|
||||
selected-runner-label: ${{ steps.select.outputs.selected_runner_label }}
|
||||
is-self-hosted: ${{ steps.select.outputs.is_self_hosted }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: delan/servo-ci@main
|
||||
- name: Select and reserve best available runner
|
||||
id: select
|
||||
run: |
|
||||
ci runner select \
|
||||
--github-repository '${{ github.repository }}' \
|
||||
--github-run-id '${{ github.run_id }}' \
|
||||
--monitor-api-token '${{ secrets.SERVO_CI_MONITOR_API_TOKEN }}' \
|
||||
--github-hosted-runner-label 'windows-2022' \
|
||||
--self-hosted-image-name 'servo-windows10' \
|
||||
--force-github-hosted-runner '${{ inputs.force-github-hosted-runner }}'
|
||||
runner-timeout:
|
||||
needs:
|
||||
- runner-select
|
||||
uses: ./.github/workflows/self-hosted-runner-timeout.yml
|
||||
secrets: inherit
|
||||
with:
|
||||
unique-id: ${{ needs.runner-select.outputs.unique-id }}
|
||||
is-self-hosted: ${{ fromJSON(needs.runner-select.outputs.is-self-hosted) }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: delan/servo-ci@main
|
||||
- name: Cancel if workload job is still queued
|
||||
run: |
|
||||
ci runner timeout \
|
||||
--wait-time 120 \
|
||||
--unique-id '${{ needs.runner-select.outputs.unique-id }}' \
|
||||
--github-repository '${{ github.repository }}' \
|
||||
--github-run-id '${{ github.run_id }}' \
|
||||
--github-token '${{ secrets.GITHUB_TOKEN }}'
|
||||
|
||||
build:
|
||||
needs:
|
||||
|
||||
Reference in New Issue
Block a user