@samitouri / QOS-React-2 / commits / 652e6c5a1b

[sizebot] Add link to diff view (#24790)

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.

Andrew Clark committed Jun 25, 2022 at 18:13 UTC 652e6c5a1b2067cbe1964c6b4ec1af5ff295d7ed
1 file changed +6 -5
dangerfile.js
+6 -5
@@ -84,9 +84,10 @@ const header = `
84 | Name | +/- | Base | Current | +/- gzip | Base gzip | Current gzip |
85 | ---- | --- | ---- | ------- | -------- | --------- | ------------ |`;
86
87 -function row(result) {
87 +function row(result, baseSha, headSha) {
88 + const diffViewUrl = `https://react-builds.vercel.app/commits/${headSha}/files/${result.path}?compare=${baseSha}`;
89 // prettier-ignore
89 - return `| ${result.path} | **${change(result.change)}** | ${kbs(result.baseSize)} | ${kbs(result.headSize)} | ${change(result.changeGzip)} | ${kbs(result.baseSizeGzip)} | ${kbs(result.headSizeGzip)}`;
90 + return `| [${result.path}](${diffViewUrl}) | **${change(result.change)}** | ${kbs(result.baseSize)} | ${kbs(result.headSize)} | ${change(result.changeGzip)} | ${kbs(result.baseSizeGzip)} | ${kbs(result.headSizeGzip)}`;
91 }
92
93 (async function() {
@@ -196,7 +197,7 @@ function row(result) {
197 artifactPath
198 );
199 }
199 - criticalResults.push(row(result));
200 + criticalResults.push(row(result, baseSha, headSha));
201 }
202
203 let significantResults = [];
@@ -212,7 +213,7 @@ function row(result) {
213 // Skip critical artifacts. We added those earlier, in a fixed order.
214 !CRITICAL_ARTIFACT_PATHS.has(result.path)
215 ) {
215 - criticalResults.push(row(result));
216 + criticalResults.push(row(result, baseSha, headSha));
217 }
218
219 // Do the same for results that exceed the significant threshold. These
@@ -224,7 +225,7 @@ function row(result) {
225 result.change === Infinity ||
226 result.change === -1
227 ) {
227 - significantResults.push(row(result));
228 + significantResults.push(row(result, baseSha, headSha));
229 }
230 }
231