From 3b1110aa57f3d29eda284e162eca918267807482 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 15 Oct 2026 15:44:53 +0000 Subject: [PATCH 01/16] chore(deps): update dependency vite to v8.3.4 --- pnpm-lock.yaml | 48 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bc18fa76ba1..96dd32fc560 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -237,7 +237,7 @@ importers: version: 7.0.2 vitest: specifier: ^5.0.0 - version: 5.0.3(@types/node@25.9.9)(vite@8.3.3(@types/node@25.9.9)(yaml@2.9.0)) + version: 5.0.3(@types/node@25.9.9)(vite@8.3.4(@types/node@25.9.9)(yaml@2.9.0)) packages/playground: dependencies: @@ -274,16 +274,16 @@ importers: version: 7.0.2 vite: specifier: ^8.0.0 - version: 8.3.3(@types/node@25.9.9)(yaml@2.9.0) + version: 8.3.4(@types/node@25.9.9)(yaml@2.9.0) vite-plugin-monaco-editor: specifier: ^1.1.0 version: 1.1.0(monaco-editor@0.57.0) vite-plugin-monaco-editor-nls: specifier: ^3.0.1 - version: 3.0.1(vite@8.3.3(@types/node@25.9.9)(yaml@2.9.0)) + version: 3.0.1(vite@8.3.4(@types/node@25.9.9)(yaml@2.9.0)) vitest: specifier: ^5.0.0 - version: 5.0.3(@types/node@25.9.9)(vite@8.3.3(@types/node@25.9.9)(yaml@2.9.0)) + version: 5.0.3(@types/node@25.9.9)(vite@8.3.4(@types/node@25.9.9)(yaml@2.9.0)) packages/vite-plugin: dependencies: @@ -299,7 +299,7 @@ importers: version: 7.0.2 vite: specifier: ^8.0.0 - version: 8.3.3(@types/node@25.9.9)(yaml@2.9.0) + version: 8.3.4(@types/node@25.9.9)(yaml@2.9.0) packages: @@ -2234,6 +2234,10 @@ packages: resolution: {integrity: sha512-RRuzqDtt5Y9h3quz5hWhK+TPnsmVs6WwSU6LkJMeY4HstUEDuYTG8UJSdawMRzmzAtV+KEoG8N3Qg2qLy5vM/A==} engines: {node: ^10 || ^12 || >=14} + postcss@8.5.29: + resolution: {integrity: sha512-49cGhUbXj8Qenv0iTMxA1cFBzxXoctpC9Ujd77t1WcbJIr6nF/eI7g/8MgxrYldFRuAXvja7xQRwavoW7kgrxQ==} + engines: {node: ^10 || ^12 || >=14} + preact@10.28.4: resolution: {integrity: sha512-uKFfOHWuSNpRFVTnljsCluEFq57OKT+0QdOiQo8XWnQ/pSvg7OpX5eNOejELXJMWy+BwM2nobz0FkvzmnpCNsQ==} @@ -2288,6 +2292,10 @@ packages: resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==} engines: {node: '>=0.10.0'} + source-map-js@1.2.2: + resolution: {integrity: sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==} + engines: {node: '>=0.10.0'} + space-separated-tokens@2.0.2: resolution: {integrity: sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==} @@ -2453,8 +2461,8 @@ packages: terser: optional: true - vite@8.3.3: - resolution: {integrity: sha512-cTAldKPImjg6c+gk48U19POPn3GCBzZwpdsN8ZMEEcbpes+6/wvfqUd0C2y3qYY4wsj8PwgFwrZ/1jBPVttMSg==} + vite@8.3.4: + resolution: {integrity: sha512-IftLE8phJhdNRIGNEV4JCCvfNScoZQVfcXaN8TQropWGJtOHcu+iAB9pHcuGvmEb/kddw0LBe/jS8ztdC6xdiQ==} engines: {node: ^20.19.0 || >=22.12.0} hasBin: true peerDependencies: @@ -3614,14 +3622,14 @@ snapshots: chai: 6.2.2 tinyrainbow: 3.1.1 - '@vitest/mocker@5.0.3(vite@8.3.3(@types/node@25.9.9)(yaml@2.9.0))': + '@vitest/mocker@5.0.3(vite@8.3.4(@types/node@25.9.9)(yaml@2.9.0))': dependencies: '@jridgewell/trace-mapping': 0.3.31 '@vitest/spy': 5.0.3 estree-walker: 3.0.3 magic-string: 1.2.3 optionalDependencies: - vite: 8.3.3(@types/node@25.9.9)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.9.9)(yaml@2.9.0) '@vitest/pretty-format@4.1.11': dependencies: @@ -4162,6 +4170,12 @@ snapshots: picocolors: 1.1.1 source-map-js: 1.2.1 + postcss@8.5.29: + dependencies: + nanoid: 3.3.19 + picocolors: 1.1.1 + source-map-js: 1.2.2 + preact@10.28.4: {} property-information@7.1.0: {} @@ -4253,6 +4267,8 @@ snapshots: source-map-js@1.2.1: {} + source-map-js@1.2.2: {} + space-separated-tokens@2.0.2: {} speakingurl@14.0.1: {} @@ -4394,9 +4410,9 @@ snapshots: '@types/unist': 3.0.3 vfile-message: 4.0.3 - vite-plugin-monaco-editor-nls@3.0.1(vite@8.3.3(@types/node@25.9.9)(yaml@2.9.0)): + vite-plugin-monaco-editor-nls@3.0.1(vite@8.3.4(@types/node@25.9.9)(yaml@2.9.0)): dependencies: - vite: 8.3.3(@types/node@25.9.9)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.9.9)(yaml@2.9.0) vite-plugin-monaco-editor@1.1.0(monaco-editor@0.57.0): dependencies: @@ -4412,11 +4428,11 @@ snapshots: fsevents: 2.3.3 lightningcss: 1.33.0 - vite@8.3.3(@types/node@25.9.9)(yaml@2.9.0): + vite@8.3.4(@types/node@25.9.9)(yaml@2.9.0): dependencies: lightningcss: 1.33.0 picomatch: 4.0.7 - postcss: 8.5.28 + postcss: 8.5.29 rolldown: 1.2.13 tinyglobby: 0.2.17 optionalDependencies: @@ -4473,10 +4489,10 @@ snapshots: - typescript - universal-cookie - vitest@5.0.3(@types/node@25.9.9)(vite@8.3.3(@types/node@25.9.9)(yaml@2.9.0)): + vitest@5.0.3(@types/node@25.9.9)(vite@8.3.4(@types/node@25.9.9)(yaml@2.9.0)): dependencies: '@types/chai': 5.2.3 - '@vitest/mocker': 5.0.3(vite@8.3.3(@types/node@25.9.9)(yaml@2.9.0)) + '@vitest/mocker': 5.0.3(vite@8.3.4(@types/node@25.9.9)(yaml@2.9.0)) chai: 6.2.2 es-module-lexer: 2.3.2 expect-type: 1.4.0 @@ -4487,7 +4503,7 @@ snapshots: tinybench: 6.1.4 tinyexec: 1.3.0 tinyglobby: 0.2.17 - vite: 8.3.3(@types/node@25.9.9)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.9.9)(yaml@2.9.0) why-is-node-running: 3.2.1 optionalDependencies: '@types/node': 25.9.9 From 17dd5ada6ab46c77e49085dd08260ed8a38cb6a1 Mon Sep 17 00:00:00 2001 From: tignear Date: Fri, 16 Oct 2026 01:38:24 +0900 Subject: [PATCH 02/16] ci: restore focused PR checks with parallel Mergify batches --- .github/workflows/ci.yml | 54 +++++++--- .github/workflows/pr-title.yml | 33 +++++- .mergify.yml | 11 +- CONTRIBUTING.md | 23 +++-- scripts/check-mergify-batch.mjs | 91 +++++++++++++++++ scripts/check-mergify-batch.test.mjs | 145 +++++++++++++++++++++++++++ scripts/check-pr-release-impact.mjs | 4 +- scripts/check-pr-title.test.mjs | 2 +- scripts/ci-changes.mjs | 9 +- scripts/ci-changes.test.mjs | 7 +- scripts/ci-workflow.test.mjs | 36 +++++-- scripts/mergify.test.mjs | 8 +- 12 files changed, 377 insertions(+), 46 deletions(-) create mode 100644 scripts/check-mergify-batch.mjs create mode 100644 scripts/check-mergify-batch.test.mjs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 950ce516bb6..0b51357024f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ name: CI -# Mergify checks each PR in place after updating it with the target branch. +# Ordinary PRs run focused checks; queue draft PRs run pre-merge validation. # Keep merge_group during migration and rollback; landed pushes need no rerun. on: pull_request: @@ -28,6 +28,7 @@ jobs: env: STABLE_LANE: ${{ github.ref_name == 'master' || github.base_ref == 'master' || (github.event_name == 'merge_group' && github.event.merge_group.base_ref == 'refs/heads/master') }} outputs: + queue: ${{ steps.classify.outputs.queue }} docs: ${{ steps.classify.outputs.docs }} release: ${{ steps.classify.outputs.release }} javascript: ${{ steps.classify.outputs.javascript }} @@ -53,7 +54,7 @@ jobs: HEAD_SHA: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha || github.sha }} FULL_VALIDATION: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} MERGE_GROUP_BASE_REF: ${{ github.event.merge_group.base_ref || format('refs/heads/{0}', github.base_ref) }} - MERGIFY_INPLACE: "true" + QUEUE_VALIDATION: ${{ github.event_name != 'pull_request' || startsWith(github.head_ref, 'mergify/merge-queue/') || contains(github.event.pull_request.labels.*.name, 'ci:full') }} # Keep the classifier usable before the pinned toolchain is installed. RUSTUP_TOOLCHAIN: stable run: node scripts/ci-changes.mjs "$BASE_SHA" "$HEAD_SHA" @@ -497,8 +498,8 @@ jobs: RUST_REQUIRED: ${{ needs.changes.outputs.rust }} RUST_RESULT: ${{ needs.rust-tests.result }} SV_TESTS_RESULT: ${{ needs.sv-tests.result }} - # In-place queue validation must include ARM64 on the original PR. - ARM64_REQUIRED: ${{ needs.changes.outputs.rust != 'false' }} + # Platform coverage is mandatory in queue and full validation runs. + ARM64_REQUIRED: ${{ needs.changes.outputs.queue != 'false' && needs.changes.outputs.rust != 'false' }} ARM64_RESULT: ${{ needs.arm64-backend.result }} NAPI_REQUIRED: ${{ needs.changes.outputs.napi }} NATIVE_RESULT: ${{ needs.napi-linux.result }} @@ -533,9 +534,8 @@ jobs: arm64-backend: name: ARM64 Backend Test needs: changes - # Mergify checks the original PR; platform checks must run there too. - # The required Rust gate rejects a skipped or failed ARM64 result. - if: always() && (needs.changes.result != 'success' || needs.changes.outputs.rust == 'true') + # Full platform checks run once in the queue, not on every PR push. + if: always() && needs.changes.outputs.queue != 'false' && (needs.changes.result != 'success' || needs.changes.outputs.rust == 'true') runs-on: ubuntu-26.04-arm steps: - uses: actions/checkout@v7 @@ -572,7 +572,7 @@ jobs: napi-windows: name: NAPI Build (Windows) needs: changes - if: always() && (needs.changes.result != 'success' || needs.changes.outputs.napi == 'true') + if: always() && needs.changes.outputs.queue != 'false' && (needs.changes.result != 'success' || needs.changes.outputs.napi == 'true') runs-on: windows-latest steps: - uses: actions/checkout@v7 @@ -608,7 +608,7 @@ jobs: napi-linux-arm64: name: NAPI Build (Linux ARM64 GNU) needs: changes - if: always() && (needs.changes.result != 'success' || needs.changes.outputs.napi_arm64 == 'true') + if: always() && needs.changes.outputs.queue != 'false' && (needs.changes.result != 'success' || needs.changes.outputs.napi_arm64 == 'true') runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 @@ -695,7 +695,7 @@ jobs: js-windows: name: JS Test (Windows) needs: [changes, napi-windows] - if: always() && (needs.changes.result != 'success' || needs.changes.outputs.javascript == 'true') + if: always() && needs.changes.outputs.queue != 'false' && (needs.changes.result != 'success' || needs.changes.outputs.javascript == 'true') runs-on: windows-latest steps: - uses: actions/checkout@v7 @@ -767,13 +767,43 @@ jobs: timeout-minutes: 5 run: pnpm --filter @celox-sim/playground exec playwright test - # Full runs are not merge gates, so a failure must reach someone. Keep one - # issue per branch open while full CI fails and close it once it passes. + queue-validation: + name: Queue validation + needs: [changes, lint, rust, napi-windows, napi-linux-arm64, js-ubuntu, js-windows, playground-browser, docs] + if: always() && needs.changes.outputs.queue != 'false' + runs-on: ubuntu-latest + env: + NEEDS: ${{ toJSON(needs) }} + steps: + - name: Require successful pre-merge validation + run: | + node --input-type=module -e ' + const jobs = JSON.parse(process.env.NEEDS); + const changed = jobs.changes.outputs; + const required = { + docs: changed.docs === "true", + lint: [changed.rust, changed.javascript, changed.scripts].includes("true"), + rust: [changed.rust, changed.napi].includes("true"), + "napi-windows": changed.napi === "true", + "napi-linux-arm64": changed.napi_arm64 === "true", + "js-ubuntu": changed.javascript === "true", + "js-windows": changed.javascript === "true", + "playground-browser": [changed.napi, changed.javascript].includes("true"), + }; + if (Object.entries(required).some(([name, required]) => required && jobs[name].result !== "success") || + jobs.changes.result !== "success" || jobs.changes.outputs.queue !== "true" || + Object.values(jobs).some(job => !["success", "skipped"].includes(job.result))) { + process.exit(1); + } + ' + + # Report daily/manual runs independently of merge queue validation. report-full-validation: name: Report full validation needs: [ changes, + queue-validation, docs, lint, rust-tests, diff --git a/.github/workflows/pr-title.yml b/.github/workflows/pr-title.yml index 3c83ad55947..37ce13473da 100644 --- a/.github/workflows/pr-title.yml +++ b/.github/workflows/pr-title.yml @@ -20,13 +20,13 @@ jobs: ref: ${{ github.event.repository.default_branch }} - name: Validate pull request title - if: github.event_name == 'pull_request_target' + if: github.event_name == 'pull_request_target' && !startsWith(github.head_ref, 'mergify/merge-queue/') env: PR_TITLE: ${{ github.event.pull_request.title }} run: node scripts/check-pr-title.mjs "$PR_TITLE" - name: Validate pull request commit release impact - if: github.event_name == 'pull_request_target' && github.event.pull_request.base.ref == github.event.repository.default_branch + if: github.event_name == 'pull_request_target' && !startsWith(github.head_ref, 'mergify/merge-queue/') && github.event.pull_request.base.ref == github.event.repository.default_branch env: GH_TOKEN: ${{ github.token }} PR_NUMBER: ${{ github.event.pull_request.number }} @@ -34,6 +34,35 @@ jobs: PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} run: node scripts/check-pr-release-impact.mjs + # Batch source is data only. Execute validators from the trusted checkout. + - name: Check out the queue tree for metadata + if: github.event_name == 'pull_request_target' && startsWith(github.head_ref, 'mergify/merge-queue/') + uses: actions/checkout@v7 + with: + ref: ${{ github.event.pull_request.head.sha }} + path: queue-tree + persist-credentials: false + + - name: Install queue metadata reader + if: github.event_name == 'pull_request_target' && startsWith(github.head_ref, 'mergify/merge-queue/') + uses: Mergifyio/setup-cli@v2 + with: + mergify_cli_version: 2026.10.5 + + - name: Read queue metadata + if: github.event_name == 'pull_request_target' && startsWith(github.head_ref, 'mergify/merge-queue/') + working-directory: queue-tree + run: mergify ci queue-info > "$RUNNER_TEMP/mergify-queue.json" + + - name: Validate queued pull request titles and release impact + if: github.event_name == 'pull_request_target' && startsWith(github.head_ref, 'mergify/merge-queue/') + env: + GH_TOKEN: ${{ github.token }} + PR_NUMBER: ${{ github.event.pull_request.number }} + PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} + MERGIFY_METADATA_FILE: ${{ runner.temp }}/mergify-queue.json + run: node scripts/check-mergify-batch.mjs + - name: Revalidate merge group release impact if: github.event_name == 'merge_group' && github.event.merge_group.base_ref == format('refs/heads/{0}', github.event.repository.default_branch) env: diff --git a/.mergify.yml b/.mergify.yml index 2c15768f3c6..56d6d411386 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -1,14 +1,14 @@ # yaml-language-server: $schema=https://docs.mergify.com/mergify-configuration-schema.json -# In-place validation: changing parallelism/batching requires batch-PR support -# in the Conventional Commit and release-impact checks first. +# Keep ordinary PR checks focused; validate combined trees on queue draft PRs. merge_queue: - max_parallel_checks: 1 + max_parallel_checks: 5 queued_label: queued dequeued_label: dequeued queue_rules: - name: default - batch_size: 1 + batch_size: 5 + batch_max_wait_time: 0 seconds max_checks_retries: 0 checks_timeout: 3 hours merge_method: merge @@ -18,6 +18,9 @@ queue_rules: body: empty trailers: [] branch_protection_injection_mode: queue + merge_conditions: + - check-success = Queue validation + - check-success = Conventional Commit title queue_conditions: - base ~= ^(master|develop)$ - -draft diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4f3a07baed1..2ab771cb85d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -68,12 +68,14 @@ minimum safety net, not the definition of validation completeness. ## CI coverage and cadence -Pull requests use `scripts/ci-changes.mjs` to select jobs. Mergify updates each -queued PR with its target branch and reruns the same checks in place, one PR at -a time. Windows and ARM64 jobs therefore run on PRs as well as Linux jobs. -When Rust is affected, CI runs the whole workspace before merging; the Rust -scope helper remains available for local focused validation. Jobs unrelated to -the changed paths may still skip. +Pull requests use `scripts/ci-changes.mjs` to select jobs and scope Rust tests +by affected crates. Windows and ARM64 checks run in Mergify queue draft PRs, +legacy merge groups, and daily/manual full runs. Queue drafts run the full Rust +workspace when Rust is affected. Mergify checks up to five batches concurrently, +with up to five PRs per batch and no delay waiting to fill a batch. +The `Queue validation` merge condition requires those pre-merge checks to pass; +ordinary PR checks cannot satisfy it. The `ci:full` label opts a PR into the +same coverage on its next push. Unrelated paths may still skip jobs. - Add `merge-ready` to request automatic queueing, or comment `@mergifyio queue` for an ordinary PR. A failed queue entry receives `dequeued`; investigate it, @@ -81,9 +83,12 @@ the changed paths may still skip. - The release PR requires `merge-ready` from the weekly release workflow and must not carry `release:hold`. Dependency rolls and lane synchronization use the same queue request label. -- `merge_group` remains supported for migration and rollback to GitHub's native - queue. Do not enable Mergify batching or parallel speculative checks without - implementing and testing batch-PR title and release-impact validation first. +- Queue draft title checks validate the original PRs and their release impact, + using the release policy from the exact batch tree. +- GitHub's strict up-to-date setting must be off for draft-PR queues: Mergify + validates the combined tree instead of updating every original PR. Required + status checks remain enabled. Keep the `Queue validation` merge condition. +- `merge_group` remains supported for rollback to GitHub's native queue. - The queue validates the tree before it lands, so pushes to `master` and `develop` do not run CI again. Daily full runs keep those branches' caches warm. - `sync-develop.yml` opens or updates the master-to-develop synchronization pull diff --git a/scripts/check-mergify-batch.mjs b/scripts/check-mergify-batch.mjs new file mode 100644 index 00000000000..42479004258 --- /dev/null +++ b/scripts/check-mergify-batch.mjs @@ -0,0 +1,91 @@ +import { readFileSync } from "node:fs"; +import { pathToFileURL } from "node:url"; +import { isConventionalPrTitle } from "./check-pr-title.mjs"; +import { + githubJson, + loadPullRequestCommits, + loadReleasePolicy, + releaseImpactErrors, +} from "./check-pr-release-impact.mjs"; + +export function batchPullRequestNumbers(metadata) { + const entries = metadata?.pull_requests; + if (!Array.isArray(entries) || entries.length === 0) { + throw new Error("Missing merge queue pull requests"); + } + const numbers = entries.map((entry) => entry.number); + if ( + numbers.some((number) => !Number.isSafeInteger(number) || number < 1) || + new Set(numbers).size !== numbers.length + ) { + throw new Error("Invalid merge queue pull request numbers"); + } + return numbers; +} + +export async function validateBatch( + { repository, number, sha, metadata }, + api = githubJson, + loadCommits = loadPullRequestCommits, + loadPolicy = loadReleasePolicy, +) { + if (!/^[0-9a-f]{40}$/.test(sha ?? "")) + throw new Error("Exact batch SHA required"); + const batch = await api(`/repos/${repository}/pulls/${number}`); + if ( + batch.user?.login !== "mergify[bot]" || + batch.user?.type !== "Bot" || + batch.head?.repo?.full_name !== repository || + batch.head?.sha !== sha || + !batch.head?.ref?.startsWith("mergify/merge-queue/") || + !batch.draft + ) { + throw new Error("Not the expected Mergify queue draft"); + } + const numbers = batchPullRequestNumbers(metadata); + const repo = await api(`/repos/${repository}`); + const options = + batch.base.ref === repo.default_branch + ? await loadPolicy(repository, sha) + : null; + for (const sourceNumber of numbers) { + if (sourceNumber === number) throw new Error("Batch cannot contain itself"); + const source = await api(`/repos/${repository}/pulls/${sourceNumber}`); + if ( + source.base?.ref !== batch.base.ref || + !isConventionalPrTitle(source.title) + ) { + throw new Error(`Invalid title or base for #${sourceNumber}`); + } + // Never certify a force-pushed PR that is no longer part of this batch. + const comparison = await api( + `/repos/${repository}/compare/${source.head.sha}...${sha}`, + ); + if (!["ahead", "identical"].includes(comparison.status)) { + throw new Error( + `#${sourceNumber} head is not contained in the tested batch`, + ); + } + if (options) { + const commits = await loadCommits(repository, sourceNumber); + const errors = releaseImpactErrors(source.title, commits, options); + if (errors.length) + throw new Error(`#${sourceNumber}: ${errors.join("; ")}`); + } + } + return numbers; +} + +if ( + process.argv[1] && + import.meta.url === pathToFileURL(process.argv[1]).href +) { + await validateBatch({ + repository: process.env.GITHUB_REPOSITORY, + number: Number(process.env.PR_NUMBER), + sha: process.env.PR_HEAD_SHA, + metadata: JSON.parse( + readFileSync(process.env.MERGIFY_METADATA_FILE, "utf8"), + ), + }); +} diff --git a/scripts/check-mergify-batch.test.mjs b/scripts/check-mergify-batch.test.mjs new file mode 100644 index 00000000000..74c1982fd90 --- /dev/null +++ b/scripts/check-mergify-batch.test.mjs @@ -0,0 +1,145 @@ +import assert from "node:assert/strict"; +import test from "node:test"; +import { + batchPullRequestNumbers, + validateBatch, +} from "./check-mergify-batch.mjs"; + +const sha = "a".repeat(40); +const sourceSha = "b".repeat(40); +const metadata = { pull_requests: [{ number: 12 }, { number: 13 }] }; +function fixture() { + const batch = { + user: { login: "mergify[bot]", type: "Bot" }, + head: { + repo: { full_name: "o/r" }, + sha, + ref: "mergify/merge-queue/master/pr-12", + }, + base: { ref: "master" }, + draft: true, + }; + const source = { + title: "fix: correct behavior", + head: { sha: sourceSha }, + base: { ref: "master" }, + }; + const calls = []; + const api = async (path) => { + calls.push(path); + if (path === "/repos/o/r/pulls/99") return batch; + if (path === "/repos/o/r") return { default_branch: "master" }; + if (path.startsWith("/repos/o/r/pulls/")) return source; + if (path === `/repos/o/r/compare/${sourceSha}...${sha}`) + return { status: "ahead" }; + throw new Error(`Unexpected API: ${path}`); + }; + const input = { repository: "o/r", number: 99, sha, metadata }; + const commits = async () => [ + { sha: sourceSha, message: "fix: correct behavior" }, + ]; + const policy = async (repo, ref) => { + assert.equal(repo, "o/r"); + assert.equal(ref, sha); + return { preMajor: false, bumpPatchForMinorPreMajor: false }; + }; + return { batch, source, calls, api, input, commits, policy }; +} + +test("batch metadata must identify nonempty, distinct original PRs", () => { + assert.deepEqual(batchPullRequestNumbers(metadata), [12, 13]); + for (const value of [ + null, + {}, + { pull_requests: [] }, + { pull_requests: [{ number: "12" }] }, + { pull_requests: [{ number: 0 }] }, + { pull_requests: [{ number: 12 }, { number: 12 }] }, + ]) { + assert.throws(() => batchPullRequestNumbers(value)); + } +}); + +test("validates every source PR against policy from the exact batch tree", async () => { + const f = fixture(); + assert.deepEqual( + await validateBatch(f.input, f.api, f.commits, f.policy), + [12, 13], + ); + assert.ok(f.calls.includes("/repos/o/r/pulls/12")); + assert.ok(f.calls.includes("/repos/o/r/pulls/13")); +}); + +test("rejects spoofed batch authors, forks, stale heads, and non-drafts", async () => { + for (const mutate of [ + (f) => (f.batch.user.login = "someone"), + (f) => (f.batch.user.type = "User"), + (f) => (f.batch.head.repo.full_name = "fork/r"), + (f) => (f.batch.head.sha = sourceSha), + (f) => (f.batch.draft = false), + (f) => (f.batch.head.ref = "feature/test"), + ]) { + const f = fixture(); + mutate(f); + await assert.rejects( + validateBatch(f.input, f.api, f.commits, f.policy), + /expected Mergify/, + ); + } +}); + +test("rejects source PRs with invalid titles or another target branch", async () => { + for (const mutate of [ + (f) => (f.source.title = "Merge changes"), + (f) => (f.source.base.ref = "develop"), + ]) { + const f = fixture(); + mutate(f); + await assert.rejects( + validateBatch(f.input, f.api, f.commits, f.policy), + /Invalid title or base/, + ); + } +}); + +test("rejects a force-pushed source head absent from the batch", async () => { + const f = fixture(); + await assert.rejects( + validateBatch( + f.input, + (path) => + path.includes("/compare/") ? { status: "diverged" } : f.api(path), + f.commits, + f.policy, + ), + /not contained/, + ); +}); + +test("a batch cannot conceal a source PR's understated release impact", async () => { + const f = fixture(); + await assert.rejects( + validateBatch( + f.input, + f.api, + async () => [{ sha: sourceSha, message: "feat!: break the API" }], + f.policy, + ), + /exceeds/, + ); +}); + +test("develop batches still validate titles without applying master release policy", async () => { + const f = fixture(); + f.batch.base.ref = "develop"; + f.source.base.ref = "develop"; + assert.deepEqual( + await validateBatch( + f.input, + f.api, + () => assert.fail(), + () => assert.fail(), + ), + [12, 13], + ); +}); diff --git a/scripts/check-pr-release-impact.mjs b/scripts/check-pr-release-impact.mjs index 98cd7c0efe6..87b526012be 100644 --- a/scripts/check-pr-release-impact.mjs +++ b/scripts/check-pr-release-impact.mjs @@ -218,7 +218,7 @@ export function releaseImpactErrors(title, commits, options) { }); } -async function githubJson(path) { +export async function githubJson(path) { const apiUrl = process.env.GITHUB_API_URL ?? "https://api.github.com"; const response = await fetch(`${apiUrl}${path}`, { headers: { @@ -258,7 +258,7 @@ async function githubGraphql(query, variables) { return payload.data; } -async function loadPullRequestCommits(repository, number) { +export async function loadPullRequestCommits(repository, number) { const pullRequest = await githubJson(`/repos/${repository}/pulls/${number}`); // BEGIN_COMMIT_OVERRIDE does not apply to plain merges. The companion // repository-settings check enforces that this repository stays merge-only. diff --git a/scripts/check-pr-title.test.mjs b/scripts/check-pr-title.test.mjs index fbe36db107d..56d768de485 100644 --- a/scripts/check-pr-title.test.mjs +++ b/scripts/check-pr-title.test.mjs @@ -50,7 +50,7 @@ test("guards the repository setting that exposes the title to release automation ); assert.match( workflow, - /Validate pull request commit release impact\n\s+if: github\.event_name == 'pull_request_target' && github\.event\.pull_request\.base\.ref == github\.event\.repository\.default_branch/, + /Validate pull request commit release impact\n\s+if: github\.event_name == 'pull_request_target' && !startsWith\(github\.head_ref, 'mergify\/merge-queue\/'\) && github\.event\.pull_request\.base\.ref == github\.event\.repository\.default_branch/, ); assert.match( workflow, diff --git a/scripts/ci-changes.mjs b/scripts/ci-changes.mjs index 2d68b7b7029..ffee3a96f52 100644 --- a/scripts/ci-changes.mjs +++ b/scripts/ci-changes.mjs @@ -239,7 +239,9 @@ if ( const files = scheduledFull ? null : changedFiles(process.argv[2] ?? "", process.argv[3] ?? ""); - const release = isReleaseMergeGroup({ + const queue = process.env.QUEUE_VALIDATION === "true" || + (process.env.QUEUE_VALIDATION !== "false" && process.env.GITHUB_EVENT_NAME !== "pull_request"); + const release = queue && isReleaseMergeGroup({ event: process.env.GITHUB_EVENT_NAME, baseRef: process.env.MERGE_GROUP_BASE_REF, files, @@ -252,11 +254,12 @@ if ( heliodor_arm64: affectsHeliodorArm64(files), }; writeOutputs({ + queue, ...affected, release, ...rustScopeOutputs( process.env.GITHUB_EVENT_NAME === "pull_request" && - process.env.MERGIFY_INPLACE !== "true" && + !queue && !release && affected.rust ? files @@ -265,7 +268,7 @@ if ( }); } -// In-place queue validation, legacy merge groups, releases and daily runs keep +// Queue drafts, legacy merge groups, releases and daily runs keep // the whole workspace. The scope helper remains available outside queue CI. function rustScopeOutputs(files) { let scope = { full: true }; diff --git a/scripts/ci-changes.test.mjs b/scripts/ci-changes.test.mjs index 365c3318471..ff1755943cc 100644 --- a/scripts/ci-changes.test.mjs +++ b/scripts/ci-changes.test.mjs @@ -140,6 +140,7 @@ test("full validation overrides even an empty valid diff", () => { ), { ...all, + queue: true, heliodor_arm64: true, release: false, // The whole Rust workspace, with no package scope or filter. @@ -188,7 +189,7 @@ function runClassifier( const [name, value] = line.split("="); return [name, value === "true"]; }) - .filter(([name]) => !name.startsWith("rust_")), + .filter(([name]) => !name.startsWith("rust_") && name !== "queue"), ); } @@ -453,7 +454,7 @@ test("generic Rust changes do not schedule ARM64 Heliodor on pull requests", () ); }); -test("in-place master PRs run release gates even with an unknown diff", () => { +test("queue drafts on master run release gates even with an unknown diff", () => { for (const files of [[".release-please-manifest.json"], null]) { assert.equal( isReleaseMergeGroup({ @@ -476,7 +477,7 @@ test("in-place master PRs run release gates even with an unknown diff", () => { runClassifier("", "", { GITHUB_EVENT_NAME: "pull_request", MERGE_GROUP_BASE_REF: "refs/heads/master", - MERGIFY_INPLACE: "true", + QUEUE_VALIDATION: "true", }), { ...all, heliodor_arm64: true, release: true }, ); diff --git a/scripts/ci-workflow.test.mjs b/scripts/ci-workflow.test.mjs index 378a6053031..9363606830b 100644 --- a/scripts/ci-workflow.test.mjs +++ b/scripts/ci-workflow.test.mjs @@ -29,7 +29,7 @@ test("the required gate rejects failures and only accepts explicitly optional sk ); assert.match( gate, - /ARM64_REQUIRED: \$\{\{ needs\.changes\.outputs\.rust != 'false' \}\}/, + /ARM64_REQUIRED: \$\{\{ needs\.changes\.outputs\.queue != 'false' && needs\.changes\.outputs\.rust != 'false' \}\}/, ); assert.match(gate, /ARM64_RESULT: \$\{\{ needs\.arm64-backend\.result \}\}/); const script = gate.match(/ run: \|\n([\s\S]*)/)[1]; @@ -172,7 +172,7 @@ test("scheduled and manual validation run all paths and external suites", () => /MERGE_GROUP_BASE_REF: .*github\.event\.merge_group\.base_ref.*github\.base_ref/, ); assert.doesNotMatch(job("changes"), /RELEASE_PLEASE_PR:/); - assert.match(job("changes"), /MERGIFY_INPLACE: "true"/); + assert.match(job("changes"), /QUEUE_VALIDATION: .*startsWith\(github\.head_ref, 'mergify\/merge-queue\/'\)/); assert.match(external, /fail-fast: false/); assert.match(external, /suite: \[veryl, sv\]/); assert.match(external, /tool: \[verilator, icarus\]/); @@ -225,9 +225,9 @@ test("Rust changes validate dependency exclusions even when script jobs are omit ); }); -test("in-place CI retains the whole workspace and keeps the optional scope runner", () => { +test("queue CI retains the whole workspace and ordinary PRs use scoped tests", () => { const rust = job("rust-tests"); - assert.match(job("changes"), /MERGIFY_INPLACE: "true"/); + assert.match(job("changes"), /QUEUE_VALIDATION: .*startsWith\(github\.head_ref, 'mergify\/merge-queue\/'\)/); // Anything but an explicit scope, including a failed detection, runs all. assert.match( rust, @@ -265,7 +265,7 @@ test("landed commits are not re-validated by a push run", () => { assert.match(triggers, /^\s+schedule:/m); }); -test("platform jobs run on in-place pull requests as well as legacy merge groups", () => { +test("platform jobs are deferred to queue validation", () => { const platform = [ "arm64-backend", "napi-windows", @@ -273,7 +273,7 @@ test("platform jobs run on in-place pull requests as well as legacy merge groups "js-windows", ]; for (const name of platform) { - assert.match(job(name), /\n if: always\(\) && \(/, name); + assert.match(job(name), /\n if: always\(\) && needs\.changes\.outputs\.queue != 'false' && \(/, name); } // Linux jobs still give pull requests their feedback. for (const name of [ @@ -310,3 +310,27 @@ test("full runs on long-lived branches report every job's result", () => { assert.match(report, /NEEDS: \$\{\{ toJSON\(needs\) \}\}/); assert.match(report, /run: node scripts\/report-full-ci\.mjs/); }); + +test("queue validation rejects missing coverage, producer failures and detection failure", () => { + const gate = job("queue-validation"); + assert.match(gate, /if: always\(\) && needs\.changes\.outputs\.queue != 'false'/); + const script = gate.match(/ run: \|\n([\s\S]*)/)[1]; + const needs = Object.fromEntries(["lint", "rust", "napi-windows", "napi-linux-arm64", "js-ubuntu", "js-windows", "playground-browser", "docs"].map(name => [name, { result: "success" }])); + needs.changes = { result: "success", outputs: { queue: "true", rust: "true", napi: "true", napi_arm64: "true", javascript: "true", scripts: "true", docs: "true" } }; + const passes = (value) => spawnSync("bash", ["-e", "-c", script], { env: { ...process.env, NEEDS: JSON.stringify(value) } }).status === 0; + assert.equal(passes(needs), true); + for (const name of Object.keys(needs)) { + for (const result of ["failure", "cancelled", "skipped"]) { + const failed = structuredClone(needs); failed[name].result = result; + assert.equal(passes(failed), false, `${name}: ${result}`); + } + } + for (const queue of ["false", ""]) { + const light = structuredClone(needs); light.changes.outputs.queue = queue; + assert.equal(passes(light), false); + } + const docs = structuredClone(needs); + for (const name of Object.keys(docs)) if (!["changes", "docs"].includes(name)) docs[name].result = "skipped"; + for (const flag of ["rust", "napi", "napi_arm64", "javascript", "scripts"]) docs.changes.outputs[flag] = "false"; + assert.equal(passes(docs), true); +}); diff --git a/scripts/mergify.test.mjs b/scripts/mergify.test.mjs index d4b0a490469..c8108511f33 100644 --- a/scripts/mergify.test.mjs +++ b/scripts/mergify.test.mjs @@ -5,12 +5,12 @@ import test from "node:test"; const read = (path) => readFileSync(new URL(`../${path}`, import.meta.url), "utf8"); -test("queue stays in place so original PR checks validate the merge", () => { +test("queue runs parallel batches with mandatory full validation", () => { const config = read(".mergify.yml"); - assert.match(config, /max_parallel_checks: 1/); - assert.match(config, /batch_size: 1/); + assert.match(config, /max_parallel_checks: 5/); + assert.match(config, /batch_size: 5/); assert.match(config, /max_checks_retries: 0/); - assert.doesNotMatch(config, /^\s+merge_conditions:/m); + assert.match(config, /merge_conditions:\n\s+- check-success = Queue validation\n\s+- check-success = Conventional Commit title/); assert.match(config, /merge_method: merge/); assert.match(config, /update_method: merge/); assert.match(config, /title: pr-title\n\s+body: empty\n\s+trailers: \[\]/); From fc3948e79ec0d42e3057bda6e040190d4a25e111 Mon Sep 17 00:00:00 2001 From: tignear Date: Fri, 16 Oct 2026 01:40:27 +0900 Subject: [PATCH 03/16] ci: defer version-only release checks to queue batches --- .github/workflows/ci.yml | 1 + CONTRIBUTING.md | 4 ++++ scripts/ci-changes.mjs | 24 ++++++++++++++++++++++-- scripts/ci-changes.test.mjs | 5 +++++ scripts/ci-workflow.test.mjs | 2 +- 5 files changed, 33 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b51357024f..de8ff8eca81 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,6 +54,7 @@ jobs: HEAD_SHA: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha || github.sha }} FULL_VALIDATION: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} MERGE_GROUP_BASE_REF: ${{ github.event.merge_group.base_ref || format('refs/heads/{0}', github.base_ref) }} + RELEASE_PLEASE_PR: ${{ github.event_name == 'pull_request' && github.head_ref == 'release-please--branches--master--components--celox' && github.event.pull_request.head.repo.full_name == github.repository }} QUEUE_VALIDATION: ${{ github.event_name != 'pull_request' || startsWith(github.head_ref, 'mergify/merge-queue/') || contains(github.event.pull_request.labels.*.name, 'ci:full') }} # Keep the classifier usable before the pinned toolchain is installed. RUSTUP_TOOLCHAIN: stable diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2ab771cb85d..9cbe0e2fea5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -77,6 +77,10 @@ The `Queue validation` merge condition requires those pre-merge checks to pass; ordinary PR checks cannot satisfy it. The `ci:full` label opts a PR into the same coverage on its next push. Unrelated paths may still skip jobs. +- Enable both Merge Queue and Workflow Automation in Mergify; the latter runs + the label-based queue rule. +- Version-only Release Please PRs defer product tests to the queue, where the + release manifest change requires full validation including external suites. - Add `merge-ready` to request automatic queueing, or comment `@mergifyio queue` for an ordinary PR. A failed queue entry receives `dequeued`; investigate it, remove that label, and request queueing again. There is no automatic retry loop. diff --git a/scripts/ci-changes.mjs b/scripts/ci-changes.mjs index ffee3a96f52..6083282f785 100644 --- a/scripts/ci-changes.mjs +++ b/scripts/ci-changes.mjs @@ -26,6 +26,18 @@ const NEUTRAL_FILES = new Set([ "renovate.json", ]); +// Version-only release PRs defer product validation to the queue draft. +const RELEASE_PLEASE_FILES = new Set([ + ".release-please-manifest.json", + "CHANGELOG.md", + "Cargo.lock", + "Cargo.toml", + "VERSION", + "crates/celox-napi/package.json", + "packages/celox/package.json", + "packages/vite-plugin/package.json", +]); + // These crates are consumers or test infrastructure, not runtime/build // dependencies of celox-napi. ci-changes.test.mjs checks the workspace graph // so adding a dependency cannot silently make this exclusion unsafe. @@ -102,7 +114,7 @@ export function isReleaseMergeGroup({ event, baseRef, files }) { ); } -export function classifyFiles(files) { +export function classifyFiles(files, { releasePlease = false } = {}) { const affected = { docs: false, javascript: false, @@ -114,6 +126,14 @@ export function classifyFiles(files) { const normalizedFiles = files.map((path) => path.replace(/^\.\//, "")); + if ( + releasePlease && + normalizedFiles.length > 0 && + normalizedFiles.every((path) => RELEASE_PLEASE_FILES.has(path)) + ) { + return affected; + } + for (const path of normalizedFiles) { if ( path === ".github/workflows/ci.yml" || @@ -250,7 +270,7 @@ if ( files === null || release ? { ...ALL_AFFECTED, heliodor_arm64: true } : { - ...classifyFiles(files), + ...classifyFiles(files, { releasePlease: !queue && process.env.RELEASE_PLEASE_PR === "true" }), heliodor_arm64: affectsHeliodorArm64(files), }; writeOutputs({ diff --git a/scripts/ci-changes.test.mjs b/scripts/ci-changes.test.mjs index ff1755943cc..872be4688ec 100644 --- a/scripts/ci-changes.test.mjs +++ b/scripts/ci-changes.test.mjs @@ -482,3 +482,8 @@ test("queue drafts on master run release gates even with an unknown diff", () => { ...all, heliodor_arm64: true, release: true }, ); }); + +test("version-only Release Please PRs defer product tests to queue validation", () => { + assert.deepEqual(classifyFiles(releasePullRequestFiles, { releasePlease: true }), none); + assert.equal(classifyFiles([...releasePullRequestFiles, "crates/celox/src/lib.rs"], { releasePlease: true }).rust, true); +}); diff --git a/scripts/ci-workflow.test.mjs b/scripts/ci-workflow.test.mjs index 9363606830b..2b005ee5f74 100644 --- a/scripts/ci-workflow.test.mjs +++ b/scripts/ci-workflow.test.mjs @@ -171,7 +171,7 @@ test("scheduled and manual validation run all paths and external suites", () => job("changes"), /MERGE_GROUP_BASE_REF: .*github\.event\.merge_group\.base_ref.*github\.base_ref/, ); - assert.doesNotMatch(job("changes"), /RELEASE_PLEASE_PR:/); + assert.match(job("changes"), /RELEASE_PLEASE_PR: .*github\.event\.pull_request\.head\.repo\.full_name == github\.repository/); assert.match(job("changes"), /QUEUE_VALIDATION: .*startsWith\(github\.head_ref, 'mergify\/merge-queue\/'\)/); assert.match(external, /fail-fast: false/); assert.match(external, /suite: \[veryl, sv\]/); From 4ab58a9955ec6ee4d4910072b3bc4b44759a9a3a Mon Sep 17 00:00:00 2001 From: tignear Date: Fri, 16 Oct 2026 01:42:40 +0900 Subject: [PATCH 04/16] ci: let superseded validation runs finish cancellation --- .github/workflows/ci.yml | 32 ++++++++++++++++---------------- scripts/ci-workflow.test.mjs | 10 +++++----- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index de8ff8eca81..a6068fbcd11 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,7 +67,7 @@ jobs: docs: name: Docs Build needs: changes - if: always() && (needs.changes.result != 'success' || needs.changes.outputs.docs == 'true') + if: ${{ !cancelled() && (needs.changes.result != 'success' || needs.changes.outputs.docs == 'true') }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 @@ -88,7 +88,7 @@ jobs: lint: name: Lint & Format needs: changes - if: always() && (needs.changes.result != 'success' || needs.changes.outputs.rust == 'true' || needs.changes.outputs.javascript == 'true' || needs.changes.outputs.scripts == 'true') + if: ${{ !cancelled() && (needs.changes.result != 'success' || needs.changes.outputs.rust == 'true' || needs.changes.outputs.javascript == 'true' || needs.changes.outputs.scripts == 'true') }} runs-on: ubuntu-latest env: VERYL_LANE: ${{ (github.ref_name == 'develop' || github.base_ref == 'develop' || (github.event_name == 'merge_group' && github.event.merge_group.base_ref == 'refs/heads/develop')) && 'detect' || 'stable' }} @@ -176,7 +176,7 @@ jobs: rust-tests: name: Rust Tests needs: changes - if: always() && (needs.changes.result != 'success' || needs.changes.outputs.rust == 'true') + if: ${{ !cancelled() && (needs.changes.result != 'success' || needs.changes.outputs.rust == 'true') }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 @@ -268,7 +268,7 @@ jobs: needs: changes # Scheduled and manual runs compare even when change detection fails. A # merge group that cuts a release also compares before it can merge. - if: always() && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || needs.changes.outputs.release == 'true') + if: ${{ !cancelled() && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || needs.changes.outputs.release == 'true') }} runs-on: ubuntu-latest timeout-minutes: 90 strategy: @@ -355,7 +355,7 @@ jobs: sv-tests: name: sv-tests conformance needs: changes - if: always() && (needs.changes.result != 'success' || needs.changes.outputs.rust == 'true') + if: ${{ !cancelled() && (needs.changes.result != 'success' || needs.changes.outputs.rust == 'true') }} runs-on: ubuntu-latest timeout-minutes: 60 steps: @@ -394,7 +394,7 @@ jobs: napi-linux: name: NAPI Build (Linux x64) needs: changes - if: always() && (needs.changes.result != 'success' || needs.changes.outputs.napi == 'true') + if: ${{ !cancelled() && (needs.changes.result != 'success' || needs.changes.outputs.napi == 'true') }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 @@ -436,7 +436,7 @@ jobs: napi-wasm: name: NAPI WASM Build & Test needs: changes - if: always() && (needs.changes.result != 'success' || needs.changes.outputs.napi == 'true') + if: ${{ !cancelled() && (needs.changes.result != 'success' || needs.changes.outputs.napi == 'true') }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 @@ -492,7 +492,7 @@ jobs: rust: name: Rust Test & NAPI Build needs: [changes, rust-tests, sv-tests, arm64-backend, napi-linux, napi-wasm, external-suites] - if: always() && (needs.changes.result != 'success' || needs.changes.outputs.rust == 'true' || needs.changes.outputs.napi == 'true') + if: ${{ !cancelled() && (needs.changes.result != 'success' || needs.changes.outputs.rust == 'true' || needs.changes.outputs.napi == 'true') }} runs-on: ubuntu-latest env: CHANGES_RESULT: ${{ needs.changes.result }} @@ -536,7 +536,7 @@ jobs: name: ARM64 Backend Test needs: changes # Full platform checks run once in the queue, not on every PR push. - if: always() && needs.changes.outputs.queue != 'false' && (needs.changes.result != 'success' || needs.changes.outputs.rust == 'true') + if: ${{ !cancelled() && needs.changes.outputs.queue != 'false' && (needs.changes.result != 'success' || needs.changes.outputs.rust == 'true') }} runs-on: ubuntu-26.04-arm steps: - uses: actions/checkout@v7 @@ -573,7 +573,7 @@ jobs: napi-windows: name: NAPI Build (Windows) needs: changes - if: always() && needs.changes.outputs.queue != 'false' && (needs.changes.result != 'success' || needs.changes.outputs.napi == 'true') + if: ${{ !cancelled() && needs.changes.outputs.queue != 'false' && (needs.changes.result != 'success' || needs.changes.outputs.napi == 'true') }} runs-on: windows-latest steps: - uses: actions/checkout@v7 @@ -609,7 +609,7 @@ jobs: napi-linux-arm64: name: NAPI Build (Linux ARM64 GNU) needs: changes - if: always() && needs.changes.outputs.queue != 'false' && (needs.changes.result != 'success' || needs.changes.outputs.napi_arm64 == 'true') + if: ${{ !cancelled() && needs.changes.outputs.queue != 'false' && (needs.changes.result != 'success' || needs.changes.outputs.napi_arm64 == 'true') }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 @@ -650,7 +650,7 @@ jobs: js-ubuntu: name: JS Test (Ubuntu) needs: [changes, napi-linux] - if: always() && (needs.changes.result != 'success' || needs.changes.outputs.javascript == 'true') + if: ${{ !cancelled() && (needs.changes.result != 'success' || needs.changes.outputs.javascript == 'true') }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 @@ -696,7 +696,7 @@ jobs: js-windows: name: JS Test (Windows) needs: [changes, napi-windows] - if: always() && needs.changes.outputs.queue != 'false' && (needs.changes.result != 'success' || needs.changes.outputs.javascript == 'true') + if: ${{ !cancelled() && needs.changes.outputs.queue != 'false' && (needs.changes.result != 'success' || needs.changes.outputs.javascript == 'true') }} runs-on: windows-latest steps: - uses: actions/checkout@v7 @@ -728,7 +728,7 @@ jobs: playground-browser: name: Playground Browser Test needs: [changes, napi-wasm] - if: always() && (needs.changes.result != 'success' || needs.changes.outputs.javascript == 'true' || needs.changes.outputs.napi == 'true') + if: ${{ !cancelled() && (needs.changes.result != 'success' || needs.changes.outputs.javascript == 'true' || needs.changes.outputs.napi == 'true') }} runs-on: ubuntu-latest timeout-minutes: 15 steps: @@ -771,7 +771,7 @@ jobs: queue-validation: name: Queue validation needs: [changes, lint, rust, napi-windows, napi-linux-arm64, js-ubuntu, js-windows, playground-browser, docs] - if: always() && needs.changes.outputs.queue != 'false' + if: ${{ !cancelled() && needs.changes.outputs.queue != 'false' }} runs-on: ubuntu-latest env: NEEDS: ${{ toJSON(needs) }} @@ -820,7 +820,7 @@ jobs: js-windows, playground-browser, ] - if: always() && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && (github.ref_name == 'master' || github.ref_name == 'develop') + if: ${{ !cancelled() && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && (github.ref_name == 'master' || github.ref_name == 'develop') }} runs-on: ubuntu-latest permissions: contents: read diff --git a/scripts/ci-workflow.test.mjs b/scripts/ci-workflow.test.mjs index 2b005ee5f74..147cb2574fb 100644 --- a/scripts/ci-workflow.test.mjs +++ b/scripts/ci-workflow.test.mjs @@ -18,7 +18,7 @@ function job(name) { test("the required gate rejects failures and only accepts explicitly optional skips", () => { const gate = job("rust"); assert.match(gate, /name: Rust Test & NAPI Build/); - assert.match(gate, /if: always\(\)/); + assert.match(gate, /if: \$\{\{ !cancelled\(\)/); assert.match( gate, /needs: \[changes, rust-tests, sv-tests, arm64-backend, napi-linux, napi-wasm, external-suites\]/, @@ -161,7 +161,7 @@ test("scheduled and manual validation run all paths and external suites", () => assert.match(external, /needs: changes\n/); assert.match( external, - /if: always\(\) && \(github\.event_name == 'schedule' \|\| github\.event_name == 'workflow_dispatch' \|\| needs\.changes\.outputs\.release == 'true'\)/, + /if: \$\{\{ !cancelled\(\) && \(github\.event_name == 'schedule' \|\| github\.event_name == 'workflow_dispatch' \|\| needs\.changes\.outputs\.release == 'true'\)/, ); assert.match( job("changes"), @@ -273,7 +273,7 @@ test("platform jobs are deferred to queue validation", () => { "js-windows", ]; for (const name of platform) { - assert.match(job(name), /\n if: always\(\) && needs\.changes\.outputs\.queue != 'false' && \(/, name); + assert.match(job(name), /\n if: \$\{\{ !cancelled\(\) && needs\.changes\.outputs\.queue != 'false' && \(/, name); } // Linux jobs still give pull requests their feedback. for (const name of [ @@ -304,7 +304,7 @@ test("full runs on long-lived branches report every job's result", () => { assert.deepEqual([...needs].sort(), [...jobs].sort()); assert.match( report, - /if: always\(\) && \(github\.event_name == 'schedule' \|\| github\.event_name == 'workflow_dispatch'\) && \(github\.ref_name == 'master' \|\| github\.ref_name == 'develop'\)/, + /if: \$\{\{ !cancelled\(\) && \(github\.event_name == 'schedule' \|\| github\.event_name == 'workflow_dispatch'\) && \(github\.ref_name == 'master' \|\| github\.ref_name == 'develop'\)/, ); assert.match(report, /issues: write/); assert.match(report, /NEEDS: \$\{\{ toJSON\(needs\) \}\}/); @@ -313,7 +313,7 @@ test("full runs on long-lived branches report every job's result", () => { test("queue validation rejects missing coverage, producer failures and detection failure", () => { const gate = job("queue-validation"); - assert.match(gate, /if: always\(\) && needs\.changes\.outputs\.queue != 'false'/); + assert.match(gate, /if: \$\{\{ !cancelled\(\) && needs\.changes\.outputs\.queue != 'false'/); const script = gate.match(/ run: \|\n([\s\S]*)/)[1]; const needs = Object.fromEntries(["lint", "rust", "napi-windows", "napi-linux-arm64", "js-ubuntu", "js-windows", "playground-browser", "docs"].map(name => [name, { result: "success" }])); needs.changes = { result: "success", outputs: { queue: "true", rust: "true", napi: "true", napi_arm64: "true", javascript: "true", scripts: "true", docs: "true" } }; From ceed64e4cf9c92683b7b8d87583ba15f1091ad18 Mon Sep 17 00:00:00 2001 From: tignear Date: Fri, 16 Oct 2026 01:47:04 +0900 Subject: [PATCH 05/16] docs: include queue cancellation in the corrected CI guide --- CONTRIBUTING.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9cbe0e2fea5..c0ed39fe3ca 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -84,6 +84,8 @@ same coverage on its next push. Unrelated paths may still skip jobs. - Add `merge-ready` to request automatic queueing, or comment `@mergifyio queue` for an ordinary PR. A failed queue entry receives `dequeued`; investigate it, remove that label, and request queueing again. There is no automatic retry loop. +- To cancel an automatic merge request, remove `merge-ready`, then comment + `@mergifyio dequeue`. Removing the label alone does not remove a queued PR. - The release PR requires `merge-ready` from the weekly release workflow and must not carry `release:hold`. Dependency rolls and lane synchronization use the same queue request label. From 009f1ea13b9e29b54e6b4c9c3defee63b7ed6d61 Mon Sep 17 00:00:00 2001 From: tignear Date: Fri, 16 Oct 2026 01:56:13 +0900 Subject: [PATCH 06/16] ci: revalidate speculative predecessors when release policy changes --- scripts/check-mergify-batch.mjs | 41 ++++++++++++++++++++++++++++ scripts/check-mergify-batch.test.mjs | 41 ++++++++++++++++++++++++++-- 2 files changed, 80 insertions(+), 2 deletions(-) diff --git a/scripts/check-mergify-batch.mjs b/scripts/check-mergify-batch.mjs index 42479004258..cc1f7208398 100644 --- a/scripts/check-mergify-batch.mjs +++ b/scripts/check-mergify-batch.mjs @@ -48,6 +48,47 @@ export async function validateBatch( batch.base.ref === repo.default_branch ? await loadPolicy(repository, sha) : null; + if (options) { + const basePolicy = await loadPolicy(repository, batch.base.sha); + if (JSON.stringify(basePolicy) !== JSON.stringify(options)) { + // A speculative batch can include earlier batches. If policy changes, + // revalidate their still-open PRs too, under the combined tree's policy. + const commits = new Set(); + let seen = 0; + for (let page = 1; ; page++) { + const comparison = await api( + `/repos/${repository}/compare/${batch.base.sha}...${sha}?per_page=100&page=${page}`, + ); + if ( + !Number.isSafeInteger(comparison.total_commits) || + comparison.total_commits > 10000 || + !Array.isArray(comparison.commits) + ) { + throw new Error("Cannot enumerate the speculative batch commits"); + } + for (const commit of comparison.commits) commits.add(commit.sha); + seen += comparison.commits.length; + if (seen >= comparison.total_commits) break; + if (!comparison.commits.length) + throw new Error("Incomplete batch commit pagination"); + } + for (let page = 1; ; page++) { + const pulls = await api( + `/repos/${repository}/pulls?state=open&base=${encodeURIComponent(batch.base.ref)}&per_page=100&page=${page}`, + ); + for (const pull of pulls) { + if ( + pull.number !== number && + !pull.draft && + commits.has(pull.head.sha) && + !numbers.includes(pull.number) + ) + numbers.push(pull.number); + } + if (pulls.length < 100) break; + } + } + } for (const sourceNumber of numbers) { if (sourceNumber === number) throw new Error("Batch cannot contain itself"); const source = await api(`/repos/${repository}/pulls/${sourceNumber}`); diff --git a/scripts/check-mergify-batch.test.mjs b/scripts/check-mergify-batch.test.mjs index 74c1982fd90..9e77041b60d 100644 --- a/scripts/check-mergify-batch.test.mjs +++ b/scripts/check-mergify-batch.test.mjs @@ -6,6 +6,7 @@ import { } from "./check-mergify-batch.mjs"; const sha = "a".repeat(40); +const baseSha = "c".repeat(40); const sourceSha = "b".repeat(40); const metadata = { pull_requests: [{ number: 12 }, { number: 13 }] }; function fixture() { @@ -16,7 +17,7 @@ function fixture() { sha, ref: "mergify/merge-queue/master/pr-12", }, - base: { ref: "master" }, + base: { ref: "master", sha: baseSha }, draft: true, }; const source = { @@ -40,7 +41,7 @@ function fixture() { ]; const policy = async (repo, ref) => { assert.equal(repo, "o/r"); - assert.equal(ref, sha); + assert.ok([sha, baseSha].includes(ref)); return { preMajor: false, bumpPatchForMinorPreMajor: false }; }; return { batch, source, calls, api, input, commits, policy }; @@ -143,3 +144,39 @@ test("develop batches still validate titles without applying master release poli [12, 13], ); }); + +test("policy changes revalidate preceding speculative PRs missing from this batch's metadata", async () => { + const f = fixture(); + const predecessorSha = "d".repeat(40); + const api = async (path) => { + if (path.includes(`/compare/${baseSha}...`)) + return { total_commits: 1, commits: [{ sha: predecessorSha }] }; + if (path.includes("/pulls?")) + return [{ number: 11, draft: false, head: { sha: predecessorSha } }]; + if (path.endsWith("/pulls/11")) + return { ...f.source, head: { sha: predecessorSha } }; + if (path.includes(`/compare/${predecessorSha}...`)) + return { status: "ahead" }; + return f.api(path); + }; + await assert.rejects( + validateBatch( + f.input, + api, + async (repo, number) => + number === 11 + ? [ + { + sha: predecessorSha, + message: "feat: originally accepted as a pre-major patch", + }, + ] + : f.commits(), + async (repo, ref) => ({ + preMajor: ref === baseSha, + bumpPatchForMinorPreMajor: true, + }), + ), + /#11:.*exceeds/, + ); +}); From 9c16b78c9bd26a1d3e2a3d3e30f0c2c62683f3af Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 15 Oct 2026 17:10:28 +0000 Subject: [PATCH 07/16] fix(deps): update rust crate syn to v3.0.9 --- Cargo.lock | 28 +++++++++---------- .../veryl/capture-macros/Cargo.toml | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f22c647f6de..417bc932467 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -667,7 +667,7 @@ dependencies = [ "prettyplease", "proc-macro2", "quote", - "syn 3.0.8", + "syn 3.0.9", "veryl-analyzer", "veryl-metadata", "veryl-parser", @@ -936,7 +936,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 3.0.8", + "syn 3.0.9", ] [[package]] @@ -2773,7 +2773,7 @@ dependencies = [ "napi-derive-backend", "proc-macro2", "quote", - "syn 3.0.8", + "syn 3.0.9", ] [[package]] @@ -2786,7 +2786,7 @@ dependencies = [ "proc-macro2", "quote", "semver", - "syn 3.0.8", + "syn 3.0.9", ] [[package]] @@ -3053,7 +3053,7 @@ dependencies = [ "scnr2_generate", "serde", "serde_json", - "syn 3.0.8", + "syn 3.0.9", "syntree", "syntree_layout", "tempfile", @@ -3239,7 +3239,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bfe0f4c752e450fc2faf62654f1c134747922825d5b04ca717b8874f41a40c0" dependencies = [ "proc-macro2", - "syn 3.0.8", + "syn 3.0.9", ] [[package]] @@ -3270,7 +3270,7 @@ dependencies = [ "proc-macro-error-attr3", "proc-macro2", "quote", - "syn 3.0.8", + "syn 3.0.9", ] [[package]] @@ -3630,7 +3630,7 @@ dependencies = [ "quote", "regex-syntax", "rustc-hash", - "syn 3.0.8", + "syn 3.0.9", ] [[package]] @@ -3685,7 +3685,7 @@ checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" dependencies = [ "proc-macro2", "quote", - "syn 3.0.8", + "syn 3.0.9", ] [[package]] @@ -4000,9 +4000,9 @@ dependencies = [ [[package]] name = "syn" -version = "3.0.8" +version = "3.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01016da373cd8f7ef12624f796309f5c31ba8d646dd08856c02cd741d823c622" +checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b" dependencies = [ "proc-macro2", "quote", @@ -4106,7 +4106,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 3.0.8", + "syn 3.0.9", ] [[package]] @@ -4117,7 +4117,7 @@ checksum = "f4ce35ece947bccac166e1ded639133827a953f69a48ba134d17f91108333082" dependencies = [ "proc-macro2", "quote", - "syn 3.0.8", + "syn 3.0.9", "test-case-core", ] @@ -4168,7 +4168,7 @@ checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" dependencies = [ "proc-macro2", "quote", - "syn 3.0.8", + "syn 3.0.9", ] [[package]] diff --git a/lydite/conformance/veryl/capture-macros/Cargo.toml b/lydite/conformance/veryl/capture-macros/Cargo.toml index 031ad6185b6..7758e58a33f 100644 --- a/lydite/conformance/veryl/capture-macros/Cargo.toml +++ b/lydite/conformance/veryl/capture-macros/Cargo.toml @@ -6,6 +6,6 @@ license.workspace = true [lib] proc-macro = true [dependencies] -syn = { version = "=3.0.8", features = ["full", "visit-mut", "extra-traits"] } +syn = { version = "=3.0.9", features = ["full", "visit-mut", "extra-traits"] } quote = "1" proc-macro2 = "1" From 2744a5ce9d22da1d8a8288810122b81a87c97fc8 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 15 Oct 2026 18:34:13 +0000 Subject: [PATCH 08/16] chore(deps): update rust toolchain to 87ffb7f --- flake.lock | 8 ++++---- flake.nix | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/flake.lock b/flake.lock index 3239e947a11..fd9ddd863d4 100644 --- a/flake.lock +++ b/flake.lock @@ -50,17 +50,17 @@ ] }, "locked": { - "lastModified": 1792048409, - "narHash": "sha256-ZcwtnGWuY65NQ75W1LZ99gIaFBgC0Sm+TCs1ZEabw0U=", + "lastModified": 1792087235, + "narHash": "sha256-vQHkG9lwSHJI3MVnyilP50hWW3TNnBWFTbLIurWgPhI=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "e9d12b9d8266ed9afdc5add5537ec8b5f789645c", + "rev": "87ffb7f777aef2e2647fd8fd718a5b3cbc825588", "type": "github" }, "original": { "owner": "oxalica", "repo": "rust-overlay", - "rev": "e9d12b9d8266ed9afdc5add5537ec8b5f789645c", + "rev": "87ffb7f777aef2e2647fd8fd718a5b3cbc825588", "type": "github" } } diff --git a/flake.nix b/flake.nix index 0f9bbbbe825..f6fe96c30ac 100644 --- a/flake.nix +++ b/flake.nix @@ -9,7 +9,7 @@ }; rust-overlay = { # Pin the revision explicitly so Renovate can group overlay and Rust updates. - url = "github:oxalica/rust-overlay/e9d12b9d8266ed9afdc5add5537ec8b5f789645c"; + url = "github:oxalica/rust-overlay/87ffb7f777aef2e2647fd8fd718a5b3cbc825588"; inputs.nixpkgs.follows = "nixpkgs"; }; }; From 05593b2dc7456e9ebc89fba11b1e0021aeedbd25 Mon Sep 17 00:00:00 2001 From: tignear Date: Fri, 16 Oct 2026 04:08:52 +0900 Subject: [PATCH 09/16] ci: pin the published Mergify CLI setup action --- .github/workflows/pr-title.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-title.yml b/.github/workflows/pr-title.yml index 37ce13473da..ef76000e5c9 100644 --- a/.github/workflows/pr-title.yml +++ b/.github/workflows/pr-title.yml @@ -45,7 +45,7 @@ jobs: - name: Install queue metadata reader if: github.event_name == 'pull_request_target' && startsWith(github.head_ref, 'mergify/merge-queue/') - uses: Mergifyio/setup-cli@v2 + uses: Mergifyio/setup-cli@dc99f07e699b94b39e5495c24596372813eadcbc # v1.3.0 with: mergify_cli_version: 2026.10.5 From 3883cde44a6dfd73bfd1665f5ca0c7ed585c07c5 Mon Sep 17 00:00:00 2001 From: tignear Date: Fri, 16 Oct 2026 04:25:29 +0900 Subject: [PATCH 10/16] ci: batch queued PRs and defer lydite gates to the queue --- .github/workflows/lydite.yml | 9 +++++++-- .mergify.yml | 2 +- CONTRIBUTING.md | 4 +++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lydite.yml b/.github/workflows/lydite.yml index 5054e3b000d..c529a5b5f7c 100644 --- a/.github/workflows/lydite.yml +++ b/.github/workflows/lydite.yml @@ -5,8 +5,8 @@ name: lydite # linted, and unit-tested by ci.yml; this workflow runs lydite's own gates. on: - # Pull requests run these gates before they merge into master, so a push to - # master would only repeat them. The weekly run catches drift between merges. + # Queue drafts run these gates on combined changes. Ordinary PRs skip all + # jobs; the weekly run catches drift between merges. push: branches: [develop] paths: @@ -56,6 +56,7 @@ defaults: jobs: documentation: + if: github.event_name != 'pull_request' || startsWith(github.head_ref, 'mergify/merge-queue/') runs-on: ubuntu-26.04 steps: - uses: actions/checkout@v7 @@ -65,6 +66,7 @@ jobs: run: python3 scripts/check_docs.py editor: + if: github.event_name != 'pull_request' || startsWith(github.head_ref, 'mergify/merge-queue/') runs-on: ubuntu-26.04 timeout-minutes: 20 steps: @@ -97,6 +99,7 @@ jobs: # celox-replay and veryl-proof use the in-tree Celox; the narrow veryl gate # checks lydite's own Veryl lowering against a pinned upstream corpus. celox-replay: + if: github.event_name != 'pull_request' || startsWith(github.head_ref, 'mergify/merge-queue/') runs-on: ubuntu-26.04 timeout-minutes: 30 steps: @@ -118,6 +121,7 @@ jobs: retention-days: 14 veryl-fv: + if: github.event_name != 'pull_request' || startsWith(github.head_ref, 'mergify/merge-queue/') runs-on: ubuntu-26.04 timeout-minutes: 30 steps: @@ -143,6 +147,7 @@ jobs: retention-days: 14 veryl-proof-corpus: + if: github.event_name != 'pull_request' || startsWith(github.head_ref, 'mergify/merge-queue/') runs-on: ubuntu-26.04 # Cold builds plus the sequential proof/mutation gates can exceed one hour. timeout-minutes: 120 diff --git a/.mergify.yml b/.mergify.yml index 56d6d411386..1769ad21d21 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -8,7 +8,7 @@ merge_queue: queue_rules: - name: default batch_size: 5 - batch_max_wait_time: 0 seconds + batch_max_wait_time: 1 minute max_checks_retries: 0 checks_timeout: 3 hours merge_method: merge diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c0ed39fe3ca..a05520b7b10 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -72,7 +72,9 @@ Pull requests use `scripts/ci-changes.mjs` to select jobs and scope Rust tests by affected crates. Windows and ARM64 checks run in Mergify queue draft PRs, legacy merge groups, and daily/manual full runs. Queue drafts run the full Rust workspace when Rust is affected. Mergify checks up to five batches concurrently, -with up to five PRs per batch and no delay waiting to fill a batch. +with up to five PRs per batch, waiting at most one minute to collect them. +The separate lydite proof/editor gates run on queue drafts rather than ordinary +PRs; develop pushes, weekly runs, and manual dispatch remain enabled. The `Queue validation` merge condition requires those pre-merge checks to pass; ordinary PR checks cannot satisfy it. The `ci:full` label opts a PR into the same coverage on its next push. Unrelated paths may still skip jobs. From 09ad9dd07aa6064807a911118ac635830db91456 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 15 Oct 2026 19:29:21 +0000 Subject: [PATCH 11/16] chore(deps): update rust crate sha2 to v0.11.1 --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f22c647f6de..b55eb11da01 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -788,7 +788,7 @@ dependencies = [ "num-bigint", "num-traits", "serde_json", - "sha2 0.11.0", + "sha2 0.11.1", "veryl-analyzer", "veryl-emitter", "veryl-metadata", @@ -3544,7 +3544,7 @@ checksum = "42ffa149f6aa81b58a5b3011d01a857c4ed12c7a732d2c51947a4c7c692185f0" dependencies = [ "globset", "include-flate", - "sha2 0.11.0", + "sha2 0.11.1", "walkdir", ] @@ -3739,9 +3739,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "446ba717509524cb3f22f17ecc096f10f4822d76ab5c0b9822c5f9c284e825f4" +checksum = "47d7069beb7d6ac7b9acd1039986e73443f24234f41074da099d6f994ac9ad19" dependencies = [ "cfg-if", "cpufeatures 0.3.0", From 687e3130f1fb22805ea03e6c97c8c1078cee949a Mon Sep 17 00:00:00 2001 From: tignear Date: Fri, 16 Oct 2026 04:58:12 +0900 Subject: [PATCH 12/16] ci: move full CodeQL analysis to weekly and manual runs --- .github/workflows/codeql.yml | 45 +++++++++++++++++++++++ CONTRIBUTING.md | 31 ++++++++++++++++ scripts/codeql-workflow.test.mjs | 62 ++++++++++++++++++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 .github/workflows/codeql.yml create mode 100644 scripts/codeql-workflow.test.mjs diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 00000000000..46b8940d891 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,45 @@ +name: CodeQL + +# Enable CODEQL_ADVANCED_ENABLED only after disabling GitHub's default setup. +# See CONTRIBUTING.md for the cutover and rollback procedure. +on: + pull_request: + paths: + - ".github/workflows/**" + - ".github/actions/**" + schedule: + - cron: "17 4 * * 0" + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name == 'pull_request' && 'pr' || 'full' }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +permissions: + contents: read + +jobs: + analyze: + if: vars.CODEQL_ADVANCED_ENABLED == 'true' && !startsWith(github.head_ref, 'mergify/merge-queue/') + name: Analyze (${{ matrix.language }}) + runs-on: ubuntu-latest + timeout-minutes: 45 + permissions: + contents: read + security-events: write + strategy: + fail-fast: false + max-parallel: 2 + matrix: + language: ${{ fromJSON(github.event_name == 'pull_request' && '["actions"]' || '["actions", "c-cpp", "javascript-typescript", "python", "rust"]') }} + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + - uses: github/codeql-action/init@6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee # v4 + with: + languages: ${{ matrix.language }} + build-mode: none + - uses: github/codeql-action/analyze@6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee # v4 + with: + category: /language:${{ matrix.language }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c0ed39fe3ca..5e467a0903d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -68,6 +68,37 @@ minimum safety net, not the definition of validation completeness. ## CI coverage and cadence +### Code scanning + +`.github/workflows/codeql.yml` scans Actions on pull requests that change +workflow or local action files. Other ordinary PRs and Mergify queue drafts +do not run this workflow's analysis. Every Sunday at 04:17 UTC, and on manual +dispatch, it scans Actions, C/C++, JavaScript/TypeScript, Python, and Rust, with +at most two analyses running concurrently. Compiled languages use CodeQL's +`none` build mode. There is no push-triggered full scan or merge requirement. + +The workflow is inactive until the repository variable +`CODEQL_ADVANCED_ENABLED` is set to `true`. To replace the existing automatic +scans after this workflow merges: + +1. In repository Settings, switch CodeQL analysis from default to advanced + setup, disabling default setup. Keep the existing alerts and their history. +2. Disable the separate automatic GitHub Code Quality scans in Settings; + these are independent of CodeQL default setup and would otherwise continue + using runners on PRs and pushes. +3. Set the repository Actions variable `CODEQL_ADVANCED_ENABLED` to `true`, + then manually dispatch `codeql.yml` on `master`. +4. Confirm that all five analyses upload results and that an Actions-changing + PR runs only the Actions analysis. Rust/application-only PRs should not + start CodeQL or Code Quality scans. + +For rollback, unset `CODEQL_ADVANCED_ENABLED` and re-enable default setup. +This variable allows the replacement to be reviewed without running both +setups at once. Until cutover, GitHub's existing automatic scans remain active. +See GitHub's [advanced setup migration instructions](https://docs.github.com/en/code-security/how-tos/find-and-fix-code-vulnerabilities/configure-code-scanning/configuring-advanced-setup-for-code-scanning). + +### Product checks + Pull requests use `scripts/ci-changes.mjs` to select jobs and scope Rust tests by affected crates. Windows and ARM64 checks run in Mergify queue draft PRs, legacy merge groups, and daily/manual full runs. Queue drafts run the full Rust diff --git a/scripts/codeql-workflow.test.mjs b/scripts/codeql-workflow.test.mjs new file mode 100644 index 00000000000..760adf1a42a --- /dev/null +++ b/scripts/codeql-workflow.test.mjs @@ -0,0 +1,62 @@ +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import test from "node:test"; + +const workflow = readFileSync( + new URL("../.github/workflows/codeql.yml", import.meta.url), + "utf8", +); + +test("PR analysis stays light while scheduled and manual scans cover all languages", () => { + const expression = workflow.match(/language: \$\{\{ (.+) \}\}/)[1]; + const languages = new Function("github", "fromJSON", `return ${expression}`); + assert.deepEqual(languages({ event_name: "pull_request" }, JSON.parse), [ + "actions", + ]); + for (const event_name of ["schedule", "workflow_dispatch"]) { + assert.deepEqual(languages({ event_name }, JSON.parse), [ + "actions", + "c-cpp", + "javascript-typescript", + "python", + "rust", + ]); + } + assert.match(workflow, /max-parallel: 2/); + assert.match(workflow, /build-mode: none/); +}); + +test("cutover is explicit and queue drafts do not repeat PR analysis", () => { + const expression = workflow.match(/^ if: (.+)$/m)[1]; + const enabled = new Function( + "vars", + "github", + "startsWith", + `return ${expression}`, + ); + const startsWith = (value, prefix) => value.startsWith(prefix); + for (const value of [undefined, "false", "true"]) { + for (const head_ref of [ + "", + "feature/example", + "mergify/merge-queue/batch", + ]) { + assert.equal( + enabled({ CODEQL_ADVANCED_ENABLED: value }, { head_ref }, startsWith), + value === "true" && !head_ref.startsWith("mergify/merge-queue/"), + ); + } + } +}); + +test("ordinary source changes and pushes do not start CodeQL", () => { + const triggers = workflow.split("on:\n")[1].split("\nconcurrency:")[0]; + assert.doesNotMatch(triggers, /^ (push|pull_request_target|merge_group):/m); + const paths = [...triggers.matchAll(/^ - "(.+)"$/gm)].map( + (match) => match[1], + ); + assert.deepEqual(paths, [".github/workflows/**", ".github/actions/**"]); + assert.match(triggers, /cron: "17 4 \* \* 0"/); + assert.match(triggers, /^ workflow_dispatch:/m); + assert.match(workflow, /persist-credentials: false/); +}); From 20be8c7fabe312b3afe783a106eb32cbbde4b011 Mon Sep 17 00:00:00 2001 From: tignear Date: Fri, 16 Oct 2026 06:51:19 +0900 Subject: [PATCH 13/16] ci: split Mergify batches by change category --- .mergify.yml | 61 ++++++++++++++++++++- CONTRIBUTING.md | 19 ++++++- scripts/mergify.test.mjs | 111 ++++++++++++++++++++++++++++++++++----- 3 files changed, 174 insertions(+), 17 deletions(-) diff --git a/.mergify.yml b/.mergify.yml index 1769ad21d21..b3d03d77fda 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -1,12 +1,41 @@ # yaml-language-server: $schema=https://docs.mergify.com/mergify-configuration-schema.json # Keep ordinary PR checks focused; validate combined trees on queue draft PRs. merge_queue: + # Keep combined-tree validation across categories sharing a base branch. + mode: serial max_parallel_checks: 5 queued_label: queued dequeued_label: dequeued queue_rules: - - name: default + - name: integration + batch_size: 1 + batch_max_wait_time: 0 seconds + max_checks_retries: 0 + checks_timeout: 3 hours + merge_method: merge + update_method: merge + commit_message_format: + title: pr-title + body: empty + trailers: [] + branch_protection_injection_mode: queue + merge_conditions: + - check-success = Queue validation + - check-success = Conventional Commit title + queue_conditions: + - head ~= ^(integration/|renovate/veryl-crates$|upgrade/veryl-|release-please--branches--master--components--celox$|master$) + - base ~= ^(master|develop)$ + - -draft + - -label = release:hold + # A release is only eligible after the weekly workflow requests it. + - or: + - head != release-please--branches--master--components--celox + - label = merge-ready + # Required checks (including allowed skipped jobs) come from GitHub's + # rulesets. Keep those rules enforced by GitHub; Mergify gets no bypass. + + - name: dependencies batch_size: 5 batch_max_wait_time: 1 minute max_checks_retries: 0 @@ -22,6 +51,36 @@ queue_rules: - check-success = Queue validation - check-success = Conventional Commit title queue_conditions: + - head ~= ^renovate/ + - -head ~= ^(integration/|renovate/veryl-crates$|upgrade/veryl-|release-please--branches--master--components--celox$|master$) + - base ~= ^(master|develop)$ + - -draft + - -label = release:hold + # A release is only eligible after the weekly workflow requests it. + - or: + - head != release-please--branches--master--components--celox + - label = merge-ready + # Required checks (including allowed skipped jobs) come from GitHub's + # rulesets. Keep those rules enforced by GitHub; Mergify gets no bypass. + + - name: changes + batch_size: 3 + batch_max_wait_time: 1 minute + max_checks_retries: 0 + checks_timeout: 3 hours + merge_method: merge + update_method: merge + commit_message_format: + title: pr-title + body: empty + trailers: [] + branch_protection_injection_mode: queue + merge_conditions: + - check-success = Queue validation + - check-success = Conventional Commit title + queue_conditions: + - -head ~= ^renovate/ + - -head ~= ^(integration/|renovate/veryl-crates$|upgrade/veryl-|release-please--branches--master--components--celox$|master$) - base ~= ^(master|develop)$ - -draft - -label = release:hold diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a05520b7b10..8ac016de46e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -71,8 +71,23 @@ minimum safety net, not the definition of validation completeness. Pull requests use `scripts/ci-changes.mjs` to select jobs and scope Rust tests by affected crates. Windows and ARM64 checks run in Mergify queue draft PRs, legacy merge groups, and daily/manual full runs. Queue drafts run the full Rust -workspace when Rust is affected. Mergify checks up to five batches concurrently, -with up to five PRs per batch, waiting at most one minute to collect them. +workspace when Rust is affected. Mergify checks up to five batches concurrently +across three queue rules, using serial mode to preserve combined-tree validation +between categories targeting the same base branch: + +| Queue | PR heads | Batch size | Maximum collection wait | +| --- | --- | --- | --- | +| `dependencies` | `renovate/*`, except Veryl updates | 5 | 1 minute | +| `changes` | Other heads: features, fixes, CI, and manual dependency updates | 3 | 1 minute | +| `integration` | `integration/*`, `renovate/veryl-crates`, `upgrade/veryl-*`, the Release Please branch, and legacy `master` sync PRs | 1 | None | + +The head conditions are mutually exclusive, including for explicit queue +commands. The existing `merge-ready` rule selects the matching queue without +changing which PRs may auto-merge; manual-review dependency groups still require +an explicit merge request. All three queues retain the same GitHub protections, +queue validation, title checks, release hold, and release authorization gate. +These categories control batching, not independence or separate runner capacity. + The separate lydite proof/editor gates run on queue drafts rather than ordinary PRs; develop pushes, weekly runs, and manual dispatch remain enabled. The `Queue validation` merge condition requires those pre-merge checks to pass; diff --git a/scripts/mergify.test.mjs b/scripts/mergify.test.mjs index c8108511f33..6c8f38834ec 100644 --- a/scripts/mergify.test.mjs +++ b/scripts/mergify.test.mjs @@ -5,20 +5,103 @@ import test from "node:test"; const read = (path) => readFileSync(new URL(`../${path}`, import.meta.url), "utf8"); -test("queue runs parallel batches with mandatory full validation", () => { - const config = read(".mergify.yml"); - assert.match(config, /max_parallel_checks: 5/); - assert.match(config, /batch_size: 5/); - assert.match(config, /max_checks_retries: 0/); - assert.match(config, /merge_conditions:\n\s+- check-success = Queue validation\n\s+- check-success = Conventional Commit title/); - assert.match(config, /merge_method: merge/); - assert.match(config, /update_method: merge/); - assert.match(config, /title: pr-title\n\s+body: empty\n\s+trailers: \[\]/); - assert.match(config, /branch_protection_injection_mode: queue/); - assert.match(config, /- -label = release:hold/); - assert.match( - config, - /head != release-please--branches--master--components--celox\n\s+- label = merge-ready/, +const queueConfig = read(".mergify.yml"); +const queues = queueConfig + .split("queue_rules:\n")[1] + .split("\npull_request_rules:")[0] + .split(/^ - name: /m) + .slice(1) + .map((block) => ({ name: block.split("\n")[0], block })); + +test("all queue categories preserve combined-tree validation and merge protections", () => { + assert.match(queueConfig, /mode: serial/); + assert.match(queueConfig, /max_parallel_checks: 5/); + assert.deepEqual( + queues.map((queue) => queue.name), + ["integration", "dependencies", "changes"], + ); + for (const { name, block } of queues) { + const size = { integration: 1, dependencies: 5, changes: 3 }[name]; + assert.match(block, new RegExp(`batch_size: ${size}\\b`)); + assert.match( + block, + new RegExp( + `batch_max_wait_time: ${name === "integration" ? "0 seconds" : "1 minute"}`, + ), + ); + for (const pattern of [ + /max_checks_retries: 0/, + /checks_timeout: 3 hours/, + /merge_conditions:\n\s+- check-success = Queue validation\n\s+- check-success = Conventional Commit title/, + /merge_method: merge/, + /update_method: merge/, + /title: pr-title\n\s+body: empty\n\s+trailers: \[\]/, + /branch_protection_injection_mode: queue/, + /- base ~= \^\(master\|develop\)\$/, + /- -draft/, + /- -label = release:hold/, + /head != release-please--branches--master--components--celox\n\s+- label = merge-ready/, + ]) + assert.match(block, pattern, name); + } + const rule = queueConfig.split("\npull_request_rules:")[1]; + assert.match(rule, /label = merge-ready/); + assert.match(rule, /- -label = dequeued/); + assert.match(rule, /queue: \{\}/); +}); + +test("real branch conventions route to exactly one category", () => { + // Evaluate the head predicates from the actual configuration, including + // exclusions. Common admission guards are checked separately above. + function categories(head) { + return queues + .filter(({ block }) => + [...block.matchAll(/^ - (-?)head ~= (.+)$/gm)].every( + ([, negative, pattern]) => + new RegExp(pattern).test(head) !== Boolean(negative), + ), + ) + .map(({ name }) => name); + } + const examples = { + integration: [ + "integration/veryl-head", + "integration/master-to-develop", + "renovate/veryl-crates", + "upgrade/veryl-0.22", + "release-please--branches--master--components--celox", + "master", + ], + dependencies: [ + "renovate/syn-ecosystem", + "renovate/rust-1.x", + "renovate/typescript-7.x", + "renovate/napi-rs-emnapi-compatibility", + "renovate/veryl-crates-extra", + ], + changes: [ + "feature/1123-veryl-kernels", + "fix/parser", + "ci/mergify-queue-categories", + "upgrade/other", + "feature/master", + "master-extra", + "manual-dependency-update", + ], + }; + for (const [expected, heads] of Object.entries(examples)) { + for (const head of heads) + assert.deepEqual(categories(head), [expected], head); + } + assert.ok( + read(".github/workflows/sync-develop.yml").includes( + "SYNC_BRANCH: integration/master-to-develop", + ), + ); + assert.ok( + read(".github/workflows/veryl-head.yml").includes( + "--head integration/veryl-head", + ), ); }); From ef46c00bcbb33d7535875a7b1009a33355429a0a Mon Sep 17 00:00:00 2001 From: tignear Date: Fri, 16 Oct 2026 07:06:09 +0900 Subject: [PATCH 14/16] ci: ignore obsolete merge queue title checks --- .github/workflows/pr-title.yml | 8 +- scripts/check-mergify-queue-title.mjs | 55 ++++++++++++ scripts/check-mergify-queue-title.test.mjs | 97 ++++++++++++++++++++++ 3 files changed, 153 insertions(+), 7 deletions(-) create mode 100644 scripts/check-mergify-queue-title.mjs create mode 100644 scripts/check-mergify-queue-title.test.mjs diff --git a/.github/workflows/pr-title.yml b/.github/workflows/pr-title.yml index ef76000e5c9..39d0763b605 100644 --- a/.github/workflows/pr-title.yml +++ b/.github/workflows/pr-title.yml @@ -49,19 +49,13 @@ jobs: with: mergify_cli_version: 2026.10.5 - - name: Read queue metadata - if: github.event_name == 'pull_request_target' && startsWith(github.head_ref, 'mergify/merge-queue/') - working-directory: queue-tree - run: mergify ci queue-info > "$RUNNER_TEMP/mergify-queue.json" - - name: Validate queued pull request titles and release impact if: github.event_name == 'pull_request_target' && startsWith(github.head_ref, 'mergify/merge-queue/') env: GH_TOKEN: ${{ github.token }} PR_NUMBER: ${{ github.event.pull_request.number }} PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} - MERGIFY_METADATA_FILE: ${{ runner.temp }}/mergify-queue.json - run: node scripts/check-mergify-batch.mjs + run: node scripts/check-mergify-queue-title.mjs - name: Revalidate merge group release impact if: github.event_name == 'merge_group' && github.event.merge_group.base_ref == format('refs/heads/{0}', github.event.repository.default_branch) diff --git a/scripts/check-mergify-queue-title.mjs b/scripts/check-mergify-queue-title.mjs new file mode 100644 index 00000000000..9c9fcd652d3 --- /dev/null +++ b/scripts/check-mergify-queue-title.mjs @@ -0,0 +1,55 @@ +import { execFileSync } from "node:child_process"; +import { pathToFileURL } from "node:url"; +import { validateBatch } from "./check-mergify-batch.mjs"; +import { githubJson } from "./check-pr-release-impact.mjs"; + +export async function checkQueueTitle( + input, + { + api = githubJson, + readMetadata = () => + JSON.parse( + execFileSync("mergify", ["ci", "queue-info"], { + cwd: "queue-tree", + encoding: "utf8", + }), + ), + validate = validateBatch, + } = {}, +) { + if (!/^[0-9a-f]{40}$/.test(input.sha ?? "")) + throw new Error("Exact batch SHA required"); + async function obsolete() { + const batch = await api(`/repos/${input.repository}/pulls/${input.number}`); + if (batch.state === "closed") return true; + if (batch.state !== "open" || !/^[0-9a-f]{40}$/.test(batch.head?.sha ?? "")) + throw new Error("Cannot establish current queue PR state"); + return batch.head.sha !== input.sha; + } + if (await obsolete()) return "Skipped obsolete queue PR event"; + try { + const metadata = await readMetadata(); + await validate({ ...input, metadata }); + return "Queue titles and release impact validated"; + } catch (error) { + // Mergify can finish the batch and delete its git note while this job runs. + // Only a fresh API confirmation of closure/replacement permits a skip. + // Missing notes, invalid titles, and API failures on a live batch still fail. + if (await obsolete()) + return "Skipped queue PR completed or replaced during validation"; + throw error; + } +} + +if ( + process.argv[1] && + import.meta.url === pathToFileURL(process.argv[1]).href +) { + console.log( + await checkQueueTitle({ + repository: process.env.GITHUB_REPOSITORY, + number: Number(process.env.PR_NUMBER), + sha: process.env.PR_HEAD_SHA, + }), + ); +} diff --git a/scripts/check-mergify-queue-title.test.mjs b/scripts/check-mergify-queue-title.test.mjs new file mode 100644 index 00000000000..e2d3b1e9e04 --- /dev/null +++ b/scripts/check-mergify-queue-title.test.mjs @@ -0,0 +1,97 @@ +import assert from "node:assert/strict"; +import test from "node:test"; +import { checkQueueTitle } from "./check-mergify-queue-title.mjs"; + +const input = { repository: "o/r", number: 99, sha: "a".repeat(40) }; +const open = { state: "open", head: { sha: input.sha } }; +const closed = { ...open, state: "closed" }; +const replaced = { ...open, head: { sha: "b".repeat(40) } }; +const missing = new Error("No merge queue metadata found"); + +for (const stale of [closed, replaced]) { + test(`skip ${stale.state === "closed" ? "closed" : "replaced"} batch before reading deleted metadata`, async () => { + const result = await checkQueueTitle(input, { + api: async () => stale, + readMetadata: () => assert.fail("must not read obsolete notes"), + validate: () => assert.fail("must not validate obsolete batch"), + }); + assert.match(result, /Skipped/); + }); + test(`handle ${stale.state === "closed" ? "closure" : "replacement"} during metadata retrieval`, async () => { + let reads = 0; + const result = await checkQueueTitle(input, { + api: async () => (++reads === 1 ? open : stale), + readMetadata: () => { + throw missing; + }, + }); + assert.equal(reads, 2); + assert.match(result, /Skipped/); + }); +} + +test("missing metadata for an active batch remains a failure", async () => { + await assert.rejects( + checkQueueTitle(input, { + api: async () => open, + readMetadata: () => { + throw missing; + }, + }), + (error) => error === missing, + ); +}); + +test("active batch validates the exact CLI metadata", async () => { + const metadata = { pull_requests: [{ number: 12 }] }; + let validated = false; + await checkQueueTitle(input, { + api: async () => open, + readMetadata: () => metadata, + validate: async (value) => { + assert.deepEqual(value, { ...input, metadata }); + validated = true; + }, + }); + assert.equal(validated, true); +}); + +test("invalid title or release impact on an active batch remains a failure", async () => { + await assert.rejects( + checkQueueTitle(input, { + api: async () => open, + readMetadata: () => ({}), + validate: async () => { + throw new Error("Invalid title"); + }, + }), + /Invalid title/, + ); +}); + +test("an API outage during the race check cannot turn failure into success", async () => { + let reads = 0; + await assert.rejects( + checkQueueTitle(input, { + api: async () => { + if (++reads === 1) return open; + throw new Error("API unavailable"); + }, + readMetadata: () => { + throw missing; + }, + }), + /API unavailable/, + ); +}); + +test("unknown API state and invalid event SHAs fail closed", async () => { + await assert.rejects( + checkQueueTitle(input, { api: async () => ({}) }), + /current queue PR state/, + ); + await assert.rejects( + checkQueueTitle({ ...input, sha: "main" }), + /Exact batch SHA/, + ); +}); From 75f90576c48964ee64dc2adf47d7b74f9ef0e7b1 Mon Sep 17 00:00:00 2001 From: tignear Date: Fri, 16 Oct 2026 07:18:15 +0900 Subject: [PATCH 15/16] ci: separate independent PR policy checks with queue scopes --- .mergify.yml | 42 ++++++++++++++++++++++++++++++++-- CONTRIBUTING.md | 17 +++++++++++--- scripts/mergify.test.mjs | 49 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 102 insertions(+), 6 deletions(-) diff --git a/.mergify.yml b/.mergify.yml index b3d03d77fda..cd140ab4431 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -1,12 +1,50 @@ # yaml-language-server: $schema=https://docs.mergify.com/mergify-configuration-schema.json # Keep ordinary PR checks focused; validate combined trees on queue draft PRs. merge_queue: - # Keep combined-tree validation across categories sharing a base branch. - mode: serial + # Independent scopes advance separately; overlapping changes stay ordered. + mode: parallel max_parallel_checks: 5 queued_label: queued dequeued_label: dequeued +# Keep the product dependency graph together. Only these standalone PR-policy +# validators are independent of Veryl/compiler changes; unknown paths stay core. +scopes: + source: + files: + core: + include: + - "**" + exclude: + - .github/workflows/pr-title.yml + - scripts/check-pr-title.mjs + - scripts/check-pr-title.test.mjs + - scripts/check-pr-release-impact.mjs + - scripts/check-pr-release-impact.test.mjs + - scripts/check-mergify-batch.mjs + - scripts/check-mergify-batch.test.mjs + - scripts/check-mergify-queue-title.mjs + - scripts/check-mergify-queue-title.test.mjs + pr-policy: + include: + - .github/workflows/pr-title.yml + - scripts/check-pr-title.mjs + - scripts/check-pr-title.test.mjs + - scripts/check-pr-release-impact.mjs + - scripts/check-pr-release-impact.test.mjs + - scripts/check-mergify-batch.mjs + - scripts/check-mergify-batch.test.mjs + - scripts/check-mergify-queue-title.mjs + - scripts/check-mergify-queue-title.test.mjs + capacities: + core: 2 + pr-policy: 1 + barrier_files: + include: + - .mergify.yml + - release-please-config.json + - VERSION + queue_rules: - name: integration batch_size: 1 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8ac016de46e..fd3e085ed8d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -72,8 +72,8 @@ Pull requests use `scripts/ci-changes.mjs` to select jobs and scope Rust tests by affected crates. Windows and ARM64 checks run in Mergify queue draft PRs, legacy merge groups, and daily/manual full runs. Queue drafts run the full Rust workspace when Rust is affected. Mergify checks up to five batches concurrently -across three queue rules, using serial mode to preserve combined-tree validation -between categories targeting the same base branch: +across three queue rules. Parallel mode separates independent file scopes while +retaining combined-tree validation for overlapping scopes: | Queue | PR heads | Batch size | Maximum collection wait | | --- | --- | --- | --- | @@ -86,7 +86,18 @@ commands. The existing `merge-ready` rule selects the matching queue without changing which PRs may auto-merge; manual-review dependency groups still require an explicit merge request. All three queues retain the same GitHub protections, queue validation, title checks, release hold, and release authorization gate. -These categories control batching, not independence or separate runner capacity. +Queue categories control batch sizes; file scopes control independence. The +`pr-policy` scope contains only the title workflow and its standalone title, +release-impact, and batch validators. Everything else (including unknown paths, +Rust dependencies, Veryl, NAPI, and feature changes) shares `core`. This lets a +PR-title repair advance without inheriting a speculative Veryl update, while +compiler and dependency changes still validate together. Mixed PRs share both +scopes. Core is capped at two concurrent batches and PR policy at one, within +the global five-batch ceiling; these are batch limits, not runner counts. +Changes to `.mergify.yml`, `release-please-config.json`, or `VERSION` are barriers, requiring +ordering across both scopes. Extend the narrow policy allowlist only after +checking its runtime dependencies. Scopes do not change CI job selection. +See [Mergify queue modes](https://docs.mergify.com/merge-queue/queue-modes/). The separate lydite proof/editor gates run on queue drafts rather than ordinary PRs; develop pushes, weekly runs, and manual dispatch remain enabled. diff --git a/scripts/mergify.test.mjs b/scripts/mergify.test.mjs index 6c8f38834ec..a80acaac1a2 100644 --- a/scripts/mergify.test.mjs +++ b/scripts/mergify.test.mjs @@ -14,7 +14,7 @@ const queues = queueConfig .map((block) => ({ name: block.split("\n")[0], block })); test("all queue categories preserve combined-tree validation and merge protections", () => { - assert.match(queueConfig, /mode: serial/); + assert.match(queueConfig, /mode: parallel/); assert.match(queueConfig, /max_parallel_checks: 5/); assert.deepEqual( queues.map((queue) => queue.name), @@ -130,3 +130,50 @@ test("Renovate preserves the manually reviewed compatibility group", () => { rules.findLastIndex((rule) => rule.labels?.includes("merge-ready")), ); }); + +test("PR-policy repairs are independent of Veryl while dependencies and features overlap", () => { + const scopes = queueConfig.split("scopes:\n")[1].split("queue_rules:\n")[0]; + const core = scopes.split(" core:\n")[1].split(" pr-policy:")[0]; + const policy = scopes + .split(" pr-policy:\n")[1] + .split(" capacities:")[0]; + assert.match(core, /include:\n - "\*\*"/); + const paths = (block) => + [...block.matchAll(/^ - ([^"\n]+)$/gm)].map((m) => m[1]); + const excluded = paths(core.split(" exclude:")[1]); + const included = paths(policy); + assert.deepEqual(excluded, included); + // These scopes deliberately use exact paths, avoiding an expanding glob that + // could silently classify new runtime-dependent scripts as independent. + for (const path of included) assert.doesNotMatch(path, /[?*{}\[\]]/); + function assigned(files) { + return [ + files.some((file) => !excluded.includes(file)) && "core", + files.some((file) => included.includes(file)) && "pr-policy", + ].filter(Boolean); + } + const repair = [ + ".github/workflows/pr-title.yml", + "scripts/check-mergify-queue-title.mjs", + "scripts/check-mergify-queue-title.test.mjs", + ]; + assert.deepEqual(assigned(repair), ["pr-policy"]); + for (const file of [ + "Cargo.lock", + "Cargo.toml", + "rust-toolchain.toml", + "crates/celox/src/lib.rs", + "packages/celox/package.json", + "pnpm-lock.yaml", + "scripts/ci-changes.mjs", + ".github/workflows/ci.yml", + "new-component/unknown.rs", + ]) + assert.deepEqual(assigned([file]), ["core"], file); + assert.deepEqual(assigned([...repair, "Cargo.lock"]), ["core", "pr-policy"]); + assert.match(scopes, /capacities:\n core: 2\n pr-policy: 1/); + for (const file of [".mergify.yml", "release-please-config.json", "VERSION"]) + assert.ok( + scopes.split(" barrier_files:")[1].includes(` - ${file}\n`), + ); +}); From 4e92dbd770717680c02fa5f93955068c694de727 Mon Sep 17 00:00:00 2001 From: tignear Date: Fri, 16 Oct 2026 07:20:24 +0900 Subject: [PATCH 16/16] ci: prioritize lightweight validated pull requests --- .mergify.yml | 11 +++++++++++ CONTRIBUTING.md | 10 +++++++++- scripts/mergify.test.mjs | 17 +++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/.mergify.yml b/.mergify.yml index cd140ab4431..6046208f72a 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -45,6 +45,17 @@ scopes: - release-please-config.json - VERSION +# Use the actual change-based CI result, not the PR title or author, to prefer +# lightweight changes. Scope isolation handles independent running batches. +priority_rules: + - name: Lightweight validated changes first + conditions: + - check-success = Lint & Format + - check-skipped = Rust Test & NAPI Build + - check-skipped = JS Test (Ubuntu) + priority: high + allow_checks_interruption: false + queue_rules: - name: integration batch_size: 1 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fd3e085ed8d..674406b86fc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -97,7 +97,15 @@ the global five-batch ceiling; these are batch limits, not runner counts. Changes to `.mergify.yml`, `release-please-config.json`, or `VERSION` are barriers, requiring ordering across both scopes. Extend the narrow policy allowlist only after checking its runtime dependencies. Scopes do not change CI job selection. -See [Mergify queue modes](https://docs.mergify.com/merge-queue/queue-modes/). +PRs whose source CI passed lint and skipped both the Rust/NAPI aggregate and +Ubuntu JS tests receive high queue priority. This prioritizes lightweight work +using the actual CI classification, including docs and standalone scripts, +rather than a `ci:` title or bot identity. Other PRs retain medium priority. +Running checks are not interrupted: independent scopes can progress separately, +but overlapping work already being tested and barriers still impose ordering. +This does not prioritize jobs inside GitHub Actions or preempt occupied runners. +See [Mergify priorities](https://docs.mergify.com/merge-queue/priority/) and +[Mergify queue modes](https://docs.mergify.com/merge-queue/queue-modes/). The separate lydite proof/editor gates run on queue drafts rather than ordinary PRs; develop pushes, weekly runs, and manual dispatch remain enabled. diff --git a/scripts/mergify.test.mjs b/scripts/mergify.test.mjs index a80acaac1a2..7620bb8807d 100644 --- a/scripts/mergify.test.mjs +++ b/scripts/mergify.test.mjs @@ -177,3 +177,20 @@ test("PR-policy repairs are independent of Veryl while dependencies and features scopes.split(" barrier_files:")[1].includes(` - ${file}\n`), ); }); + +test("lightweight queue priority requires actual skipped product checks and successful lint", () => { + const priority = queueConfig + .split("priority_rules:\n")[1] + .split("queue_rules:\n")[0]; + const conditions = [...priority.matchAll(/^ - (.+)$/gm)].map( + (m) => m[1], + ); + assert.deepEqual(conditions, [ + "check-success = Lint & Format", + "check-skipped = Rust Test & NAPI Build", + "check-skipped = JS Test (Ubuntu)", + ]); + assert.match(priority, /priority: high/); + assert.match(priority, /allow_checks_interruption: false/); + assert.doesNotMatch(priority, /label =|head ~=|title ~=/); +});