Skip to content

Commit

Permalink
Fix client build_all.sh's ability to set node's --max-old-space-size …
Browse files Browse the repository at this point in the history
…flag for prod builds... because, after everything, turns out that was STILL broken
  • Loading branch information
Stephen-ONeil committed Apr 29, 2021
1 parent 651e631 commit 8e3d95a
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 67 deletions.
3 changes: 1 addition & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ jobs:
docker:
- image: eaadtbs/ib-ci-build:1.4
<<: *dockerhub_auth
resource_class: medium+
working_directory: "~/InfoBase"
steps:
- checkout:
Expand Down Expand Up @@ -151,7 +150,7 @@ jobs:
- prod-build-{{ .Branch }}-{{ .Revision }}
- run:
command: |
[ -f "client/$BUILD_DIR/InfoBase/app/app-a11y-en.min.js" ] || (cd client && ./deploy_scripts/build_all.sh -m 4096 -c "none")
[ -f "client/$BUILD_DIR/InfoBase/app/app-a11y-en.min.js" ] || (cd client && ./deploy_scripts/build_all.sh -m 900 -c "none")
- save_cache:
paths:
- client/build
Expand Down
107 changes: 46 additions & 61 deletions client/deploy_scripts/build_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
set -e # will exit if any command has non-zero exit value

concurrency="full"
max_old_space_size=1024

max_old_space_size=2048
while getopts "c:m:" opt; do
case ${opt} in
c) concurrency=$OPTARG;;
Expand All @@ -16,89 +15,75 @@ if [[ ! $concurrency =~ ^(full|half|none)$ ]]; then
exit 1
fi

# the prod no-watch scripts in client/package.json will use MAX_OLD_SPACE_SIZE if it exists
export MAX_OLD_SPACE_SIZE=max_old_space_size

[ -e $BUILD_DIR/InfoBase ] && rm -r $BUILD_DIR/InfoBase # clean up build dir

npm run IB_base

# When exiting, either from finishing, being killed, or throwing an error, kill the spinner and dump the captured build process output to terminal
function print_captured_output {
kill -9 $spinner_pid

[ -f $scratch/ib_prod_en_build_out ] && cat $scratch/ib_prod_en_build_out
[ -f $scratch/ib_prod_en_build_err ] && cat $scratch/ib_prod_en_build_err

[ -f $scratch/ib_prod_fr_build_out ] && cat $scratch/ib_prod_fr_build_out
[ -f $scratch/ib_prod_fr_build_err ] && cat $scratch/ib_prod_fr_build_err

[ -f $scratch/a11y_prod_en_build_out ] && cat $scratch/a11y_prod_en_build_out
[ -f $scratch/a11y_prod_en_build_err ] && cat $scratch/a11y_prod_en_build_err

[ -f $scratch/a11y_prod_fr_build_out ] && cat $scratch/a11y_prod_fr_build_out
[ -f $scratch/a11y_prod_fr_build_err ] && cat $scratch/a11y_prod_fr_build_err
}

if [ $concurrency == "none" ]; then
# Just running all builds one at a time, no backgrounding or output redirection
npm run IB_prod_no_watch_en

npm run IB_prod_no_watch_fr

npm run a11y_prod_no_watch_en

scratch=$(mktemp -d -t captured_build_output.XXXXXXXXXX)
if [ $concurrency == "full" ]; then
npm run a11y_prod_no_watch_fr
else
# Run standard and a11y builds in parallel as background processes, store thieir stdout and stderr in temp files and hold on to their pids,
# clean up and dump output on exit
trap print_captured_output EXIT

echo ""
echo "Running prod builds in background, full concurrency..."
echo "Running prod builds in background, $concurrency concurrency..."
spinner_pid=$(sh ../scripts/spinner.sh)

npm run IB_prod_no_watch_en -- --max_old_space_size=$max_old_space_size > $scratch/ib_prod_en_build_out 2> $scratch/ib_prod_en_build_err &
ib_prod_en_pid=$!
# When exiting, either from finishing, being killed, or throwing an error, kill the spinner and dump the captured build process output to terminal
scratch=$(mktemp -d -t captured_build_output.XXXXXXXXXX)
function print_captured_output {
kill -9 $spinner_pid

npm run IB_prod_no_watch_fr -- --max_old_space_size=$max_old_space_size > $scratch/ib_prod_fr_build_out 2> $scratch/ib_prod_fr_build_err &
ib_prod_fr_pid=$!
[ -f $scratch/ib_prod_en_build_out ] && cat $scratch/ib_prod_en_build_out3
[ -f $scratch/ib_prod_en_build_err ] && cat $scratch/ib_prod_en_build_err

npm run a11y_prod_no_watch_en -- --max_old_space_size=$max_old_space_size > $scratch/a11y_prod_en_build_out 2> $scratch/a11y_prod_en_build_err &
a11y_prod_en_pid=$!
[ -f $scratch/ib_prod_fr_build_out ] && cat $scratch/ib_prod_fr_build_out
[ -f $scratch/ib_prod_fr_build_err ] && cat $scratch/ib_prod_fr_build_err

npm run a11y_prod_no_watch_fr -- --max_old_space_size=$max_old_space_size > $scratch/a11y_prod_fr_build_out 2> $scratch/a11y_prod_fr_build_err &
a11y_prod_fr_pid=$!

wait $ib_prod_en_pid
wait $ib_prod_fr_pid
wait $a11y_prod_en_pid
wait $a11y_prod_fr_pid
elif [ $concurrency == "half" ]; then
# Same as "full" concurrency, but only run two builds at a time
[ -f $scratch/a11y_prod_en_build_out ] && cat $scratch/a11y_prod_en_build_out
[ -f $scratch/a11y_prod_en_build_err ] && cat $scratch/a11y_prod_en_build_err

[ -f $scratch/a11y_prod_fr_build_out ] && cat $scratch/a11y_prod_fr_build_out
[ -f $scratch/a11y_prod_fr_build_err ] && cat $scratch/a11y_prod_fr_build_err
}
trap print_captured_output EXIT

echo ""
echo "Running prod builds in background, half concurrency..."
spinner_pid=$(sh ../scripts/spinner.sh)

npm run IB_prod_no_watch_en -- --max_old_space_size=$max_old_space_size > $scratch/ib_prod_en_build_out 2> $scratch/ib_prod_en_build_err &
npm run IB_prod_no_watch_en > $scratch/ib_prod_en_build_out 2> $scratch/ib_prod_en_build_err &
ib_prod_en_pid=$!

npm run IB_prod_no_watch_fr -- --max_old_space_size=$max_old_space_size > $scratch/ib_prod_fr_build_out 2> $scratch/ib_prod_fr_build_err &
npm run IB_prod_no_watch_fr > $scratch/ib_prod_fr_build_out 2> $scratch/ib_prod_fr_build_err &
ib_prod_fr_pid=$!

wait $ib_prod_en_pid
wait $ib_prod_fr_pid

npm run a11y_prod_no_watch_en -- --max_old_space_size=$max_old_space_size > $scratch/a11y_prod_en_build_out 2> $scratch/a11y_prod_en_build_err &
if [ $concurrency == "half" ]; then
wait $ib_prod_en_pid
wait $ib_prod_fr_pid
fi

npm run a11y_prod_no_watch_en > $scratch/a11y_prod_en_build_out 2> $scratch/a11y_prod_en_build_err &
a11y_prod_en_pid=$!

npm run a11y_prod_no_watch_fr -- --max_old_space_size=$max_old_space_size > $scratch/a11y_prod_fr_build_out 2> $scratch/a11y_prod_fr_build_err &
npm run a11y_prod_no_watch_fr > $scratch/a11y_prod_fr_build_out 2> $scratch/a11y_prod_fr_build_err &
a11y_prod_fr_pid=$!

wait $a11y_prod_en_pid
wait $a11y_prod_fr_pid
elif [ $concurrency == "none" ]; then
# Just running all builds one at a time, no backgrounding or output redirection

npm run IB_prod_no_watch_en -- --max_old_space_size=$max_old_space_size

npm run IB_prod_no_watch_fr -- --max_old_space_size=$max_old_space_size

npm run a11y_prod_no_watch_en -- --max_old_space_size=$max_old_space_size

npm run a11y_prod_no_watch_fr -- --max_old_space_size=$max_old_space_size
if [ $concurrency == "half" ]; then
wait $a11y_prod_en_pid
wait $a11y_prod_fr_pid
else
wait $ib_prod_en_pid
wait $ib_prod_fr_pid
wait $a11y_prod_en_pid
wait $a11y_prod_fr_pid
fi
fi

exit
8 changes: 4 additions & 4 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"IB_dev": "node build_code/webpack_starter.js EN FR TARGET-IE11 main_client",
"IB_prod": "node build_code/webpack_starter.js EN FR TARGET-IE11 PROD main_client",
"IB_prod_no_watch": "node build_code/webpack_starter.js EN FR TARGET-IE11 PROD NO-WATCH main_client",
"IB_prod_no_watch_en": "node build_code/webpack_starter.js EN TARGET-IE11 PROD NO-WATCH main_client",
"IB_prod_no_watch_fr": "node build_code/webpack_starter.js FR TARGET-IE11 PROD NO-WATCH main_client",
"IB_prod_no_watch_en": "node --max-old-space-size=${MAX_OLD_SPACE_SIZE:-2048} build_code/webpack_starter.js EN TARGET-IE11 PROD NO-WATCH main_client",
"IB_prod_no_watch_fr": "node --max-old-space-size=${MAX_OLD_SPACE_SIZE:-2048} build_code/webpack_starter.js FR TARGET-IE11 PROD NO-WATCH main_client",
"IB_prod_stats": "node build_code/webpack_starter.js EN TARGET-IE11 PROD STATS main_client",
"IB_prod_stats_save_baseline": "node build_code/webpack_starter.js EN TARGET-IE11 PROD STATS STATS-BASELINE main_client",
"IB_prod_stats_no_compare": "node build_code/webpack_starter.js EN TARGET-IE11 PROD STATS NO-COMPARE main_client",
Expand All @@ -22,8 +22,8 @@
"a11y_dev": "node build_code/webpack_starter.js EN FR TARGET-IE11 a11y_client",
"a11y_prod": "node build_code/webpack_starter.js EN FR TARGET-IE11 PROD a11y_client",
"a11y_prod_no_watch": "node build_code/webpack_starter.js EN FR TARGET-IE11 PROD NO-WATCH a11y_client",
"a11y_prod_no_watch_en": "node build_code/webpack_starter.js EN TARGET-IE11 PROD NO-WATCH a11y_client",
"a11y_prod_no_watch_fr": "node build_code/webpack_starter.js FR TARGET-IE11 PROD NO-WATCH a11y_client",
"a11y_prod_no_watch_en": "node --max-old-space-size=${MAX_OLD_SPACE_SIZE:-2048} build_code/webpack_starter.js EN TARGET-IE11 PROD NO-WATCH a11y_client",
"a11y_prod_no_watch_fr": "node --max-old-space-size=${MAX_OLD_SPACE_SIZE:-2048} build_code/webpack_starter.js FR TARGET-IE11 PROD NO-WATCH a11y_client",
"route_load_tests": "node browser-tests/route-load-tests.js --browser chrome",
"ci_route_load_tests": "node browser-tests/route-load-tests.js --browser chromium --sandbox false --concurrency 8",
"ci_serve": "http-server -s -a 127.0.0.1",
Expand Down

0 comments on commit 8e3d95a

Please sign in to comment.