Files
msd-core/tests/changeset-github-release-notes.test.cjs
Tom Boucher 334a64168e chore(npm): rebrand packages to @opengsd scope (#127)
* chore(npm): rebrand packages to @opengsd scope

Rename:
- get-shit-done-redux → @opengsd/get-shit-done-redux
- @gsd-redux/sdk → @opengsd/gsd-sdk

Add publishConfig.access=public for first-time scoped publish.
CLI binary names (get-shit-done-redux, gsd-sdk, gsd-tools) unchanged.

Sweeps install commands, npx invocations, CI publish/version-check
workflows, tests, docs, READMEs (all translations), and the
PACKAGE_NAME constant in check-latest-version.

Bumps qs 6.15.1 → 6.15.2 to clear a moderate advisory surfaced by
the audit-clean test (GHSA-q8mj-m7cp-5q26).

Closes #126

* chore: pin 2.0.0 release + remove canary workflow

- Bump both packages 1.50.0-canary.0 → 2.0.0 for first @opengsd publish
- Remove .github/workflows/canary.yml and canary dist-tag handling in
  release.yml / release-sdk.yml
- Drop canary section from VERSIONING.md

Refs #126

* chore: address review findings + harden tarball-smoke timeout

- .changeset/opengsd-org-rename.md: match project's custom
  parse.cjs frontmatter (type: Changed / pr: 127); the scoped
  @changesets/cli keys were silently rejected.
- CONTEXT.md: drop two canary-stream policy lines and a dangling
  DEFECT.CANARY-VERSION-LEAK.cross-ref now that canary.yml is gone.
- tests/release-tarball-smoke.install.test.cjs: pass
  timeout: 600_000 for npm pack + global install; the 3-minute
  runNpm default was timing out on slower Docker hosts (cartographer).

Refs #126

* fix(sdk): add missing type/runtime devDependencies for build

prepublishOnly invokes tsc which couldn't resolve @types/node,
@types/ws, or synckit. They had been hoisted from root but were
not declared in sdk/'s own package.json — first publish from a
clean SDK tree failed.

Refs #126

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(ci): use npm pack stdout instead of glob to find tarball

`npm pack --silent` for a scoped package (@opengsd/get-shit-done-redux)
produces `opengsd-get-shit-done-redux-*.tgz`, not `get-shit-done-redux-*.tgz`.
Capture the filename from stdout instead of a hardcoded glob so the step
works regardless of package name format.

Fixes smoke (ubuntu-latest, 22, false) CI failure.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* ci: treat workflow-file changes as test-skip eligible

`.github/workflows/install-smoke.yml` (and other workflow files)
were in neither `test.yml` paths nor `test-skip.yml` paths-ignore,
so neither workflow ran on a workflow-only commit — leaving the
required test-skip check perpetually missing.

Refs #126

* chore: reset version to 1.0.0 for first @opengsd publish

Nothing has been published yet under the @opengsd scope, so the
inaugural release uses 1.0.0 rather than 2.0.0. The "major bump"
in the changeset reflects the breaking install-command change for
users migrating from the prior unscoped `get-shit-done-redux`, not
a numeric continuation from a 1.x line under the new identity.

Refs #126

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 16:22:41 -04:00

163 lines
5.5 KiB
JavaScript

'use strict';
process.env.GSD_TEST_MODE = '1';
const { test, describe } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const os = require('node:os');
const path = require('node:path');
const cp = require('node:child_process');
const ROOT = path.join(__dirname, '..');
const SCRIPT = path.join(ROOT, 'scripts', 'changeset', 'cli.cjs');
const {
loadFragmentsFromRange,
buildGithubReleaseNotesIr,
serializeGithubReleaseNotes,
renderGithubReleaseNotes,
} = require(path.join(ROOT, 'scripts', 'changeset', 'github-release-notes.cjs'));
function run(command, args, cwd) {
const result = cp.spawnSync(command, args, { cwd, encoding: 'utf8' });
assert.equal(result.status, 0, `${command} ${args.join(' ')}\nstdout=${result.stdout}\nstderr=${result.stderr}`);
return result.stdout;
}
function writeFragment(repo, name, type, pr, body) {
const dir = path.join(repo, '.changeset');
fs.mkdirSync(dir, { recursive: true });
fs.writeFileSync(path.join(dir, `${name}.md`), `---\ntype: ${type}\npr: ${pr}\n---\n${body}\n`);
}
function createTaggedRepo() {
const repo = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-release-notes-'));
run('git', ['init', '-q'], repo);
run('git', ['config', 'user.email', 'test@example.com'], repo);
run('git', ['config', 'user.name', 'Test User'], repo);
fs.writeFileSync(path.join(repo, 'README.md'), 'fixture\n');
run('git', ['add', 'README.md'], repo);
run('git', ['commit', '-q', '-m', 'initial'], repo);
run('git', ['tag', 'v1.0.0'], repo);
writeFragment(repo, 'fix-install-sdk', 'Fixed', 101, '**`gsd-sdk` now installs reliably** — persistent PATH is checked.');
writeFragment(repo, 'remove-intel-noise', 'Removed', 102, '**`gsd-intel-updater` no longer emits layout detection noise** — ordinary projects stay quiet.');
run('git', ['add', '.changeset'], repo);
run('git', ['commit', '-q', '-m', 'add changesets'], repo);
run('git', ['tag', 'v1.0.1'], repo);
return repo;
}
describe('changeset github release notes: tag-range renderer (#3382)', () => {
test('loads changed changeset slugs from a git tag range', () => {
const repo = createTaggedRepo();
const result = loadFragmentsFromRange({ repo, fromRef: 'v1.0.0', toRef: 'v1.0.1' });
assert.deepEqual(result.failures, []);
assert.deepEqual(
result.fragments.map((fragment) => ({ slug: fragment.slug, type: fragment.type, pr: fragment.pr })),
[
{ slug: 'fix-install-sdk', type: 'Fixed', pr: 101 },
{ slug: 'remove-intel-noise', type: 'Removed', pr: 102 },
],
);
});
test('builds grouped GitHub release-note IR from parsed fragments', () => {
const repo = createTaggedRepo();
const { fragments } = loadFragmentsFromRange({ repo, fromRef: 'v1.0.0', toRef: 'v1.0.1' });
const ir = buildGithubReleaseNotesIr({ fragments });
assert.deepEqual(
ir.sections.map((section) => ({
type: section.type,
groups: section.groups.map((group) => ({ title: group.title, prs: group.bullets.map((b) => b.pr) })),
})),
[
{ type: 'Fixed', groups: [{ title: 'Install & runtime conversion', prs: [101] }] },
{ type: 'Removed', groups: [{ title: 'Intel updater', prs: [102] }] },
],
);
});
test('CLI writes a notes file suitable for gh release edit --notes-file', () => {
const repo = createTaggedRepo();
const output = path.join(repo, 'release-notes.md');
const result = cp.spawnSync(
process.execPath,
[
SCRIPT,
'github-release-notes',
'--repo', repo,
'--from', 'v1.0.0',
'--to', 'v1.0.1',
'--repo-slug', 'example/project',
'--output', output,
'--json',
],
{ encoding: 'utf8' },
);
assert.equal(result.status, 0, `stdout=${result.stdout}\nstderr=${result.stderr}`);
const report = JSON.parse(result.stdout);
assert.deepEqual(
{ consumed: report.consumed, output: report.output, hasBodyInJson: report.body !== null },
{ consumed: 2, output, hasBodyInJson: false },
);
const generated = renderGithubReleaseNotes({
repo,
fromRef: 'v1.0.0',
toRef: 'v1.0.1',
repoSlug: 'example/project',
installCommand: 'npx @opengsd/get-shit-done-redux@latest',
});
assert.equal(fs.readFileSync(output, 'utf8'), generated.body);
});
test('rejects unsafe git refs before rendering a range', () => {
const repo = createTaggedRepo();
assert.throws(
() => loadFragmentsFromRange({ repo, fromRef: '--help', toRef: 'v1.0.1' }),
/Invalid git ref/,
);
});
test('validates PR metadata and repo slug before serializing release notes', () => {
assert.throws(
() => serializeGithubReleaseNotes({
ir: {
sections: [
{
type: 'Fixed',
groups: [{ title: 'Other fixes', bullets: [{ slug: 'missing-pr', body: 'missing pr' }] }],
},
],
},
fromRef: 'v1.0.0',
toRef: 'v1.0.1',
}),
/missing valid pr field/,
);
assert.throws(
() => serializeGithubReleaseNotes({
ir: { sections: [] },
fromRef: 'v1.0.0',
toRef: 'v1.0.1',
repoSlug: 'owner/repo/extra',
}),
/Invalid repoSlug format/,
);
assert.throws(
() => serializeGithubReleaseNotes({
ir: { sections: [] },
fromRef: 'v1.0.0',
toRef: 'v1.0.1',
installCommand: 'echo `bad`',
}),
/installCommand cannot contain backtick/,
);
});
});