MCPcopy
hub / github.com/ampproject/amphtml / reportBundleSize

Function reportBundleSize

build-system/tasks/bundle-size/index.js:182–222  ·  view source on GitHub ↗

* Report the size to the bundle-size GitHub App, to determine size changes. * @return {Promise }

()

Source from the content-addressed store, hash-verified

180 * @return {Promise<void>}
181 */
182async function reportBundleSize() {
183 if (isPullRequestBuild()) {
184 const headSha = gitCommitHash();
185 const baseSha = gitCiMainBaseline();
186 const mergeSha = circleciPrMergeCommit();
187 log(
188 'Reporting bundle sizes for commit',
189 cyan(shortSha(headSha)),
190 'using baseline commit',
191 cyan(shortSha(baseSha)),
192 'and merge commit',
193 cyan(shortSha(mergeSha)) + '...'
194 );
195 try {
196 const response = await postJson(
197 url.resolve(
198 bundleSizeAppBaseUrl,
199 path.join('commit', headSha, 'report')
200 ),
201 {
202 baseSha,
203 mergeSha,
204 bundleSizes: await getBrotliBundleSizes(),
205 }
206 );
207 await checkResponse(response, 'Successfully reported bundle sizes.');
208 } catch (error) {
209 log(
210 yellow('WARNING:'),
211 'Could not report the bundle sizes for this pull request'
212 );
213 logWithoutTimestamp(error);
214 return;
215 }
216 } else {
217 log(
218 yellow('WARNING:'),
219 'Bundle sizes from pull requests can be reported only during CI builds'
220 );
221 }
222}
223
224/**
225 * @return {Promise<void>}

Callers 1

bundleSizeFunction · 0.85

Calls 13

isPullRequestBuildFunction · 0.85
gitCommitHashFunction · 0.85
gitCiMainBaselineFunction · 0.85
circleciPrMergeCommitFunction · 0.85
cyanFunction · 0.85
shortShaFunction · 0.85
postJsonFunction · 0.85
getBrotliBundleSizesFunction · 0.85
checkResponseFunction · 0.85
yellowFunction · 0.85
logWithoutTimestampFunction · 0.85
resolveMethod · 0.80

Tested by

no test coverage detected