mirror of
https://github.com/stablyai/orca.git
synced 2026-09-30 16:02:56 +00:00
Every changed-path gate asked git for `--merge-base "$BASE_SHA" "$HEAD_SHA"`, which needs the event payload's base SHA to be in the local graph. That is the only reason two jobs cloned all 8127 refs' history. On a pull_request checkout HEAD is already the merge commit, so its first parent is the base side and no merge base has to be computed. config/scripts/git-pull-request-diff-base.mjs resolved that for the two Node gates; the workflow's inline gates now use the same helper through a small CLI rather than open-coding it. code_paths gates all 22 jobs, so its checkout is charged to the start of every one of them: measured 20.7s to 1.6s, keeping blob:none because its sparse tree is ~7 files and leaves no blobs to refetch. Static analysis drops the filter instead, since populating all 30,226 files makes blob:none force a second promisor fetch: 23s to ~11s. Verified on a real merge ref. At depth 50 the old and new forms produce identical changed-file sets. At depth 2 the new form still works and the old one fails with `fatal: bad object`, which is the failure a stale base would have caused once the checkout stopped being complete. Also drops the dead resolveBase + merge-base prelude in the changed-code gate, whose result resolvePullRequestDiffBase already discarded on every PR.
60 lines
2.3 KiB
JavaScript
60 lines
2.3 KiB
JavaScript
import { readFileSync } from 'node:fs'
|
|
import { expect, it } from 'vitest'
|
|
import { parse } from 'yaml'
|
|
import { affectsLocalizationExtraction } from './localization-extraction-change-scope.mjs'
|
|
|
|
it.each([
|
|
'src/renderer/src/components/Example.tsx',
|
|
'src/main/notifications.ts',
|
|
'src/renderer/src/i18n/locales/en.json',
|
|
'config/i18next.config.ts',
|
|
'config/scripts/verify-localization-extraction.mjs',
|
|
'config/scripts/localization-extraction-change-scope.mjs',
|
|
'config/patches/i18next-cli.patch',
|
|
'package.json',
|
|
'pnpm-lock.yaml',
|
|
'pnpm-workspace.yaml',
|
|
'tsconfig.json',
|
|
'config/tsconfig.web.json',
|
|
'.npmrc',
|
|
'.pnpmfile.cjs',
|
|
'.github/workflows/pr.yml',
|
|
'.github/actions/install-node-dependencies/action.yml'
|
|
])('retains extraction when an input changes: %s', (path) => {
|
|
expect(affectsLocalizationExtraction([path])).toBe(true)
|
|
})
|
|
|
|
it('avoids extraction for unrelated CI, documentation, and native changes', () => {
|
|
expect(
|
|
affectsLocalizationExtraction([
|
|
'.github/workflows/e2e.yml',
|
|
'config/scripts/run-ssh-docker-e2e.mjs',
|
|
'docs/reference/ci-runner-efficiency.md',
|
|
'native/windows-registry/src/addon.cc'
|
|
])
|
|
).toBe(false)
|
|
})
|
|
|
|
it('preserves deleted and renamed inputs and falls back to extraction on detection failure', () => {
|
|
const workflow = parse(
|
|
readFileSync(new URL('../../.github/workflows/pr.yml', import.meta.url), 'utf8')
|
|
)
|
|
const step = workflow.jobs.static_analysis.steps.find(
|
|
(candidate) => candidate.name === 'Verify localization extraction'
|
|
)
|
|
expect(step.env).toEqual({
|
|
BASE_SHA: '${{ github.event.pull_request.base.sha }}'
|
|
})
|
|
// The base side comes from the merge ref's first parent, so the gate needs no merge base and
|
|
// works on a shallow checkout. The payload head SHA is no longer read: HEAD is the merged tree
|
|
// the gate is actually deciding about.
|
|
expect(step.run).toContain('node config/scripts/git-pull-request-diff-base.mjs "$BASE_SHA"')
|
|
expect(step.run).toContain('git diff --name-only --no-renames -z "$DIFF_BASE" HEAD')
|
|
expect(step.run).not.toContain('--diff-filter')
|
|
expect(step.run).toContain('&& [ "$scope" = false ]; then')
|
|
expect(step.run).toMatch(/else\s+pnpm run verify:localization-extraction\s+fi/)
|
|
expect(
|
|
affectsLocalizationExtraction(['src/old-translations.ts', 'docs/moved-translations.ts'])
|
|
).toBe(true)
|
|
})
|