-
Notifications
You must be signed in to change notification settings - Fork 491
feat(ci): add CHANGELOG and exports map completeness gates #673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
tamirdresher
merged 9 commits into
bradygaster:dev
from
diberry:squad/104-pr-completeness-gates-upstream
Mar 29, 2026
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
deb0c7a
feat(ci): add CHANGELOG and exports map completeness gates (#104)
diberry e904f85
fix: address Copilot review -- crash masking in test, label check per…
Copilot 78749c5
Update .github/workflows/squad-ci.yml
diberry f745b42
fix: exact label matching + test optimization per Copilot review
Copilot 5350804
Update test/check-exports-map.test.ts
diberry 29aeb84
Update test/check-exports-map.test.ts
diberry 37ce2ef
fix: sort barrelDirs for deterministic CI output
Copilot e8d1796
Merge branch 'dev' into squad/104-pr-completeness-gates-upstream
diberry 7629e8a
Merge branch 'dev' into squad/104-pr-completeness-gates-upstream
tamirdresher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| #!/usr/bin/env node | ||
| // check-exports-map.mjs -- Verify package.json exports match barrel files. | ||
| // Exit 0 if all barrels are mapped, exit 1 with details if any are missing. | ||
| // Uses only Node.js built-ins (fs, path). | ||
|
|
||
| import { readFileSync, readdirSync, existsSync } from 'node:fs'; | ||
| import { resolve, join, dirname } from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
|
|
||
| const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
| const SDK_ROOT = resolve(__dirname, '..', 'packages', 'squad-sdk'); | ||
| const SRC_DIR = join(SDK_ROOT, 'src'); | ||
| const PKG_PATH = join(SDK_ROOT, 'package.json'); | ||
|
|
||
| const pkg = JSON.parse(readFileSync(PKG_PATH, 'utf8')); | ||
| const exportsMap = pkg.exports || {}; | ||
|
|
||
| const srcEntries = readdirSync(SRC_DIR, { withFileTypes: true }); | ||
| const barrelDirs = srcEntries | ||
| .filter((entry) => entry.isDirectory()) | ||
| .filter((entry) => existsSync(join(SRC_DIR, entry.name, 'index.ts'))) | ||
| .map((entry) => entry.name) | ||
| .sort(); | ||
|
|
||
| const missing = []; | ||
|
|
||
| for (const dir of barrelDirs) { | ||
| const exportKey = `./${dir}`; | ||
| if (!exportsMap[exportKey]) { | ||
| missing.push({ dir, expectedKey: exportKey }); | ||
| } | ||
| } | ||
|
|
||
| if (missing.length === 0) { | ||
| console.log(`Exports map check passed: all ${barrelDirs.length} barrel directories have export entries.`); | ||
| process.exit(0); | ||
| } else { | ||
| console.error(`Exports map check FAILED: ${missing.length} barrel(s) missing from package.json exports.`); | ||
| console.error(`This is by design -- new barrel directories must have matching export entries.\n`); | ||
| for (const { dir, expectedKey } of missing) { | ||
| console.error(` MISSING: "${expectedKey}" (has src/${dir}/index.ts but no export entry)`); | ||
| } | ||
| console.error(`\nTo fix: add export entries to packages/squad-sdk/package.json "exports" for each missing barrel.`); | ||
| console.error('To skip: add the "skip-exports-check" label to your PR to bypass this gate.'); | ||
| process.exit(1); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| /** | ||
| * check-exports-map.mjs — Script execution test | ||
| * | ||
| * Validates that the exports map checker script: | ||
| * 1. Executes without crashing (exits 0 or 1, not a runtime error) | ||
| * 2. Produces human-readable output on stdout or stderr describing the result | ||
| * | ||
| * This does NOT test that exports are complete — the script itself | ||
| * catches real gaps (e.g., platform, remote, roles, streams, upstream). | ||
| * Those missing exports are expected; they are tracked separately. | ||
| */ | ||
|
|
||
| import { describe, it, expect, beforeAll } from 'vitest'; | ||
| import { execFile } from 'node:child_process'; | ||
| import { resolve } from 'node:path'; | ||
|
|
||
| const SCRIPT_PATH = resolve(process.cwd(), 'scripts', 'check-exports-map.mjs'); | ||
|
|
||
| function runScript(): Promise<{ code: number; stdout: string; stderr: string }> { | ||
| return new Promise((res, rej) => { | ||
| execFile('node', [SCRIPT_PATH], { cwd: process.cwd() }, (error, stdout, stderr) => { | ||
| if (!error) { | ||
| res({ code: 0, stdout, stderr }); | ||
| return; | ||
| } | ||
| const err = error as NodeJS.ErrnoException & { status?: number; code?: number | string }; | ||
| if (typeof err.code === 'number') { | ||
| res({ code: err.code, stdout, stderr }); | ||
| return; | ||
| } | ||
| if (typeof err.status === 'number') { | ||
| res({ code: err.status, stdout, stderr }); | ||
| return; | ||
| } | ||
| // Non-numeric code or missing exit code (e.g., spawn ENOENT, signal termination) | ||
| rej(error); | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| describe('check-exports-map.mjs', () => { | ||
| let result: { code: number; stdout: string; stderr: string }; | ||
|
|
||
| beforeAll(async () => { | ||
| result = await runScript(); | ||
| }); | ||
|
|
||
| it('executes without crashing (exits 0 or 1)', () => { | ||
| // Exit 0 = all barrels mapped, exit 1 = some missing. | ||
| // Both are valid outcomes. A crash would be a non-0/1 code or thrown error. | ||
| expect([0, 1]).toContain(result.code); | ||
| }); | ||
|
|
||
| it('produces output describing the check result', () => { | ||
| const combined = result.stdout + result.stderr; | ||
| // The script always prints either "passed" or "FAILED" in its output | ||
| expect(combined).toMatch(/Exports map check (passed|FAILED)/); | ||
| }); | ||
|
|
||
| it('reports MISSING entries with expected format when barrels are unmapped', () => { | ||
| if (result.code === 1) { | ||
| // When the check fails, each missing barrel is reported with a MISSING: prefix | ||
| expect(result.stderr).toContain('MISSING:'); | ||
| // The error message should mention the skip label escape hatch | ||
| expect(result.stderr).toContain('skip-exports-check'); | ||
| } | ||
| // If code === 0, all barrels are mapped and there is nothing to assert here | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.