Files
orca/config/scripts/git-pull-request-diff-base.mjs
T
Neil a7ae68fc6f ci: full checks on main pushes, changed-file lint on PRs, Slack alert when main breaks (#37282)
* ci: full checks on main pushes, changed-file lint on PRs, Slack alert when main breaks

PR Checks now also runs on every push to main, with each commit in its own
concurrency group so main runs never cancel one another. On a push the path
router gets an empty diff, which already fails closed to every job, and the
input-scoped steps (localization extraction, VM rollback replay, orcad smoke)
run in full. Advisory E2E lanes stay PR-only.

On PRs the per-file passes (root oxlint, JS-plugin oxlint, anti-slop, ast-grep
and oxfmt) check only the changed paths. Everything is checked when the diff
cannot be resolved, a lint toolchain input changes (oxlint/oxfmt/ast-grep
configs and plugins, package.json, the lockfile, .gitignore, pr.yml), or more
than 1500 paths change. Whole-program checks stay unscoped.

A new workflow follows completed main runs and posts to the release Slack
webhook only when main turns red, and once when it turns green again.

* ci: alert once per main health streak and tolerate a malformed Slack mapping
2026-11-01 20:30:03 -08:00

38 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { execFileSync } from 'node:child_process'
import process from 'node:process'
import { pathToFileURL } from 'node:url'
export function selectPullRequestDiffBase(requestedBase, headParents, eventName) {
if (eventName === 'pull_request' && headParents.length >= 2) {
return headParents[0]
}
// A main push has no payload base; its first parent is the main tip it landed on.
if (eventName === 'push' && !requestedBase && headParents.length >= 1) {
return headParents[0]
}
return requestedBase
}
export function resolvePullRequestDiffBase(
root,
requestedBase,
eventName = process.env.GITHUB_EVENT_NAME
) {
const [, ...headParents] = execFileSync('git', ['rev-list', '--parents', '-n', '1', 'HEAD'], {
cwd: root,
encoding: 'utf8'
})
.trim()
.split(/\s+/)
return selectPullRequestDiffBase(requestedBase, headParents, eventName)
}
// Print shared gate’s resolved base so workflow shell gates can use merge-ref HEAD^1 instead of requiring full history for payload merge-base.
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
const resolved = resolvePullRequestDiffBase(process.cwd(), process.argv[2])
if (!resolved) {
throw new Error('No diff base: pass the pull request base SHA, or run on a merge ref.')
}
process.stdout.write(`${resolved}\n`)
}