Repository navigation
ci: each published package commits a generated public API report, with advisory API changes for the PR report - #9241
Conversation
… the PR report gets its API changes
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
There was a problem hiding this comment.
Changes requested. The generator matches INV24 and the committed reports regenerate byte-identically from this head's build. However, two required checks fail and the API changes are wrong in two cases.
lint: Changeset coverage counts eachapi-report.mdas shipped docs becauseisPackedFilefails closed on the!**/…globs infiles; mark package-root reports as not shipping inscripts/release/changeset-coverage.mjsrather than adding Changesets.test-ui (1/4): four fixtures underscripts/api-report/__fixtures__/repo/packages/demo/lib/need the copyright header.- When
merge-base.shfinds no merge base, the step falls back to the committed report and reports zero changes, so it should exit instead. - Stylesheet, theme-target and attribute rows get usage like
import {--x} from '@astryxdesign/core', becauseusageForcheckssectionwhileparseReportstores those headings inentry. - Reuse
isStableReleasePackageand the lint rule'sPUBLIC_ATTRIBUTESinstead of re-deriving the package and attribute lists. - Until the PR report renders the API changes, drop "the PR report gets its API changes" from the title and the step comment.
[Automated review]
| BASE_SHA=$(.github/scripts/merge-base.sh "$BASE_REF" 'the API changes' || true) | ||
| node scripts/api-report/cli.mjs --changes ${BASE_SHA:+--base "$BASE_SHA"} |
There was a problem hiding this comment.
When merge-base.sh finds no merge base it prints nothing, but this still runs --changes without --base. cli.mjs:151 then compares against the head's own committed report, so the output reads as zero API changes (baseline: false, 0 rows, empty api-changes.md). INV24 asks for changes against the merge base's report, so exit here when BASE_SHA is empty (for example [ -n "$BASE_SHA" ] || exit 0).
| export function usageFor(pkg, row) { | ||
| const spec = row.entry.startsWith('./') ? `${pkg}${row.entry.slice(1)}` : pkg; | ||
| const [kind, name = row.item] = row.item.split(' '); | ||
| if (row.section === 'Stylesheets') return `.my-scope { ${name}: …; }`; |
There was a problem hiding this comment.
parseReport (line 45) puts a package-level heading such as Stylesheets in entry and leaves section empty, so this branch and the next three never match. An added custom property currently gets import {--x} from '@astryxdesign/core'. Check row.entry here, and add a tail-row case to the test.
| * @param {string} repoRoot | ||
| * @returns {Array<{name: string, dir: string}>} | ||
| */ | ||
| export function publishedPackages(repoRoot) { |
There was a problem hiding this comment.
This repeats published-package discovery that .github/scripts/lib/package-size.js (publishedPackages) and scripts/release/active-release.mjs (isStableReleasePackage) already own, with a different rule: canary-only packages and the scope are ignored here. Filtering with isStableReleasePackage keeps the report set equal to what release publishes.
| * @param {string} repoRoot | ||
| * @returns {string[]} | ||
| */ | ||
| export function readPublicAttributes(repoRoot) { |
There was a problem hiding this comment.
internal/eslint-plugin-astryx/no-raw-private-attribute.js already exports PUBLIC_ATTRIBUTES, the list the lint enforces. Scraping the record's prose returns [] as soon as that sentence is reworded, and the attribute rows disappear without an error.
…c attribute list; exempt package-root reports from Changeset coverage; skip the step with no merge base
There was a problem hiding this comment.
Changes requested: the earlier findings are fixed and all 11 reports regenerate byte for byte from this head's build, but the API changes still miss some changes to core.
parseReportkeys a row by its first two words (scripts/api-report/changes.mjs:83-86), so 40 of core's rows collide (36 custom properties declared in both./astryx.cssand./tailwind-theme.css, and 4 shared theme targets) and removing--color-accentfrom./astryx.cssreports nothing; keep the stylesheet or component in the key and add a fixture for it.- The description's Maintainer impact and Risk sections still say the PR report shows the API changes; reword them to say CI writes them to the
pr-analysisartifact until the renderer follow-up lands.
[Automated review]
|
|
||
| function itemName(line) { | ||
| if (/^[\w$]+ \(/.test(line)) return line.split(' ')[0]; // `Name (./entry)` in an also-exported list | ||
| const m = line.match(/^(\w+) ([^\s(:<=]+)/); |
There was a problem hiding this comment.
This key keeps only the first two words, so var --color-accent (./astryx.css) and var --color-accent (./tailwind-theme.css) (36 such names in core) and target checkbox-indicator (CheckboxInput) / (Indicator) (4 shared targets) map to one row, and the later one overwrites the earlier at line 62. Removing --color-accent from ./astryx.css while ./tailwind-theme.css keeps it then yields no added, changed or removed row, which INV24 requires. Keeping the parenthesised part for var and target rows (or refusing a duplicate key) fixes it; a fixture with one custom property in two stylesheets would cover it.
…rget its component in the change key
There was a problem hiding this comment.
Approval recommended: the API changes now keep a custom property's stylesheet and a theme target's component in the row key, so a removal from core's ./astryx.css shows up, and all 11 reports regenerate byte for byte from this head's build. Two small follow-ups, neither blocking:
- The "Reachable members tagged internal" index lists exports only (4 in core) while 17 rows carry
@internal; add the member rows or title it "Exports tagged internal". - Once this lands, the INV24 known-gap note in
docs/architecture/public-component-api.mdis out of date and can name only the PR-report rendering that remains.
[Automated review]
| } | ||
| seen.set(identity, e.subpath); | ||
| const m = marks(decl, name); | ||
| if (m.includes('@internal')) internal.push(`${name} via ${e.subpath}`); |
There was a problem hiding this comment.
Only top-level exports reach the "Reachable members tagged internal" index, so core's lists 4 while 17 rows carry @internal (for example BaseTypeahead's prop __queryEntries). Not blocking, since each row carries the mark: either add member rows here or title the section "Exports tagged internal".
Maintainer impact
Maintainers reviewing a pull request can't easily see what it does to the published API. A renamed prop, a new export, a widened type or a changed theme target only shows up if a reviewer happens to read the right declaration. Contributors get no signal either. This PR puts each published package's public surface in a committed report. CI compares the head's build with the merge base's reports and writes the advisory API changes to the
pr-analysisartifact. The PR report shows them as one API changes line once its renderer follow-up lands. Nothing here fails CI or blocks a contributor.Intended invariant
architecture:public-component-apiINV24:pnpm api:reportgenerates one committed report per published package from its built declarations and stylesheet, with a section for each entry point. The PR report lists added, changed and removed rows against the merge base, each with its signature and a usage example, and flags a stale committed report. All of this is evidence only (INV13): it fails no check.Change
What gets reported
api-report.md, using the release's own package rule. Today that is@astryxdesign/build,cli,core,richtextand the seven themes.exportsmap gets its own section, listing:@defaultwhere declared)--_*excluded)data-astryx-*names from INV23, read from the lint rule'sPUBLIC_ATTRIBUTESthat enforces that list@internal@internal,@experimentaland@deprecatedshow on the row. Core's./internal/*and unpublished packages are left out.Format and the change comparison
scripts/api-report/changes.mjskeys rows by entry point, section, item and member. A custom property keeps its stylesheet in its key and a theme target its component, so one name in two places stays two rows. It produces added, changed and removed rows with a usage example. A package with no report at the merge base reads as "new report".Commands
pnpm api:reportwrites every report.--package <name>writes one, and each published package also has its ownapi:reportscript.--checkexits 1 on a stale report, for local use only.--changes --base <sha>writesapi-changes.jsonandapi-changes.md, and always exits 0.CI
build-storybookjob, just before the analysis artifact upload. It reads the dists that job already built and diffs against the reports committed at the merge base. Those are read withgit show: no GitHub API calls, and the base is not built. With no merge base the step exits without comparing.continue-on-errorand a 2-minute timeout.api-changes.jsonto thepr-analysisartifact. Until the PR report's renderer follow-up lands, the changes live only in that artifact; the renderer escapes every string.Changeset coverage
api-report.mdis not in any package's tarball, but coverage treated it as shipped because the!**/…exclusion globs infilesfail closed. Coverage now exempts it unlessfilesactually packs it, so regenerating a report never needs a Changeset. Two tests cover it.Diffs
.gitattributesmarks the reports as generated, so their raw diffs collapse. Reviewers read the API changes line instead.Dependencies
Evidence
pnpm api:report --checkpasses on this head.--changes --base origin/mainon this head prints one line, "new report", for each package, since main has no reports yet. On a later PR it lists rows. The fixture test covers added, changed and removed rows, a stale report, and the empty case.api:reportscript in each publishedpackage.jsonand the report files, which are outside every package'sfileslist and so are not published.Scope
@internalmembers in core are recorded as baseline rows, not changed here.Risk
build-storybook. Generating all 11 reports takes about 6 seconds of CPU locally. It can't fail the job:continue-on-error, a 2-minute timeout, and the script exits 0 in--changesmode.stale: true), not failed. Regenerate withpnpm build && pnpm api:report.pr-analysisartifact only, not in the PR report.CI impact
ubuntu-latestjob (build-storybook)build-storybook; target ≤30 s at p90, measured on this PR's runbuild-storybookalready runs (PRs that touch packages)Testing
vitest run --project node scripts/api-report: 14 tests over a fixture package. They cover:./internal/*, private custom properties and unlisted attributes being left outpnpm build && pnpm api:report, then--check(clean) and--changes --base origin/main.changeset-coverage.test.mjs(87 tests, including the two new ones), andchangeset-coverage.mjs pron this branch: nothing ships.pnpm check:repo, the copyright check, and Prettier on the reports and scripts. Rows sit intextfences, so Prettier leaves them alone.