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

Function storeBundleSize

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

* Store the bundle sizes for a commit hash in the build artifacts storage * repository to the passed value. * @return {Promise }

()

Source from the content-addressed store, hash-verified

98 * @return {Promise<void>}
99 */
100async function storeBundleSize() {
101 if (!isPushBuild() || ciPushBranch() !== 'main') {
102 log(
103 yellow('Skipping'),
104 cyan('--on_push_build') + ':',
105 'this action can only be performed on main branch push builds during CI'
106 );
107 return;
108 }
109
110 if (ciRepoSlug() !== expectedGitHubRepoSlug) {
111 log(
112 yellow('Skipping'),
113 cyan('--on_push_build') + ':',
114 'this action can only be performed during CI builds on the',
115 cyan(expectedGitHubRepoSlug),
116 'repository'
117 );
118 return;
119 }
120
121 const commitHash = gitCommitHash();
122 log('Storing bundle sizes for commit', cyan(shortSha(commitHash)) + '...');
123 try {
124 const response = await postJson(
125 url.resolve(
126 bundleSizeAppBaseUrl,
127 path.join('commit', commitHash, 'store')
128 ),
129 {
130 token: process.env.BUNDLE_SIZE_TOKEN,
131 bundleSizes: await getBrotliBundleSizes(),
132 }
133 );
134 await checkResponse(response, 'Successfully stored bundle sizes.');
135 } catch (error) {
136 log(yellow('WARNING:'), 'Could not store bundle sizes');
137 logWithoutTimestamp(error);
138 return;
139 }
140}
141
142/**
143 * Mark a pull request as skipped, via the AMP bundle-size GitHub App.

Callers 1

bundleSizeFunction · 0.85

Calls 13

isPushBuildFunction · 0.85
ciPushBranchFunction · 0.85
yellowFunction · 0.85
cyanFunction · 0.85
ciRepoSlugFunction · 0.85
gitCommitHashFunction · 0.85
shortShaFunction · 0.85
postJsonFunction · 0.85
getBrotliBundleSizesFunction · 0.85
checkResponseFunction · 0.85
logWithoutTimestampFunction · 0.85
resolveMethod · 0.80

Tested by

no test coverage detected