Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions .github/workflows/queue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ on:
types: [opened, synchronize, reopened, edited]
merge_group:
types: [checks_requested]
# Reports the skipped context on a branch's head without a pull_request
# event. A PR whose test merge commit predates this workflow gets no
# pull_request run from it (GitHub runs PR workflows from that commit), so
# `gh workflow run queue.yml --ref <branch>` gives it the context.
# Reports the skipped context on a PR's head without a pull_request event.
# A PR whose test merge commit predates this workflow gets no pull_request
# run from it (GitHub runs PR workflows from that commit, and a dispatch reads
# the workflow from the ref it runs on), so
# `gh workflow run queue.yml -f sha=<head>` on main reports it there.
workflow_dispatch:
inputs:
sha:
description: The PR head commit to report the skipped Queue context on.
required: true

permissions:
contents: read
Expand Down Expand Up @@ -74,3 +79,23 @@ jobs:
path: target/cargo-timings/cargo-timing-*.html
if-no-files-found: ignore
retention-days: 14

# The merge queue still builds every group with the job above; this only
# satisfies the PR-side requirement, as a pull_request run's skipped job does.
report:
name: Report Queue
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
checks: write
steps:
- name: Report the skipped Queue context
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
SHA: ${{ inputs.sha }}
run: |
[[ "$SHA" =~ ^[0-9a-f]{40}$ ]] || { echo "::error::sha must be a full commit SHA" >&2; exit 1; }
gh api "repos/$REPO/check-runs" -f name=Queue -f head_sha="$SHA" -f status=completed -f conclusion=skipped \
-f 'output[title]=Queue' -f 'output[summary]=Skipped on the pull request; the merge queue builds the group.' --silent
7 changes: 5 additions & 2 deletions sh/gh/queue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ assert.equal(await Bun.file(".github/workflows/land.yml").exists(), false, "no w
// host's runner, read-only and without secrets.
const queue = await workflow("queue");
assert.deepEqual(queue.on.merge_group, { types: ["checks_requested"] });
// A dispatch only reports the skipped context on a branch head.
assert.ok("workflow_dispatch" in queue.on);
// A dispatch only reports the skipped context on a PR head, with nothing but `checks: write`.
assert.ok(queue.on.workflow_dispatch.inputs.sha.required);
assert.equal(queue.jobs.report.if, "github.event_name == 'workflow_dispatch'");
assert.deepEqual(queue.jobs.report.permissions, { checks: "write" });
assert.equal(queue.jobs.report.steps.length, 1, "the report job checks nothing out and runs no code from a PR");
assert.deepEqual(queue.on.pull_request.branches, ["main"]);
assert.ok(queue.on.pull_request.types.includes("edited"), "retargeting to main must report the context");
assert.equal(queue.on.pull_request.paths, undefined, "the required context must always report");
Expand Down