Repository navigation
103 lines (94 loc) · 3.98 KB
/
Copy pathqueue.yml
File metadata and controls
103 lines (94 loc) · 3.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Queue
# GitHub's merge queue tests each picked PR on top of main, one at a time, on
# the host's self-hosted runner, and merges exactly the tree it tested. When the
# queue drops a PR, moq-dev/quest's queue watcher on the host runs the land
# fixer and re-enqueues it
# (https://github.com/moq-dev/moq/blob/17a81d6c64/quest/m0/ci/land.md).
#
# `main`'s ruleset requires this job's `Queue` context. GitHub admits a PR to
# the queue only once its required checks pass on the PR itself, so the job
# also runs, as skipped, on main pull requests; a skipped job satisfies the
# requirement. Only the merge group build runs code, and only a maintainer's
# pick enters the queue.
on:
pull_request:
branches: [main]
# `edited` covers a PR retargeted to main, which needs the context too.
types: [opened, synchronize, reopened, edited]
merge_group:
types: [checks_requested]
# 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
# Each group has its own ref, so a group never cancels another; a pull request's
# skipped runs replace their own. Dispatches all run on main, so each PR head's
# report has its own group too.
concurrency:
group: queue-${{ github.ref }}-${{ inputs.sha }}
cancel-in-progress: true
jobs:
queue:
name: Queue
if: github.event_name == 'merge_group'
runs-on: [self-hosted, moq-queue]
# A merge group is one PR at build concurrency 1; `just ci` takes about 5-15
# minutes. Backstop a hang instead of holding the queue.
timeout-minutes: 90
env:
# The diff the dispatcher selects from: the group's base, as the host gate
# passed its own BASE.
BASE: ${{ github.event.merge_group.base_sha }}
# A failure goes to the fixer whatever else fails, so stop at the first
# failed module (moq-dev/moq#7466).
CHECK_FAIL_FAST: "1"
NEXTEST_TEST_THREADS: 24
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# Full history for the dispatcher's base comparison.
fetch-depth: 0
- uses: ./.github/actions/just
# Local storage only: a self-hosted runner gets no remote cache key.
- name: Rust cache
uses: ./.github/actions/rust-cache
- name: Check
run: |
rm -rf target/cargo-timings
nix develop --command just ci "$BASE"
- name: Upload build timings
if: ${{ !cancelled() }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: cargo-timings
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