Skip to content

Commit

Permalink
[sizebot] Add link to diff view (#24790)
Browse files Browse the repository at this point in the history
Updates the sizebot output so that the file names link to a diff view of
the corresponding build artifact.

Example diff view: https://react-builds.vercel.app/commits/955cad9bcc6d755b2a672f8038fe9754e0fe5108/files/oss-stable-semver/react-dom/cjs/react-dom.production.min.js?compare=c3d7a7e3d72937443ef75b7e29335c98ad0f1424

The diff view itself is rendered by a Next.js app that I built as a side
project and is hosted at https://react-builds.vercel.app. If we find
this useful enough I could move the app to a React-owned repo but since
this isn't a critical feature it might be OK to leave it separate for
now, so we don't need to commit to supporting it indefinitely.
  • Loading branch information
acdlite committed Jun 25, 2022
1 parent 955cad9 commit 652e6c5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions dangerfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ const header = `
| Name | +/- | Base | Current | +/- gzip | Base gzip | Current gzip |
| ---- | --- | ---- | ------- | -------- | --------- | ------------ |`;

function row(result) {
function row(result, baseSha, headSha) {
const diffViewUrl = `https://react-builds.vercel.app/commits/${headSha}/files/${result.path}?compare=${baseSha}`;
// prettier-ignore
return `| ${result.path} | **${change(result.change)}** | ${kbs(result.baseSize)} | ${kbs(result.headSize)} | ${change(result.changeGzip)} | ${kbs(result.baseSizeGzip)} | ${kbs(result.headSizeGzip)}`;
return `| [${result.path}](${diffViewUrl}) | **${change(result.change)}** | ${kbs(result.baseSize)} | ${kbs(result.headSize)} | ${change(result.changeGzip)} | ${kbs(result.baseSizeGzip)} | ${kbs(result.headSizeGzip)}`;
}

(async function() {
Expand Down Expand Up @@ -196,7 +197,7 @@ function row(result) {
artifactPath
);
}
criticalResults.push(row(result));
criticalResults.push(row(result, baseSha, headSha));
}

let significantResults = [];
Expand All @@ -212,7 +213,7 @@ function row(result) {
// Skip critical artifacts. We added those earlier, in a fixed order.
!CRITICAL_ARTIFACT_PATHS.has(result.path)
) {
criticalResults.push(row(result));
criticalResults.push(row(result, baseSha, headSha));
}

// Do the same for results that exceed the significant threshold. These
Expand All @@ -224,7 +225,7 @@ function row(result) {
result.change === Infinity ||
result.change === -1
) {
significantResults.push(row(result));
significantResults.push(row(result, baseSha, headSha));
}
}

Expand Down

0 comments on commit 652e6c5

Please sign in to comment.