Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

### Fixed

- **Durable reports now publish their exhaustive `report.json` source of truth.**
The report branch previously received only `report.md` and crop PNGs even when
a byte-capped Markdown report directed reviewers to `report.json`. Publication
now includes the generated JSON alongside the Markdown and crops.
- **Report taxonomy no longer bills added-node style inventories as restyles.** A
brand-new element still emits its full resting/state inventory (raw findings and
exit codes unchanged), but presentation counts and copy reserve
Expand Down
9 changes: 7 additions & 2 deletions src/report-publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,14 +306,19 @@ export async function verifyPublishedReceipt(options: {
);
}

/** Collect exactly what the report step publishes: `report.md` plus every
* generated crop it references. Nothing else in the report directory travels. */
/** Collect exactly what the report step publishes: `report.md`, the exhaustive
* `report.json`, plus every generated crop the Markdown references. Nothing
* else in the report directory travels. */
export function collectReportFiles(reportDirectory: string): ReportPublishFile[] {
const files: ReportPublishFile[] = [
{
relativePath: 'report.md',
content: fs.readFileSync(path.join(reportDirectory, 'report.md')),
},
{
relativePath: 'report.json',
content: fs.readFileSync(path.join(reportDirectory, 'report.json')),
},
];
const cropsDirectory = path.join(reportDirectory, 'crops');
if (fs.existsSync(cropsDirectory)) {
Expand Down
21 changes: 21 additions & 0 deletions test/report-publish.test.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import assert from 'node:assert/strict';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import test from 'node:test';
import {
collectReportFiles,
REPORT_BRANCH_SIZE_WARNING_BYTES,
publishReportFolder,
verifyPublishedReceipt,
Expand Down Expand Up @@ -94,6 +98,23 @@ const reportFiles = [
{ relativePath: 'crops/hero.png', content: Buffer.from([1, 2, 3]) },
];

test('collectReportFiles publishes report.json with markdown and crops', (t) => {
const reportDirectory = fs.mkdtempSync(path.join(os.tmpdir(), 'styleproof-report-publish-'));
t.after(() => fs.rmSync(reportDirectory, { recursive: true, force: true }));
fs.mkdirSync(path.join(reportDirectory, 'crops'));
fs.writeFileSync(path.join(reportDirectory, 'report.md'), '# report');
fs.writeFileSync(path.join(reportDirectory, 'report.json'), '{"surfaces":[]}');
fs.writeFileSync(path.join(reportDirectory, 'crops', 'hero.png'), Buffer.from([1, 2, 3]));

const files = collectReportFiles(reportDirectory);

assert.deepEqual(
files.map((file) => file.relativePath),
['report.md', 'report.json', 'crops/hero.png'],
);
assert.equal(files[1].content.toString('utf8'), '{"surfaces":[]}');
});

test('publishes onto an existing branch without downloading any report bytes', async () => {
const fake = buildFakeGitHub({
branchTip: 'tip-sha',
Expand Down
Loading