diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 21ff7d2cb0b..147db8242b2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,8 @@ name: CI +# No push trigger: the merge queue already validated the exact tree that lands +# on master or develop. The daily full runs keep those branches' caches warm. on: - push: - branches: [master, develop] pull_request: merge_group: # Full validation also runs without a change filter, including quiet periods. @@ -443,7 +443,9 @@ jobs: arm64-backend: name: ARM64 Backend Test needs: changes - if: always() && (needs.changes.result != 'success' || needs.changes.outputs.rust == 'true') + # Platform jobs run in merge groups and full runs, not on pull requests. + # They almost never fail alone; dispatch ci.yml on a branch to run them. + if: always() && github.event_name != 'pull_request' && (needs.changes.result != 'success' || needs.changes.outputs.rust == 'true') runs-on: ubuntu-26.04-arm steps: - uses: actions/checkout@v7 @@ -480,7 +482,7 @@ jobs: napi-windows: name: NAPI Build (Windows) needs: changes - if: always() && (needs.changes.result != 'success' || needs.changes.outputs.napi == 'true') + if: always() && github.event_name != 'pull_request' && (needs.changes.result != 'success' || needs.changes.outputs.napi == 'true') runs-on: windows-latest steps: - uses: actions/checkout@v7 @@ -516,7 +518,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() && github.event_name != 'pull_request' && (needs.changes.result != 'success' || needs.changes.outputs.napi_arm64 == 'true') runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 @@ -603,7 +605,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() && github.event_name != 'pull_request' && (needs.changes.result != 'success' || needs.changes.outputs.javascript == 'true') runs-on: windows-latest steps: - uses: actions/checkout@v7 diff --git a/.github/workflows/sync-develop.yml b/.github/workflows/sync-develop.yml index c634d5161fd..d4524d1ff8b 100644 --- a/.github/workflows/sync-develop.yml +++ b/.github/workflows/sync-develop.yml @@ -1,11 +1,11 @@ name: Sync Develop on: - push: - branches: [master] - pull_request_target: - types: [closed] - branches: [develop] + # Sync once a day rather than on every master push. Each update re-runs the + # synchronization pull request's CI, and develop only needs master daily. + # This runs early enough to merge before the develop full CI at 02:43 UTC. + schedule: + - cron: "7 22 * * *" workflow_dispatch: concurrency: @@ -17,11 +17,6 @@ permissions: {} jobs: sync: name: Merge master into develop - if: >- - github.event_name != 'pull_request_target' || - (github.event.pull_request.merged == true && - github.event.pull_request.head.ref == 'integration/master-to-develop' && - github.event.pull_request.head.repo.full_name == github.repository) runs-on: ubuntu-latest env: SYNC_BRANCH: integration/master-to-develop diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 18ec9043f34..018cbc335a4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -62,7 +62,22 @@ minimum safety net, not the definition of validation completeness. ## CI coverage and cadence -Pull requests and pushes use `scripts/ci-changes.mjs` to select jobs: +Pull requests and merge groups use `scripts/ci-changes.mjs` to select jobs. +Each change is validated where it matters rather than repeatedly: + +- Pull requests run the Linux jobs (lint, Rust tests, Linux and WASI NAPI, JS + on Ubuntu, Playground). Windows NAPI/JS and the ARM64 NAPI and backend jobs + are skipped there, which their required checks accept, and run in the merge + group instead. They rarely fail when the Linux jobs pass. Dispatch `ci.yml` on + a branch to run them before queueing. +- The merge group validates the exact tree that lands, so pushes to `master` and + `develop` do not run CI again. Daily full runs keep those branches' build + caches current for pull requests. +- `sync-develop.yml` opens or updates the master-to-develop synchronization pull + request once a day (22:07 UTC) rather than on every master push. Dispatch it + to sync sooner. + +Job selection: - Rust tests, benches, the common test suite, benchmark crates, VPI, the separate wasm binding crate, and lydite retain Rust checks without triggering NAPI and diff --git a/scripts/check-sync-branch-head.test.mjs b/scripts/check-sync-branch-head.test.mjs index ccece2cc946..4bae8b13c96 100644 --- a/scripts/check-sync-branch-head.test.mjs +++ b/scripts/check-sync-branch-head.test.mjs @@ -10,23 +10,17 @@ const guard = fileURLToPath( new URL("./check-sync-branch-head.sh", import.meta.url), ); -test("sync workflow retries after its preserved pull request lands", () => { +// A daily run also retries after a preserved (hand-resolved) synchronization +// lands, without re-syncing, and re-running its CI, on every master push. +test("sync workflow runs daily instead of on every master push", () => { const workflow = readFileSync( new URL("../.github/workflows/sync-develop.yml", import.meta.url), "utf8", ); - assert.match( - workflow, - /pull_request_target:\n\s+types: \[closed\]\n\s+branches: \[develop\]/, - ); - assert.match( - workflow, - /github\.event\.pull_request\.head\.ref == 'integration\/master-to-develop'/, - ); - assert.match( - workflow, - /github\.event\.pull_request\.head\.repo\.full_name == github\.repository/, - ); + const triggers = workflow.match(/^on:\n([\s\S]*?)\n\S/m)[1]; + assert.match(triggers, /schedule:\n\s+- cron: "7 22 \* \* \*"/); + assert.match(triggers, /workflow_dispatch:/); + assert.doesNotMatch(triggers, /^\s+(push|pull_request_target):/m); }); test("sync branch guard preserves unresolved branch work", (t) => { diff --git a/scripts/ci-workflow.test.mjs b/scripts/ci-workflow.test.mjs index 95792f40659..03f76c1d55f 100644 --- a/scripts/ci-workflow.test.mjs +++ b/scripts/ci-workflow.test.mjs @@ -213,6 +213,33 @@ test("artifact consumers wait for their producer rather than the Rust test gate" assert.match(browser, /name: napi-wasm32-wasi/); }); +test("landed commits are not re-validated by a push run", () => { + const triggers = workflow.match(/^on:\n([\s\S]*?)\n\S/m)[1]; + assert.doesNotMatch(triggers, /^\s+push:/m); + assert.match(triggers, /^\s+merge_group:/m); + assert.match(triggers, /^\s+schedule:/m); +}); + +test("platform jobs run in merge groups and full runs, not on pull requests", () => { + const platform = [ + "arm64-backend", + "napi-windows", + "napi-linux-arm64", + "js-windows", + ]; + for (const name of platform) { + assert.match( + job(name), + /\n if: always\(\) && github\.event_name != 'pull_request' && \(/, + name, + ); + } + // Linux jobs still give pull requests their feedback. + for (const name of ["lint", "rust-tests", "napi-linux", "js-ubuntu", "rust"]) { + assert.doesNotMatch(job(name), /github\.event_name != 'pull_request'/, name); + } +}); + test("full runs on long-lived branches report every job's result", () => { const report = job("report-full-validation"); const jobs = [...workflow.split(/^jobs:\n/m)[1].matchAll(/^ ([\w-]+):\n/gm)]