diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 49a97165..7f7c911b 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -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: @@ -16,7 +19,6 @@ concurrency: jobs: check: - if: github.event_name != 'pull_request' runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -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 }} diff --git a/.github/workflows/gate-macos.yml b/.github/workflows/gate-macos.yml index c1d907bf..d512a266 100644 --- a/.github/workflows/gate-macos.yml +++ b/.github/workflows/gate-macos.yml @@ -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 }}) diff --git a/.github/workflows/queue-pr.yml b/.github/workflows/queue-pr.yml new file mode 100644 index 00000000..17e779e1 --- /dev/null +++ b/.github/workflows/queue-pr.yml @@ -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=` 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 diff --git a/.github/workflows/queue.yml b/.github/workflows/queue.yml index b718570d..8946b775 100644 --- a/.github/workflows/queue.yml +++ b/.github/workflows/queue.yml @@ -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 @@ -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=` 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 @@ -60,18 +40,16 @@ 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: @@ -79,23 +57,3 @@ jobs: 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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cec258a3..3f9ddefe 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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: @@ -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: @@ -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 @@ -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 @@ -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 @@ -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: @@ -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 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f1bbcc4a..616e1a71 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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. diff --git a/README.md b/README.md index fb9d1e01..c094d67d 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/quest/m0/required-checks.md b/quest/m0/required-checks.md deleted file mode 100644 index 699a64b7..00000000 --- a/quest/m0/required-checks.md +++ /dev/null @@ -1,20 +0,0 @@ -# [S] Every PR check is required - -## Goal - -Every check that runs on a moq-dev/quest pull request is one `main`'s ruleset requires. Each job that should not gate a PR moves to the merge queue, the nightly run, or the release run instead. A PR then has no optional checks, so `quest wait`, which wakes once every check has finished, waits only on what gates landing, and no agent stalls on a slow check that decides nothing. - -Non-goal: other repositories, which kixel-ai/dotfiles' `repo-settings check` covers. - -## Plan - -Decided 2026-11-22 (maintainer, while settling [moq-dev/quest#810](https://github.com/moq-dev/quest/pull/810)'s wait rule): "we MUST NOT HAVE OPTIONAL CHECKS. Every PR check MUST BE REQUIRED or moved to an async run (ex. nightly)". On that basis #810 keeps `quest wait` waking on every check (rejected: a wake on required checks only), since the two are the same once no optional checks exist. - -At a88c65b, the ruleset requires only `Queue`. On a PR, `check.yml` runs `check` and `lifecycle`, `release.yml` runs `plan`, `build`, and the four-target `check` matrix among others, and `gate-macos.yml` runs on gate paths. All of them are optional. - -Recommended: - -- The ruleset comes from kixel-ai/dotfiles' `bin/repo-settings`, so prefer keeping `Queue` as the only required context: move each PR job into the merge queue's build or onto `release.yml`'s nightly schedule, by the rule in `quest context` that the merge gate holds only fast, high-signal checks. Requiring a new context means changing the standard there, not in this repository. -- A workflow filtered by `paths` never reports when its paths are untouched, so it cannot be required as is: move `gate-macos.yml` to the nightly run, or into the queue with a job-level condition that reports success. -- Each run moved off pull requests, and the nightly `windows.yml` already there, files what it finds as work, as `quest context` asks: today a failed scheduled run only emails the account that last edited its cron. -- Say in the PR how much the queue's run time changes, and which checks a PR author loses before the queue. diff --git a/scripts/release-plan.sh b/scripts/release-plan.sh index 4a32a925..d87749ac 100644 --- a/scripts/release-plan.sh +++ b/scripts/release-plan.sh @@ -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 }