Files
paperclip/.github/scripts/tests/check-pr-test-coverage.test.mjs
T
Devin Foley 4518f272b2 fix(release): publish all remaining @paperclipai workspace packages from CI + guard unpublishable edges (#8365)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work, distributed primarily via the `paperclipai` npm package and its
`@paperclipai/*` workspace packages.
> - The release subsystem (`scripts/release-package-*`) decides which
workspace packages CI republishes at the unified calver version each
release, and `replaceWorkspaceDeps()` rewrites every internal
`workspace:` dependency to that calver version at publish time.
> - The gap: a package that publishes from CI can declare a `workspace:`
dependency on a package that is NOT enrolled for CI publish. The
dependency spec gets rewritten to a calver version that is never
actually published, so the dependent becomes uninstallable.
> - This shipped for real: a recent change made `@paperclipai/server`
depend on `@paperclipai/skills-catalog`, but skills-catalog was not on
the calver release train — so canary builds after that merge failed to
resolve `@paperclipai/skills-catalog@<calver>` and `npx
paperclipai@canary run` broke.
> - This PR addresses it durably by (a) putting every remaining internal
package on the CI release train so no internal dependency can dangle,
and (b) adding a fail-fast guard so this class of break can never ship
again.
> - The benefit is that canary and stable installs resolve all internal
dependencies, and any future unpublishable workspace edge fails the
release build with a clear, named error instead of producing a broken
package.

## Linked Issues or Issue Description

Refs #8327 (introduced the `server -> skills-catalog` runtime dependency
that surfaced the gap).

No public issue tracks this; describing it in-PR:

- **Problem:** After #8327, `npx paperclipai@canary run` failed for
builds past the merge because `@paperclipai/skills-catalog` was
rewritten to a calver version that was never published (the package was
not enrolled for CI publish). Versions before the merge still ran.
- **Root cause:** A `publishFromCi:true` package can declare a
`workspace:` dependency on a package that is not `publishFromCi:true`;
the release-time version rewrite then points at a non-existent published
version.

## What Changed

- Enrolled every remaining internal package on the calver release train
by setting `publishFromCi: true` in
`scripts/release-package-manifest.json`: `skills-catalog`,
`teams-catalog`, `plugin-workspace-diff`, `plugin-kubernetes`,
`plugin-novita-sandbox`. There are now zero `publishFromCi:false`
entries.
- `skills-catalog`, `teams-catalog`, `plugin-workspace-diff` already
existed on npm — CI simply republishes them at calver.
- `plugin-kubernetes` and `plugin-novita-sandbox` were not on npm; their
one-time first publish was bootstrapped so the
`check-release-package-bootstrap` gate passes.
- Added `findUnpublishableWorkspaceEdges()` to
`scripts/release-package-map.mjs`, wired into
`buildReleasePackagePlan()`. The release map build now fails fast
(surfaced by the `check` CI already runs) whenever a
`publishFromCi:true` package declares a runtime `workspace:` dependency
(`dependencies`/`optionalDependencies`/`peerDependencies`) on a
non-`publishFromCi:true` `@paperclipai/*` package, naming the offending
edge.
- Added tests covering positive/negative detection, all three dependency
sections, unknown-package edges, off-train edges, and the live manifest.

## Verification

- `node --test scripts/release-package-map.test.mjs` → 9/9 pass
(includes a test asserting the live manifest has no unpublishable
edges).
- `node scripts/check-release-package-bootstrap.mjs
scripts/release-package-manifest.json` → passes, naming all five
newly-enabled packages (all confirmed present on npm).
- Confirmed via `npm view` that all five packages resolve on the public
registry.

## Risks

- Low risk. The change only enrolls already-existing (or
freshly-bootstrapped) packages onto the existing release train and adds
a build-time validation. No runtime code paths change. The new guard can
only *fail* a release that was already going to ship a broken package.

## Model Used

Claude Opus 4.7 (claude-opus-4-7), extended thinking, with tool use /
code execution.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change and contains no internal
Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] If this change affects the UI, I have included before/after
screenshots (N/A — no UI changes)
- [x] I have updated relevant documentation to reflect my changes (N/A —
no doc-facing behavior change)
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [ ] I will address all Greptile and reviewer comments before
requesting merge
2026-06-19 19:11:20 -07:00

110 lines
4.3 KiB
JavaScript

import { test } from 'node:test';
import assert from 'node:assert/strict';
import { checkTestCoverage } from '../check-pr-test-coverage.mjs';
const makeFiles = (filenames) =>
filenames.map(filename => ({ filename, status: 'modified' }));
// Existing tests with title parameter added (fix: prefix means test required)
test('passes when .test.ts file is changed', () => {
assert.equal(checkTestCoverage(makeFiles(['src/foo.test.ts', 'src/foo.ts']), 'fix: bug').passed, true);
});
test('passes when .spec.js file is changed', () => {
assert.equal(checkTestCoverage(makeFiles(['src/bar.spec.js']), 'fix: bug').passed, true);
});
test('passes when .test.mjs file is changed', () => {
assert.equal(checkTestCoverage(makeFiles(['scripts/foo.test.mjs', 'scripts/foo.mjs']), 'fix: bug').passed, true);
});
test('passes when .test.cjs file is changed', () => {
assert.equal(checkTestCoverage(makeFiles(['scripts/bar.test.cjs']), 'fix: bug').passed, true);
});
test('passes when file under tests/ is changed', () => {
assert.equal(checkTestCoverage(makeFiles(['tests/unit/baz.ts']), 'fix: bug').passed, true);
});
test('passes when file under __tests__ is changed', () => {
assert.equal(checkTestCoverage(makeFiles(['src/__tests__/qux.ts']), 'fix: bug').passed, true);
});
test('fails when fix: PR has no tests', () => {
const result = checkTestCoverage(makeFiles(['src/foo.ts', 'src/bar.ts']), 'fix: bug');
assert.equal(result.passed, false);
assert.ok(result.failures[0].includes('test'));
});
test('fails when feat: PR has no tests', () => {
const result = checkTestCoverage(makeFiles(['src/foo.ts']), 'feat: new feature');
assert.equal(result.passed, false);
});
test('fails with empty file list and fix: prefix', () => {
assert.equal(checkTestCoverage([], 'fix: bug').passed, false);
});
test('ignores removed test files', () => {
const files = [
{ filename: 'src/foo.test.ts', status: 'removed' },
{ filename: 'src/foo.ts', status: 'modified' },
];
assert.equal(checkTestCoverage(files, 'fix: bug').passed, false);
});
// New tests for prefix-aware skip behavior
test('skips test requirement for docs: prefix (markdown only)', () => {
assert.equal(checkTestCoverage(makeFiles(['README.md', 'docs/setup.md']), 'docs: update guide').passed, true);
});
test('skips test requirement for chore: prefix (config only)', () => {
assert.equal(checkTestCoverage(makeFiles(['.gitignore', '.github/labels.yml']), 'chore: cleanup').passed, true);
});
test('skips test requirement for refactor: prefix', () => {
assert.equal(checkTestCoverage(makeFiles(['src/foo.ts']), 'refactor: rename function').passed, true);
});
test('skips test requirement for style: prefix', () => {
assert.equal(checkTestCoverage(makeFiles(['src/foo.ts']), 'style: format').passed, true);
});
// New tests for mismatch detection
test('flags docs: PR with source code changes', () => {
const result = checkTestCoverage(makeFiles(['src/api.ts', 'README.md']), 'docs: update docs');
assert.equal(result.passed, false);
assert.ok(result.failures[0].includes('docs:'));
assert.ok(result.failures[0].includes('source code'));
});
test('flags chore: PR with source code changes', () => {
const result = checkTestCoverage(makeFiles(['src/server.ts']), 'chore: cleanup');
assert.equal(result.passed, false);
assert.ok(result.failures[0].includes('chore:'));
});
test('does NOT flag chore: PR with only config files', () => {
const result = checkTestCoverage(makeFiles(['package.json', '.eslintrc.js']), 'chore: bump');
// .eslintrc.js is a .js file but it's config — current rule will flag it. This documents that.
// For now we err on the side of flagging — contributor can retitle if needed.
assert.equal(result.passed, false);
});
test('does NOT flag refactor: PR with source code (refactor expects source changes)', () => {
const result = checkTestCoverage(makeFiles(['src/foo.ts']), 'refactor: rename');
assert.equal(result.passed, true);
});
test('requires test when no prefix used', () => {
const result = checkTestCoverage(makeFiles(['src/foo.ts']), 'Some PR with no prefix');
assert.equal(result.passed, false);
});
test('handles scoped prefix like fix(server):', () => {
assert.equal(checkTestCoverage(makeFiles(['src/foo.test.ts', 'src/foo.ts']), 'fix(server): bug').passed, true);
});