mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-01 14:34:42 +01:00
fix: pre-landing review fixes (pass 2)
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
b4a9fe11ec
commit
855410fcf5
3 files changed
+11
-2
No files matched your search
+1
-1
@@ -54,7 +54,7 @@ async function main(argv: string[]): Promise<number> {
|
||||
if (nothingToRun(l) && (verb === 'run' || verb === 'detect')) { process.stdout.write(NONE); return verb === 'run' ? 3 : 0; }
|
||||
if (verb === 'detect') {
|
||||
for (const c of l.checks) process.stdout.write(`CHECK ${c.name} ${c.command}${c.body ? ` (runs: ${c.body})` : ''} (${c.source})\n`);
|
||||
if (!l.checks.length) process.stdout.write('CHECKS: none detected besides tests (no gstack:verify: line, Health Stack section or manifest check)\n');
|
||||
if (!l.checks.length) process.stdout.write('CHECKS: tests only (no gstack:verify: line, Health Stack section or manifest check)\n');
|
||||
const selection = Object.values(l.ctx.config.selection ?? {});
|
||||
process.stdout.write(`TESTS pregate selection against ${l.ctx.baseRef} (policy ${l.ctx.configLabel}; runner ${l.ctx.config.runner ?? 'detected per file'}${selection.length ? `; selection commands: ${selection.join(' | ')}` : ''})\n`);
|
||||
process.stdout.write(`TRUST ${trusted ? 'trusted' : 'untrusted (run gstack-checks trust after the user agrees, or pass --allow-repo-commands)'}\n`);
|
||||
|
||||
+3
-1
@@ -100,7 +100,9 @@ export function manifestChecks(root: string): Check[] {
|
||||
if (/\bruff\b/.test(pyproject)) checks.push({ name: 'lint', command: 'ruff check .', source: 'pyproject.toml' });
|
||||
if (/\bmypy\b/.test(pyproject)) checks.push({ name: 'typecheck', command: 'mypy .', source: 'pyproject.toml' });
|
||||
}
|
||||
if (fs.existsSync(path.join(root, 'Cargo.toml'))) checks.push({ name: 'build', command: 'cargo check --all-targets', source: 'Cargo.toml' }, { name: 'lint', command: 'cargo clippy --all-targets', source: 'Cargo.toml' });
|
||||
const cargo = read(path.join(root, 'Cargo.toml'));
|
||||
if (cargo !== null) checks.push({ name: 'build', command: 'cargo check --all-targets', source: 'Cargo.toml' });
|
||||
if (cargo !== null && (/^\[(workspace\.)?lints\.clippy\]/m.test(cargo) || ['clippy.toml', '.clippy.toml'].some(f => fs.existsSync(path.join(root, f))))) checks.push({ name: 'lint', command: 'cargo clippy --all-targets', source: 'Cargo.toml' });
|
||||
if (fs.existsSync(path.join(root, 'go.mod'))) checks.push({ name: 'vet', command: 'go vet ./...', source: 'go.mod' }, { name: 'build', command: 'go build ./...', source: 'go.mod' });
|
||||
const seen = new Set<string>();
|
||||
return checks.filter(c => (seen.has(c.name) ? false : (seen.add(c.name), true)));
|
||||
|
||||
@@ -69,6 +69,13 @@ describe('detection', () => {
|
||||
fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify({ scripts: { lint: 'eslint .' }, devDependencies: { typescript: '5' } }));
|
||||
fs.writeFileSync(path.join(dir, 'go.mod'), 'module x\n');
|
||||
expect(manifestChecks(dir).map(c => c.command)).toEqual(['bunx tsc --noEmit', 'bun run lint', 'go vet ./...', 'go build ./...']);
|
||||
// Clippy is a rustup component Cargo.toml does not declare: it runs only when the repo opts in.
|
||||
const rs = fs.mkdtempSync(path.join(os.tmpdir(), 'gstack-checks-rs-'));
|
||||
dirs.push(rs);
|
||||
fs.writeFileSync(path.join(rs, 'Cargo.toml'), '[package]\nname = "x"\n');
|
||||
expect(manifestChecks(rs).map(c => c.command)).toEqual(['cargo check --all-targets']);
|
||||
fs.writeFileSync(path.join(rs, 'Cargo.toml'), '[package]\nname = "x"\n[lints.clippy]\npedantic = "warn"\n');
|
||||
expect(manifestChecks(rs).map(c => c.command)).toEqual(['cargo check --all-targets', 'cargo clippy --all-targets']);
|
||||
const py = fs.mkdtempSync(path.join(os.tmpdir(), 'gstack-checks-py-'));
|
||||
dirs.push(py);
|
||||
expect(manifestChecks(py)).toEqual([]);
|
||||
|
||||
Reference in new issue
Block a user