From aa183e677d885e67942cd18f32069f1904006542 Mon Sep 17 00:00:00 2001 From: tignear Date: Thu, 8 Oct 2026 09:56:03 +0900 Subject: [PATCH] ci: validate each change once instead of three times Two weeks of CI (709 runs, ~45,000 job-minutes) showed each change tested on its pull request, again in the merge group, and again on the push to master or develop, with change detection selecting nearly every job each time. - Drop the push trigger. The merge group validated the exact tree that lands (~9,700 job-minutes). Daily full runs keep branch caches current. - Run Windows and ARM64 jobs in merge groups and full runs, not on pull requests (~4,500 job-minutes). Only 1 of 336 pull request runs failed on those jobs alone; skipped jobs satisfy their required checks. - Sync master into develop daily instead of on every master push. The sync pull request ran CI 60 times (~4,200 job-minutes). --- .github/workflows/ci.yml | 14 +++++++------ .github/workflows/sync-develop.yml | 15 +++++--------- CONTRIBUTING.md | 17 +++++++++++++++- scripts/check-sync-branch-head.test.mjs | 20 +++++++----------- scripts/ci-workflow.test.mjs | 27 +++++++++++++++++++++++++ 5 files changed, 63 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a3d6bbeabc7..ca133edf4ef 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. @@ -430,7 +430,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 @@ -467,7 +469,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 @@ -503,7 +505,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 @@ -590,7 +592,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 2ffcaee4918..426f25b1b03 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 8cda5ce2fbf..cac9613e7ad 100644 --- a/scripts/ci-workflow.test.mjs +++ b/scripts/ci-workflow.test.mjs @@ -178,3 +178,30 @@ test("artifact consumers wait for their producer rather than the Rust test gate" assert.match(browser, /needs: \[changes, napi-wasm\]/); 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); + } +});