Skip to content

Commit

Permalink
Stop tracking bundle sizes (#15404)
Browse files Browse the repository at this point in the history
* [sizebot] Fail gracefully if CI returns invalid response

Moves the `response.json()` call into the catch block.

* Stop tracking bundle sizes
  • Loading branch information
acdlite authored Apr 12, 2019
1 parent 3438e5c commit 38bd570
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 1,412 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
path: ./build.tgz

- store_artifacts:
path: ./scripts/rollup/results.json
path: ./build/bundle-sizes.json

- store_artifacts:
path: ./scripts/error-codes/codes.json
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.DS_STORE
node_modules
scripts/flow/*/.flowconfig
scripts/rollup/results.json
*~
*.pyc
.grunt
Expand Down
14 changes: 7 additions & 7 deletions dangerfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ const {generateResultsArray} = require('./scripts/rollup/stats');
const {existsSync, readFileSync} = require('fs');
const {exec} = require('child_process');

if (!existsSync('./scripts/rollup/results.json')) {
if (!existsSync('./build/bundle-sizes.json')) {
// This indicates the build failed previously.
// In that case, there's nothing for the Dangerfile to do.
// Exit early to avoid leaving a redundant (and potentially confusing) PR comment.
process.exit(0);
}

const currentBuildResults = JSON.parse(
readFileSync('./scripts/rollup/results.json')
readFileSync('./build/bundle-sizes.json')
);

/**
Expand Down Expand Up @@ -118,7 +118,7 @@ function git(args) {
await git('fetch upstream');
const baseCommit = await git(`merge-base HEAD upstream/${upstreamRef}`);

let resultsResponse = null;
let previousBuildResults = null;
try {
let baseCIBuildId = null;
const statusesResponse = await fetch(
Expand Down Expand Up @@ -153,8 +153,9 @@ function git(args) {

for (let i = 0; i < baseArtifactsInfo.length; i++) {
const info = baseArtifactsInfo[i];
if (info.path === 'home/circleci/project/scripts/rollup/results.json') {
resultsResponse = await fetch(info.url);
if (info.path === 'home/circleci/project/build/bundle-sizes.json') {
const resultsResponse = await fetch(info.url);
previousBuildResults = await resultsResponse.json();
break;
}
}
Expand All @@ -163,14 +164,13 @@ function git(args) {
return;
}

if (resultsResponse === null) {
if (previousBuildResults === null) {
warn(`Could not find build artifacts for base commit: ${baseCommit}`);
return;
}

// Take the JSON of the build response and
// make an array comparing the results for printing
const previousBuildResults = await resultsResponse.json();
const results = generateResultsArray(
currentBuildResults,
previousBuildResults
Expand Down
1 change: 1 addition & 0 deletions scripts/circleci/test_entry_point.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ if [ $((2 % CIRCLE_NODE_TOTAL)) -eq "$CIRCLE_NODE_INDEX" ]; then
COMMANDS_TO_RUN+=('./scripts/circleci/build.sh')
COMMANDS_TO_RUN+=('yarn test-build --maxWorkers=2')
COMMANDS_TO_RUN+=('yarn test-build-prod --maxWorkers=2')
COMMANDS_TO_RUN+=('cp ./scripts/rollup/results.json ./build/bundle-sizes.json')
COMMANDS_TO_RUN+=('node ./scripts/tasks/danger')
COMMANDS_TO_RUN+=('./scripts/circleci/upload_build.sh')
COMMANDS_TO_RUN+=('./scripts/circleci/pack_and_store_artifact.sh')
Expand Down
Loading

0 comments on commit 38bd570

Please sign in to comment.