* Report the size to the bundle-size GitHub App, to determine size changes. * @return {Promise }
()
| 180 | * @return {Promise<void>} |
| 181 | */ |
| 182 | async 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>} |
no test coverage detected