mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-29 03:15:05 +01:00
Merge remote-tracking branch 'origin/main' into cso-precision-incidental
This commit is contained in:
commit
be591da3e9
38 files changed
+2651
-1969
No files matched your search
@@ -262,7 +262,7 @@ test.each([
|
||||
[reviewStartLead, reviewStartLabels, 2],
|
||||
['D1 — No design doc found: run /office-hours before the review?', ['Run /office-hours now', 'Skip — proceed with review (Recommended)'], 2],
|
||||
[reviewStartLead, ['Skip — standard review', 'Run /office-hours first'], 1],
|
||||
...['Example: ', 'If approved: ', 'Do not ', '> ', ' ', '"', '`'].map(prefix => [prefix + reviewStartLead, reviewStartLabels, 1]),
|
||||
...['Example: ', 'If approved: ', 'Do not ', '> ', ' ', '"', '`'].map(prefix => [prefix + reviewStartLead, reviewStartLabels, 1] as const),
|
||||
['D1 — Discuss /office-hours in our documentation?', reviewStartLabels, 1],
|
||||
['D1 — Run /office-hours instead of this review?', reviewStartLabels, 1],
|
||||
[reviewStartLead, ['Run /office-hours first', 'Skip'], 1],
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* Version Gate (scripts/compare-pr-version.ts). Hard rule 1 requires VERSION
|
||||
* above the base, which dependabot can never satisfy, so a dependabot PR that
|
||||
* touches only dependency manifests, lockfiles and dependabot config is exempt.
|
||||
* Every other author or file keeps the rule.
|
||||
*/
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
import * as fs from 'node:fs';
|
||||
import * as os from 'node:os';
|
||||
import * as path from 'node:path';
|
||||
|
||||
const ROOT = path.resolve(import.meta.dir, '..');
|
||||
const SCRIPT = path.join(ROOT, 'scripts', 'compare-pr-version.ts');
|
||||
|
||||
function gate(env: { PR_VERSION: string; PR_AUTHOR?: string; PR_CHANGED_FILES?: string }) {
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'version-gate-'));
|
||||
try {
|
||||
const next = path.join(dir, 'next.json');
|
||||
fs.writeFileSync(next, JSON.stringify({ version: '1.91.117.0', base_version: '1.91.116.0', claimed: [{ pr: 3236, branch: 'fix-wave-5', version: '1.91.117.0' }] }));
|
||||
const run = Bun.spawnSync([process.execPath, 'run', SCRIPT, next, '3227'], {
|
||||
env: { PATH: process.env.PATH ?? '', ...env },
|
||||
timeout: 30_000,
|
||||
stdout: 'pipe',
|
||||
stderr: 'pipe',
|
||||
});
|
||||
return { code: run.exitCode, out: run.stdout.toString() + run.stderr.toString() };
|
||||
} finally {
|
||||
fs.rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
}
|
||||
|
||||
const DEPENDABOT = 'dependabot[bot]';
|
||||
|
||||
describe('version gate: dependabot dependency-manifest exemption', () => {
|
||||
test('an unbumped VERSION still fails for a human author', () => {
|
||||
const result = gate({ PR_VERSION: '1.91.116.0', PR_AUTHOR: 'garrytan', PR_CHANGED_FILES: 'package.json\nbun.lock' });
|
||||
expect(result.code).toBe(1);
|
||||
expect(result.out).toContain('::error::VERSION not bumped');
|
||||
});
|
||||
|
||||
test('a dependabot PR behind main that touches only manifests, lockfiles and dependabot config passes', () => {
|
||||
const files = ['package.json', 'bun.lock', 'lib/diagram-render/package.json', 'lib/diagram-render/bun.lock', '.github/dependabot.yml'].join('\n');
|
||||
const result = gate({ PR_VERSION: '1.91.106.0', PR_AUTHOR: DEPENDABOT, PR_CHANGED_FILES: files + '\n' });
|
||||
expect(result.code).toBe(0);
|
||||
expect(result.out).toContain('::notice::PR #3227 is a dependabot dependency update');
|
||||
expect(result.out).not.toContain('::error::');
|
||||
});
|
||||
|
||||
test('a dependabot PR with any other file keeps hard rule 1', () => {
|
||||
for (const other of ['scripts/compare-pr-version.ts', 'VERSION', '.github/workflows/version-gate.yml', 'evil-package.json', 'package.json.bak']) {
|
||||
const result = gate({ PR_VERSION: '1.91.116.0', PR_AUTHOR: DEPENDABOT, PR_CHANGED_FILES: `package.json\nbun.lock\n${other}` });
|
||||
expect(result.code).toBe(1);
|
||||
expect(result.out).toContain('::error::VERSION not bumped');
|
||||
}
|
||||
});
|
||||
|
||||
test('a missing file list or author keeps hard rule 1', () => {
|
||||
expect(gate({ PR_VERSION: '1.91.116.0', PR_AUTHOR: DEPENDABOT, PR_CHANGED_FILES: '' }).code).toBe(1);
|
||||
expect(gate({ PR_VERSION: '1.91.116.0', PR_AUTHOR: DEPENDABOT }).code).toBe(1);
|
||||
expect(gate({ PR_VERSION: '1.91.116.0', PR_CHANGED_FILES: 'package.json' }).code).toBe(1);
|
||||
});
|
||||
|
||||
test('a bumped dependabot VERSION goes through the collision rule as before', () => {
|
||||
const result = gate({ PR_VERSION: '1.91.117.0', PR_AUTHOR: DEPENDABOT, PR_CHANGED_FILES: 'package.json' });
|
||||
expect(result.code).toBe(1);
|
||||
expect(result.out).toContain('::error::VERSION collision');
|
||||
});
|
||||
|
||||
test('the workflow passes the PR author and its changed-file list to the gate', () => {
|
||||
const workflow = Bun.YAML.parse(fs.readFileSync(path.join(ROOT, '.github', 'workflows', 'version-gate.yml'), 'utf8')) as any;
|
||||
const step = workflow.jobs.check.steps.find((s: any) => s.name === 'Compare PR VERSION to next free slot');
|
||||
expect(step.env.PR_AUTHOR).toBe('${{ github.event.pull_request.user.login }}');
|
||||
expect(step.env.GH_TOKEN).toBe('${{ secrets.GITHUB_TOKEN }}');
|
||||
expect(step.run).toContain('pulls/${{ github.event.pull_request.number }}/files');
|
||||
expect(step.run).toContain('--paginate');
|
||||
expect(step.run).toContain('then PR_CHANGED_FILES=""; fi');
|
||||
expect(step.run).toContain('export PR_CHANGED_FILES');
|
||||
expect(workflow.jobs.check.permissions).toEqual({ contents: 'read', 'pull-requests': 'read' });
|
||||
});
|
||||
});
|
||||
@@ -1027,16 +1027,24 @@ describe('gstack-doctor: rescue refs, CLAUDE.md skill lists, Windows bash', () =
|
||||
const probe = (f: Fixture, inputs: Record<string, unknown>) => { const file = path.join(f.base, 'bash-probe.json'); write(file, JSON.stringify(inputs)); return file; };
|
||||
const GIT_BASH = 'C:/Program Files/Git/bin/bash.exe';
|
||||
|
||||
test('windows bash: on Windows the row names the resolved bash and what chose it; a refusal fails with BASH_UNAVAILABLE naming GSTACK_GIT_BASH; off Windows there is no row', () => {
|
||||
test('windows bash: on Windows the row names the resolved bash and what chose it', () => {
|
||||
const f = makeFixture();
|
||||
const found = doctor(f, [], { GSTACK_DOCTOR_PLATFORM: 'windows', GSTACK_DOCTOR_BASH_PROBE: probe(f, { exists: [GIT_BASH], gitExecPath: 'C:/Program Files/Git/mingw64/libexec/git-core' }) });
|
||||
expect(found.row('windows bash'), found.out).toEqual({ state: 'ok', detail: `${GIT_BASH} (chosen by git --exec-path)`, fix: '' });
|
||||
const override = doctor(f, [], { GSTACK_DOCTOR_PLATFORM: 'windows', GSTACK_GIT_BASH: 'D:\\tools\\bash.exe', GSTACK_DOCTOR_BASH_PROBE: probe(f, { exists: ['D:/tools/bash.exe', GIT_BASH] }) });
|
||||
expect(override.row('windows bash').detail).toBe('D:/tools/bash.exe (chosen by GSTACK_GIT_BASH)');
|
||||
});
|
||||
|
||||
test('windows bash: GSTACK_GIT_BASH and a different deprecated GSTACK_BASH warn naming both', () => {
|
||||
const f = makeFixture();
|
||||
const differ = doctor(f, [], { GSTACK_DOCTOR_PLATFORM: 'windows', GSTACK_GIT_BASH: 'D:/a/bash.exe', GSTACK_BASH: 'D:/b/bash.exe', GSTACK_DOCTOR_BASH_PROBE: probe(f, { exists: ['D:/a/bash.exe', 'D:/b/bash.exe'] }) });
|
||||
expect(differ.row('windows bash').state).toBe('warn');
|
||||
expect(differ.row('windows bash').detail).toContain('D:/a/bash.exe (chosen by GSTACK_GIT_BASH)');
|
||||
expect(differ.row('windows bash').detail).toContain('GSTACK_GIT_BASH (D:/a/bash.exe) and the deprecated GSTACK_BASH (D:/b/bash.exe) differ');
|
||||
});
|
||||
|
||||
test('windows bash: a refusal fails with BASH_UNAVAILABLE naming GSTACK_GIT_BASH; off Windows there is no row', () => {
|
||||
const f = makeFixture();
|
||||
const refused = doctor(f, [], { GSTACK_DOCTOR_PLATFORM: 'windows', GSTACK_DOCTOR_BASH_PROBE: probe(f, { exists: [], gitExecPath: null, which: { bash: 'C:/Windows/System32/bash.exe' } }) });
|
||||
const row = refused.row('windows bash');
|
||||
expect(row.state, refused.out).toBe('fail');
|
||||
|
||||
@@ -36,15 +36,16 @@ const CONFLICT_LINE = 'THROTTLE_SECONDS=3600 # 1 hour';
|
||||
* install sits one commit behind it, at the same tree without
|
||||
* bin/gstack-ff-update (an install that predates it), with VERSION 1.91.101.0.
|
||||
*/
|
||||
function makeFixture() {
|
||||
function makeFixture(source = ROOT) {
|
||||
const base = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'gstack-held-')));
|
||||
bases.push(base);
|
||||
const origin = path.join(base, 'origin.git');
|
||||
const work = path.join(base, 'work');
|
||||
execFileSync('git', ['clone', '-q', '--shared', ROOT, work], { timeout: 60_000 });
|
||||
execFileSync('git', ['clone', '-q', '--shared', source, work], { timeout: 60_000 });
|
||||
// A root commit of this tree: the checkout may be shallow, and a bare
|
||||
// origin refuses a shallow push.
|
||||
git(work, 'checkout', '-q', '--orphan', 'main');
|
||||
// origin refuses a shallow push. The clone already has a local main when
|
||||
// the source is on main (actions/checkout runs `checkout -B main` on a push).
|
||||
git(work, 'checkout', '-q', '--orphan', 'held-fixture');
|
||||
fs.writeFileSync(path.join(work, 'VERSION'), '1.91.101.0\n');
|
||||
fs.rmSync(path.join(work, 'bin', 'gstack-ff-update'), { force: true });
|
||||
git(work, 'add', '-A');
|
||||
@@ -59,7 +60,7 @@ function makeFixture() {
|
||||
git(work, 'commit', '-q', '-m', 'the fixed release');
|
||||
const fixed = git(work, 'rev-parse', 'HEAD');
|
||||
execFileSync('git', ['init', '-q', '--bare', '-b', 'main', origin], { timeout: 60_000 });
|
||||
git(work, 'push', '-q', origin, 'main');
|
||||
git(work, 'push', '-q', origin, 'HEAD:refs/heads/main');
|
||||
return { base, origin, held, fixed };
|
||||
}
|
||||
type Fx = ReturnType<typeof makeFixture>;
|
||||
@@ -126,6 +127,23 @@ describe.skipIf(process.platform === 'win32')('held-install recovery (Git Bash f
|
||||
expect(form('recovery-powershell')).toContain('d=$(mktemp -d)');
|
||||
});
|
||||
|
||||
for (const checkout of ['on main', 'detached with no branch'] as const) {
|
||||
test(`the fixture builds from a source checkout ${checkout}`, () => {
|
||||
const src = path.join(fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'gstack-held-src-'))), 'src');
|
||||
bases.push(path.dirname(src));
|
||||
execFileSync('git', ['clone', '-q', '--shared', ROOT, src], { timeout: 60_000 });
|
||||
if (checkout === 'on main') git(src, 'checkout', '-q', '-B', 'main');
|
||||
else {
|
||||
git(src, 'checkout', '-q', '--detach');
|
||||
for (const b of git(src, 'for-each-ref', '--format=%(refname:short)', 'refs/heads').split('\n').filter(Boolean)) git(src, 'branch', '-q', '-D', b);
|
||||
}
|
||||
const fx = makeFixture(src);
|
||||
expect(git(fx.origin, 'rev-parse', 'refs/heads/main')).toBe(fx.fixed);
|
||||
expect(git(fx.origin, 'rev-parse', `${fx.fixed}^`)).toBe(fx.held);
|
||||
expect(git(fx.origin, 'rev-list', '--max-parents=0', fx.fixed)).toBe(fx.held);
|
||||
}, 60_000);
|
||||
}
|
||||
|
||||
for (const state of ['clean', 'dirty', 'unmerged'] as const) {
|
||||
test(`a ${state} prefix-mode install reaches the fixed release; a planted symlink is never followed`, async () => {
|
||||
const fx = makeFixture();
|
||||
|
||||
@@ -50,4 +50,12 @@ describe("osv-scanner config wiring", () => {
|
||||
const page = fs.readFileSync(path.join(ROOT, "lib", "diagram-render", "dist", "diagram-render.html"), "utf8");
|
||||
expect(page).not.toMatch(/chokidar|FSWatcher/);
|
||||
});
|
||||
|
||||
test("the chokidar override keeps braces (GHSA-vfj7-8cjw-p6xm, no fixed release) out of lib/diagram-render", () => {
|
||||
const pkg = JSON.parse(fs.readFileSync(path.join(ROOT, "lib", "diagram-render", "package.json"), "utf8"));
|
||||
expect(pkg.overrides.chokidar).toMatch(/^4\./);
|
||||
const lock = fs.readFileSync(path.join(ROOT, "lib", "diagram-render", "bun.lock"), "utf8");
|
||||
expect(lock).toMatch(/"chokidar": \["chokidar@4\.\d+\.\d+"/);
|
||||
expect(lock).not.toMatch(/"braces": \["braces@/);
|
||||
});
|
||||
});
|
||||
@@ -58,18 +58,15 @@ describe('OSV suppression expiry', () => {
|
||||
for (const text of ['"$SCAN_RESULT" = "failure"', 'gh issue create', 'gh issue comment', 'gh issue close']) expect(run).toContain(text);
|
||||
});
|
||||
|
||||
test('the image-size entries name the fixed release and the pin that blocks it (#2753)', () => {
|
||||
const toml = fs.readFileSync(path.join(import.meta.dir, '..', '.osv-scanner.toml'), 'utf8');
|
||||
const entries = toml.split('[[IgnoredVulns]]').slice(1).filter(e => /^id = "GHSA-(?:5p2g-fcmc-qvqq|w3rx-r6r6-pgpr)"/m.test(e));
|
||||
expect(entries).toHaveLength(2);
|
||||
for (const entry of entries) {
|
||||
expect(entry).not.toContain('No fixed version exists');
|
||||
expect(entry).toMatch(/^reason = ".*image-size 2\.0\.3.*\^1\.0\.0.*"$/m);
|
||||
expect(entry).toContain('ignoreUntil = 2026-11-30T00:00:00Z');
|
||||
}
|
||||
// The stated blocker is the lockfile's: html-to-docx asks for image-size ^1.0.0 and resolves a 1.x.
|
||||
test('image-size is overridden to a fixed 2.x and its suppressions are gone (#2753)', () => {
|
||||
const toml = fs.readFileSync(path.join(ROOT, CONFIG), 'utf8');
|
||||
expect(toml).not.toMatch(/GHSA-(?:5p2g-fcmc-qvqq|w3rx-r6r6-pgpr)/);
|
||||
const pkg = JSON.parse(fs.readFileSync(path.join(ROOT, 'package.json'), 'utf8'));
|
||||
expect(pkg.overrides['image-size']).toBe('2.0.4');
|
||||
// html-to-docx still asks for ^1.0.0; the override is what moves the lockfile off the affected 1.x.
|
||||
const lock = fs.readFileSync(path.join(ROOT, 'bun.lock'), 'utf8');
|
||||
expect(lock).toMatch(/"html-to-docx": \["html-to-docx@[^"]+", "", \{ "dependencies": \{[^}]*"image-size": "\^1\.0\.0"/);
|
||||
expect(lock).toMatch(/"image-size": \["image-size@1\.\d+\.\d+"/);
|
||||
expect(lock).toMatch(/"image-size": \["image-size@2\.0\.4"/);
|
||||
expect(lock).not.toMatch(/"image-size": \["image-size@1\./);
|
||||
});
|
||||
});
|
||||
@@ -18,6 +18,8 @@ import {
|
||||
DEFAULT_WALL_TIMEOUT_MS,
|
||||
PER_FILE_WALL_MS,
|
||||
wallTimeoutForShard,
|
||||
recordingWallTimeoutMs,
|
||||
parseCliOptions,
|
||||
KNOWN_WINDOWS_INCOMPATIBLE,
|
||||
TEST_ROOTS,
|
||||
TREE_MUTATING,
|
||||
@@ -940,6 +942,11 @@ describe('test-free-shards: wall-timeout scaling', () => {
|
||||
test('an explicit base above the scaled value wins', () => {
|
||||
expect(wallTimeoutForShard(10, 10 * 60_000)).toBe(10 * 60_000);
|
||||
});
|
||||
|
||||
test('--record-durations times each file under the one-file default unless --wall-timeout is explicit', () => {
|
||||
expect(recordingWallTimeoutMs(parseCliOptions(['--record-durations']))).toBe(wallTimeoutForShard(1));
|
||||
expect(recordingWallTimeoutMs(parseCliOptions(['--record-durations', '--wall-timeout', '1200']))).toBe(1_200_000);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -62,11 +62,14 @@ test('a record_durations dispatch times each Windows-safe file alone and uploads
|
||||
expect(job.if).toBe('${{ inputs.record_durations }}');
|
||||
expect(job['runs-on']).toBe('windows-latest');
|
||||
const record = job.steps.find((step: any) => step.name === 'Time every Windows-safe file alone');
|
||||
expect(record.run).toBe('bun run test:windows --record-durations');
|
||||
expect(record.run).toBe('bun run test:windows --record-durations --wall-timeout 1200');
|
||||
expect(record.env.GSTACK_FREE_TEST_DURATIONS).toBeUndefined();
|
||||
const rename = job.steps.find((step: any) => step.name === 'Name the recording as the Windows seed');
|
||||
expect(rename.if).toBe('always()');
|
||||
expect(rename.run).toBe('cp scripts/free-test-durations.json "$RUNNER_TEMP/free-test-durations-windows.json"');
|
||||
const logs = job.steps.find((step: any) => step.name === 'Upload full recording logs');
|
||||
expect(logs.if).toBe('always()');
|
||||
expect(logs.with['include-hidden-files']).toBe(true);
|
||||
expect(job.steps.at(-1).with.name).toBe('free-test-durations-windows');
|
||||
});
|
||||
|
||||
|
||||
@@ -113,4 +113,13 @@ describe('workflow action pins', () => {
|
||||
expect(ignored[name]).toEqual({ 'dependency-name': name, 'update-types': ['version-update:semver-minor', 'version-update:semver-major'] });
|
||||
}
|
||||
});
|
||||
|
||||
test('Dependabot holds the Anthropic SDKs to patch updates; their 0.x breaking releases arrive as semver-minor', () => {
|
||||
const config = Bun.YAML.parse(fs.readFileSync(path.join(GITHUB_DIR, 'dependabot.yml'), 'utf-8')) as any;
|
||||
const bun = (config.updates ?? []).find((update: any) => update['package-ecosystem'] === 'bun');
|
||||
const ignored = Object.fromEntries((bun?.ignore ?? []).map((rule: any) => [rule['dependency-name'], rule]));
|
||||
for (const name of ['@anthropic-ai/claude-agent-sdk', '@anthropic-ai/sdk']) {
|
||||
expect(ignored[name]).toEqual({ 'dependency-name': name, 'update-types': ['version-update:semver-minor', 'version-update:semver-major'] });
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user