Files
orca/config/scripts/pr-code-change-scope-format-route.test.mjs
T
Neil 92eb9790bc ci: fail the static job on unformatted files (#30863)
* ci: fail the static job on unformatted files

Runs oxfmt --check over the same tree pnpm format writes (~2s), and makes the
pre-commit hook format markdown and YAML so it covers what CI now checks.

* ci: route docs-only and workflow-only diffs through the formatting check

The format check reads the whole tree, so a diff that skipped the static job
could land drift that fails every later PR. Any changed file oxfmt formats now
selects static analysis (not typecheck or units), like the mobile-only route.
The path detector checks out .oxfmtrc.json for its ignores. The hook no longer
fails a commit whose only matches oxfmt ignores (lockfiles).
2026-10-19 16:08:52 -07:00

29 lines
1.1 KiB
JavaScript

import { readFileSync } from 'node:fs'
import { expect, it } from 'vitest'
import { parse } from 'yaml'
import { classifyPrJobs } from './pr-code-change-scope.mjs'
// The formatting check reads the whole tree, so a diff that skipped it would land drift that then
// fails every later PR's merge ref.
it.each(['README.md', '.github/ISSUE_TEMPLATE/bug.yml', '.github/workflows/mobile.yml'])(
'runs static analysis, and only it, for a %s diff the formatter reads',
(file) => {
expect(classifyPrJobs([file])).toMatchObject({
should_run: false,
static_analysis: true,
typecheck: false,
test: false
})
}
)
it('leaves paths the formatter ignores out of static analysis', () => {
expect(classifyPrJobs(['cloud/apps/relay/README.md']).static_analysis).toBe(false)
expect(classifyPrJobs(['docs/assets/logo.png']).static_analysis).toBe(false)
})
it('checks out the formatter config the detector reads its ignores from', () => {
const workflow = parse(readFileSync('.github/workflows/pr.yml', 'utf8'))
expect(workflow.jobs.code_paths.steps[0].with['sparse-checkout']).toContain('/.oxfmtrc.json')
})