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/.mergify.yml b/.mergify.yml index 1769ad21d21..6046208f72a 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -1,12 +1,90 @@ # 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: + # 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 + +# 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: 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 +100,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..260c0449c3a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -68,11 +68,76 @@ 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 -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. Parallel mode separates independent file scopes while +retaining combined-tree validation for overlapping scopes: + +| 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. +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. +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. The `Queue validation` merge condition requires those pre-merge checks to pass; diff --git a/Cargo.lock b/Cargo.lock index 531a2719884..ac036eae78a 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", @@ -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", @@ -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]] @@ -3544,7 +3544,7 @@ checksum = "42ffa149f6aa81b58a5b3011d01a857c4ed12c7a732d2c51947a4c7c692185f0" dependencies = [ "globset", "include-flate", - "sha2 0.11.0", + "sha2 0.11.1", "walkdir", ] @@ -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]] @@ -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", @@ -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/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"; }; }; 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" 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 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/); +}); diff --git a/scripts/mergify.test.mjs b/scripts/mergify.test.mjs index c8108511f33..7620bb8807d 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: parallel/); + 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", + ), ); }); @@ -47,3 +130,67 @@ 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`), + ); +}); + +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 ~=/); +});