Skip to content
Open
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
12 changes: 5 additions & 7 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
name: Check

# Runs after each push to main, outside pull requests. The merge queue already
# runs `just check`, `just test`, and the flake check on the host's runner; this
# repeats them on a hosted one and adds the installed lifecycle on Linux and
# macOS. A newer push cancels an older run, even one in progress, so runs
# coalesce.
on:
push:
branches: [main]
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
workflow_dispatch:

permissions:
Expand All @@ -16,7 +19,6 @@ concurrency:

jobs:
check:
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
Expand All @@ -43,12 +45,8 @@ jobs:

lifecycle:
name: lifecycle (${{ matrix.runner }})
if: github.event_name != 'pull_request'
strategy:
fail-fast: false
# Hosted macOS runners can queue past the timeout, which then reports a job
# that never ran as failed. Main checks the flake's macOS build,
# and tags check the released binaries.
matrix:
runner: [ubuntu-latest, macos-15]
runs-on: ${{ matrix.runner }}
Expand Down
18 changes: 3 additions & 15 deletions .github/workflows/gate-macos.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,15 @@
name: Gate (macOS)

# The gate owns commands through a process group on macOS, which Check's Linux
# suite does not reach. Pull requests that change the gate run its tests here,
# and Release calls this before publishing. It is not a required check, so a
# slow hosted macOS queue holds back no merge.
# The gate owns commands through a process group on macOS, which the merge
# queue's Linux suite does not reach. Release calls this before publishing a
# release that changes what ships; dispatch it to check a branch.
on:
pull_request:
paths:
- .github/workflows/gate-macos.yml
- src/cli/gate.ts
- src/cli/supervise.ts
- src/cli/interrupt.ts
- test/gate.test.ts
workflow_call:
workflow_dispatch:

permissions:
contents: read

concurrency:
group: gate-macos-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
gate:
name: gate (${{ matrix.runner }})
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/queue-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Queue (pull request)

# Reports the `Queue` context that main's ruleset requires on each pull request
# to main, as skipped: GitHub admits a PR to the merge queue only once its
# required checks pass on the PR itself, a skipped job satisfies them, and
# queue.yml builds the merge group. This is a PR's only check, so `quest wait`
# waits on nothing that does not gate landing. Its own file, apart from
# queue.yml, keeps the merge group's jobs from reporting as skipped checks too.
on:
pull_request:
branches: [main]
# `edited` covers a PR retargeted to main, which needs the context too.
types: [opened, synchronize, reopened, edited]
# Reports the 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-pr.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

jobs:
queue:
name: Queue
# Skips, and so reports, on a pull request; runs only for a dispatch.
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
58 changes: 8 additions & 50 deletions .github/workflows/queue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ name: Queue
# queue drops a PR, moq-dev/quest's queue watcher on the host runs the land
# fixer and re-enqueues it at the back of the queue.
#
# `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.
# `main`'s ruleset requires this workflow's `Queue` context. On a pull request,
# queue-pr.yml reports it as skipped; only the merge group build runs code, and
# only a maintainer's pick enters the queue.
#
# A repository without GitHub's merge queue, such as a private one on GitHub
# Team, lands through the watcher's own queue instead. Its base keeps requiring
Expand All @@ -25,33 +23,15 @@ name: Queue
# checks besides `quest land`, reported on that commit, decide whether the PR
# lands, so the required job reports the build's result there.
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
pull-requests: read

# No concurrency group. A pull request's `Queue` job waits on `build` before it
# skips, so cancelling the run then, as a second event for the PR would,
# reports `Queue` cancelled and fails the requirement; even a group without
# cancel-in-progress cancels a pending run. Each merge group has its own ref, so
# its run never had another to replace, and a repeated dispatch only reports the
# same skipped context twice.
# No concurrency group: each merge group has its own ref, so its run never has
# another to replace, and cancelling one would report `Queue` cancelled.

jobs:
# The build runs in queue-build.yml so its runner group can admit that
Expand All @@ -60,42 +40,20 @@ jobs:
# queue-build.yml runs only after it lands.
build:
name: Queue build
if: github.event_name == 'merge_group'
uses: moq-dev/quest/.github/workflows/queue-build.yml@main

# The required context. A reusable workflow's jobs report as
# `Queue build / Build`, so this job reports the build's result under the
# name main's ruleset requires. It skips with the build on pull requests, and
# runs even when the build fails or is cancelled, since a skipped context
# would pass the group.
# name main's ruleset requires. It runs even when the build fails or is
# cancelled, since a skipped context would pass the group.
queue:
name: Queue
needs: build
if: always() && github.event_name == 'merge_group'
if: always()
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Require the build to pass
env:
RESULT: ${{ needs.build.result }}
run: '[[ "$RESULT" == success ]] || { echo "::error::the queue build ended $RESULT" >&2; exit 1; }'

# The merge queue still builds every group with the jobs 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
44 changes: 12 additions & 32 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ name: Release
# draft release and publishes it, which creates the tag, so no tag exists
# without its complete release. A failed or cancelled run needs no recovery:
# the next run sees the same unreleased range and replaces any draft it left.
# Pull requests that change what ships, and manual runs on other branches, only
# build and check. scripts/release-plan.sh holds both decisions.
# Pull requests don't run this, so the daily run is where binaries are first
# built and checked; manual runs on other branches only build and check.
# scripts/release-plan.sh holds the decision.
on:
pull_request:
schedule:
- cron: "17 6 * * *"
workflow_dispatch:
Expand All @@ -23,7 +23,7 @@ permissions:
# one replaces loses nothing, since the newer one sees its range too.
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
cancel-in-progress: false

jobs:
plan:
Expand All @@ -45,8 +45,6 @@ jobs:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
EVENT: ${{ github.event_name }}
BASE: ${{ github.event.pull_request.base.sha }}
HEAD: ${{ github.event.pull_request.head.sha }}
run: |
# The latest published release; drafts and prereleases don't count.
if ! released=$(gh api "repos/$GH_REPO/releases/latest" --jq .tag_name 2>"$RUNNER_TEMP/latest"); then
Expand All @@ -58,10 +56,7 @@ jobs:
version=$(sed -n 's/^version=//p' <<<"$plan")
ships=$(sed -n 's/^release=//p' <<<"$plan")
release=false
if [[ $EVENT == pull_request ]]; then
build=false
if git diff --name-only --no-renames "$BASE...$HEAD" | bash scripts/release-plan.sh ships; then build=true; fi
elif [[ $GITHUB_REF == refs/heads/main ]]; then
if [[ $GITHUB_REF == refs/heads/main ]]; then
release=$ships
build=$ships
if [[ $EVENT == workflow_dispatch ]]; then build=true; fi
Expand Down Expand Up @@ -135,9 +130,13 @@ jobs:
runner: ubuntu-22.04-arm
- target: x86_64-unknown-linux-gnu
runner: ubuntu-22.04
- target: aarch64-apple-darwin
runner: macos-15
- target: x86_64-apple-darwin
runner: macos-15-intel
runs-on: ${{ matrix.runner }}
timeout-minutes: 10
steps: &check-steps
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
Expand Down Expand Up @@ -171,30 +170,11 @@ jobs:
shell: bash
run: bash scripts/gate-check.sh "$RUNNER_TEMP/quest"

# Hosted macOS runners can queue past the timeout, which then reports a job
# that never ran as failed. Pull requests skip these; releases, which publish
# the artifacts, and manual runs still check them. Check covers macOS on main.
macos:
name: check (${{ matrix.target }})
if: github.event_name != 'pull_request'
needs: [plan, build]
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-apple-darwin
runner: macos-15
- target: x86_64-apple-darwin
runner: macos-15-intel
runs-on: ${{ matrix.runner }}
timeout-minutes: 10
steps: *check-steps

# Check's suite runs on Linux and Windows only, so the gate's macOS owner is
# tested natively before a release publishes.
gate-macos:
needs: plan
if: github.event_name != 'pull_request' && needs.plan.outputs.build == 'true'
if: needs.plan.outputs.build == 'true'
uses: ./.github/workflows/gate-macos.yml

windows:
Expand Down Expand Up @@ -230,7 +210,7 @@ jobs:
run: ./scripts/install-check.ps1 -Method archive -Target $env:TARGET -Tag $env:TAG -ReleaseDirectory (Resolve-Path release).Path

publish:
needs: [plan, check, macos, gate-macos, windows]
needs: [plan, check, gate-macos, windows]
if: needs.plan.outputs.release == 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
Expand Down
5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ a day's merges become one release and a day with none cuts nothing. A push to
`main` cuts no release; an urgent fix ships early once it merges, with
`gh workflow run release.yml --ref main`. `scripts/release-plan.sh` judges the
range: everything the binaries and the flake package build from, every file
Release publishes, and the workflows that build and check them. Its pull
request runs use the same predicate to decide whether to build. The next version is greater than every
Release publishes, and the workflows that build and check them. Pull requests
don't run Release, and a failed run on `main` only emails, as GitHub does by
default. The next version is greater than every
`vX.Y.Z` tag: a minor bump (a major one from 1.0) when a commit subject in the
range has `!` before its colon, a patch bump otherwise.

Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,10 @@ the way, or work on the branch), 2 for invalid arguments, and 1 for other
failures. On GitHub it
uses `GH_TOKEN`, `GITHUB_TOKEN`, or `gh auth token`.

Draft claims are placeholders. This repository reports skipped checks on PRs;
its `Queue` workflow runs the checks when a reviewed head enters GitHub's merge
queue. Platform verification also runs after pushes to `main`.
Draft claims are placeholders. This repository's only PR check is the required
`Queue`, skipped on the PR; its `Queue` workflow runs the checks when a reviewed
head enters GitHub's merge queue. Platform verification runs after pushes to
`main` and daily.

## Check a quest's PR

Expand Down
20 changes: 0 additions & 20 deletions quest/m0/required-checks.md

This file was deleted.

3 changes: 1 addition & 2 deletions scripts/release-plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ usage() {
# What a release ships or is built and checked by: everything the binaries and
# the flake package build from (`assets/` is bundled into the binary), every
# file Release publishes, such as `scripts/installer.sh`, and the workflows that
# build, check, and publish it. Release's pull request runs and its releases on
# `main` both decide with this one predicate.
# build, check, and publish it.
ships() {
grep -E '^(src/|assets/|nix/|scripts/|package\.json$|bun\.lock$|bunfig\.toml$|tsconfig\.json$|flake\.(nix|lock)$|\.github/workflows/(release|gate-macos|install-check)\.yml$)' >/dev/null
}
Expand Down