Files
orca/config/scripts/git-binary-compatibility-workflow.test.mjs
T
Neil 13b10e0b54 ci: cut PR wall clock by caching what CI recomputes every run (#15211)
None of these change what CI checks — they remove work the runners
repeated on every PR.

- install-node-dependencies installed with --no-frozen-lockfile, so every
  job re-resolved the graph against the registry to recompute what the
  lockfile already pins. Measured at ~62 MB of packument metadata per job;
  the pnpm store cache does not cover the metadata cache, so this was paid
  ~39 times per run. The `git diff` guard that made the re-resolution
  redundant stays.
- --ignore-scripts leaves node-pty with no build/Release, so
  ensure-native-runtime node-gyp-compiled it in every job asking for a
  runtime. Cache the build under an ABI-bound key (runtime, resolved Node
  version, node-pty patch) with no restore-keys, since a partial match is
  exactly the mismatched build that would be recompiled anyway.
- The four fetch-depth: 0 checkouts pulled full history including every
  historical blob (blobs are ~89% of this repo's pack). They only need the
  commit graph for a merge-base diff, so fetch them blobless. Measured
  30-43s each today versus 8s for the shallow checkouts. One of them,
  e2e-paths, gates the entire E2E chain.
- E2E jobs ordered setup-node before pnpm, which meant setup-node could not
  find the store and no E2E job cached dependencies at all. Reorder and
  cache; this sits on the critical path in both the build job and each
  shard.
- git_compatibility rebuilt Git 2.25.5 from a pinned tarball on every PR.
  Cache the build; the sha256 assertion still guards the miss path.
- typecheck ran three independent tsc passes back to back and discarded the
  .tsbuildinfo each project already emits. Run them concurrently and cache
  the incremental state.
- package (windows) built the electron-vite targets serially via
  build:release. Use a :parallel variant that overlaps them, matching what
  the Linux package job already packages and smoke-tests from.

Contract tests cover each new cache's ordering and key so none of them can
silently start serving a stale or ABI-mismatched artifact.
2026-08-17 19:20:13 -07:00

44 lines
2.2 KiB
JavaScript

import { readFileSync } from 'node:fs'
import { parse } from 'yaml'
import { describe, expect, it } from 'vitest'
describe('Git binary compatibility PR gate', () => {
it('runs the real-binary contract at each compatibility boundary', () => {
const workflow = parse(readFileSync('.github/workflows/pr.yml', 'utf8'))
const step = workflow.jobs.git_compatibility.steps.find(
(candidate) => candidate.name === 'Verify Git binary compatibility matrix'
)
expect(step?.run).toContain('git-2.25.5.tar.gz')
// Why asserted: the sha256 check only runs on the build path, so a cached binary
// must come from a key that pins the same version the tarball line declares.
expect(step?.run).toContain('if [ ! -x "$source/git" ]; then')
expect(step?.run).toContain('41662c52fc16fec4963bfc41075e71f8ead6b5e386797eb6f9a1111ff95a8ddf')
expect(step?.run).toContain('ORCA_GIT_COMPAT_BINARY="$source/git"')
expect(step?.run).toContain('alpine/git:edge-2.38.1|2.38.1')
expect(step?.run).toContain('alpine/git:v2.49.1|2.49.1')
expect(step?.run).toContain('ORCA_GIT_COMPAT_IMAGE="$image"')
expect(step?.run).toContain('src/shared/git-binary-compatibility.test.ts')
expect(step?.run).toContain('-j"$(nproc)"')
expect(step?.run).toContain('pids+=("$!")')
expect(step?.run).toContain('wait "$pid" || status=1')
})
it('restores the baseline Git build before the matrix runs', () => {
const workflow = parse(readFileSync('.github/workflows/pr.yml', 'utf8'))
const steps = workflow.jobs.git_compatibility.steps
const cacheIndex = steps.findIndex((step) => step.name === 'Cache baseline Git build')
const matrixIndex = steps.findIndex(
(step) => step.name === 'Verify Git binary compatibility matrix'
)
expect(cacheIndex).toBeGreaterThanOrEqual(0)
expect(cacheIndex).toBeLessThan(matrixIndex)
// The cached path and the build path must be the same directory or the guard
// above would rebuild on every run while still reporting a cache hit.
expect(steps[cacheIndex].with.path).toBe('~/.cache/orca-git-compat/git-2.25.5')
expect(steps[matrixIndex].run).toContain('source="$HOME/.cache/orca-git-compat/git-2.25.5"')
expect(steps[cacheIndex].with.key).toContain('2.25.5')
})
})