Skip to content

Commit 8d9adf0

Browse files
committed
ci: the single-leg dispatch waits for room under the CI ceiling, yielding to main checks (AST-030 FR16, DEC-16)
1 parent 8468726 commit 8d9adf0

2 files changed

Lines changed: 82 additions & 7 deletions

File tree

‎.github/scripts/a11y-contract-shard-workflow.test.mjs‎

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ const read = file => yaml.parse(fs.readFileSync(path.join(root, file), 'utf8'));
2121
const workflow = read('.github/workflows/a11y-contract-shard.yml');
2222
const ci = read('.github/workflows/ci.yml');
2323
const job = workflow.jobs.shard;
24-
const step = name => job.steps.find(item => item.name === name);
24+
const room = workflow.jobs.room;
25+
const step = name =>
26+
[...room.steps, ...job.steps].find(item => item.name === name);
2527
const releaseLeg = ci.jobs['a11y-contracts-shard'];
2628
const releaseStep = releaseLeg.steps.find(
2729
item => item.name === 'Run accessibility spec-test contracts',
@@ -37,10 +39,43 @@ describe('the single contract-leg dispatch', () => {
3739
]);
3840
expect(workflow.permissions).toEqual({});
3941
expect(job.permissions).toEqual({contents: 'read'});
42+
expect(room.permissions).toEqual({
43+
actions: 'read',
44+
contents: 'read',
45+
'pull-requests': 'read',
46+
});
47+
});
48+
49+
it('waits for room under the CI ceiling as a pull-request run does, so a main check or release re-check fits first', () => {
50+
expect(job.needs).toEqual(['room']);
51+
// The inputs are checked before the wait.
52+
expect(room.steps[0].name).toBe('Check the inputs');
53+
const wait = step('Wait for room under the CI ceiling');
54+
expect(wait.uses).toBe('./.ci-admission/.github/actions/ci-admission');
55+
expect(wait.with).toEqual({
56+
phase: 'whole',
57+
peak: 2,
58+
main: 'false',
59+
'max-wait-minutes': 120,
60+
'max-looks': 30,
61+
});
62+
// The admission action comes from the dispatched ref (main), not the
63+
// commit under test.
64+
expect(step('Check out the admission action').with).toEqual({
65+
'sparse-checkout':
66+
'.github/actions/ci-admission\n.github/scripts/lib\nscripts/lib\n',
67+
path: '.ci-admission',
68+
'persist-credentials': false,
69+
});
70+
expect(step('Stop when CI is full').if).toBe(
71+
"steps.room.outputs.full == 'true'",
72+
);
73+
// A standard runner: the wait outlasts a slim job's fifteen minutes.
74+
expect(room['runs-on']).toBe('ubuntu-latest');
4075
});
4176

4277
it('never puts an input into a script: each reaches it through the environment', () => {
43-
for (const item of job.steps.filter(entry => entry.run))
78+
for (const item of [...room.steps, ...job.steps].filter(entry => entry.run))
4479
expect(item.run, item.name).not.toContain('${{');
4580
});
4681

‎.github/workflows/a11y-contract-shard.yml‎

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@ concurrency:
3333
cancel-in-progress: false
3434

3535
jobs:
36-
shard:
37-
name: Accessibility spec-test contracts (${{ inputs.a11y-shard }}/6) at ${{ inputs.expected-head }}
38-
# A free standard runner: the same four vCPUs and 16 GB as the release
39-
# check's paid 4-core-ubuntu pool.
36+
# Waits for room under the CI ceiling like a pull-request run, so it yields
37+
# to a waiting main check or release re-check (spec:AST-030 FR16, DEC-16).
38+
room:
4039
runs-on: ubuntu-latest
41-
timeout-minutes: 60
40+
timeout-minutes: 130
4241
permissions:
42+
actions: read
4343
contents: read
44+
pull-requests: read
4445
steps:
4546
- name: Check the inputs
4647
env:
@@ -53,6 +54,45 @@ jobs:
5354
[[ "$SHARD" =~ ^[1-6]$ ]] || { echo "::error::a11y-shard must be 1 to 6, not '$SHARD'."; exit 1; }
5455
[[ "$REPEAT" =~ ^([1-9]|10)$ ]] || { echo "::error::repeat must be 1 to 10, not '$REPEAT'."; exit 1; }
5556
57+
- name: Check out the admission action
58+
uses: actions/checkout@v7
59+
timeout-minutes: 5
60+
with:
61+
sparse-checkout: |
62+
.github/actions/ci-admission
63+
.github/scripts/lib
64+
scripts/lib
65+
path: .ci-admission
66+
persist-credentials: false
67+
68+
- name: Wait for room under the CI ceiling
69+
id: room
70+
uses: ./.ci-admission/.github/actions/ci-admission
71+
continue-on-error: true
72+
timeout-minutes: 125
73+
with:
74+
phase: whole
75+
peak: 2
76+
main: 'false'
77+
max-wait-minutes: 120
78+
max-looks: 30
79+
80+
- name: Stop when CI is full
81+
if: steps.room.outputs.full == 'true'
82+
run: |
83+
echo "::error title=CI is full::CI is full: dispatch again later. The run found no room under the CI ceiling."
84+
exit 1
85+
86+
shard:
87+
name: Accessibility spec-test contracts (${{ inputs.a11y-shard }}/6) at ${{ inputs.expected-head }}
88+
needs: [room]
89+
# A free standard runner: the same four vCPUs and 16 GB as the release
90+
# check's paid 4-core-ubuntu pool.
91+
runs-on: ubuntu-latest
92+
timeout-minutes: 60
93+
permissions:
94+
contents: read
95+
steps:
5696
- name: Checkout
5797
uses: actions/checkout@v7
5898
timeout-minutes: 5

0 commit comments

Comments
 (0)