From 04a41a91cac5dff2350cced5ed8667d2b2c2c31f Mon Sep 17 00:00:00 2001 From: Jarda Snajdr Date: Tue, 18 Feb 2020 09:15:30 +0100 Subject: [PATCH 1/2] Move code of the icfy-analyze CircleCI task to a NPM script In hope to get better error handling a recovery, I'm moving the commands for the `icfy-analyze` CircleCI task (the `npm run preanalyze-bundles`, running the `bin/analyze-icfy.js` script, moving files to artifacts folder) to a NPM script called `analyze-icfy`. That script chains the steps using `&&` operator, relying on exit codes. That should be more reliable (or at least more comprehensible) than the `set +o errexit` bash option. This also creates a `build-client-stats` NPM script that's used by both `analyze-bundles` and `analyze-icfy` scripts. --- .circleci/config.yml | 6 +----- package.json | 5 +++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 916fab7b2fb37..05bc9c63c5a45 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -475,11 +475,7 @@ jobs: environment: NODE_ENV: 'production' BROWSERSLIST_ENV: 'defaults' - command: | - set +o errexit - npm run preanalyze-bundles - node --max-old-space-size=4096 bin/icfy-analyze.js - mv client/stats.json client/chart.json "$CIRCLE_ARTIFACTS/icfy" + command: npm run analyze-icfy - save_cache: *save-terser-cache - save_cache: *save-babel-client-cache - store-artifacts-and-test-results diff --git a/package.json b/package.json index 218d7d8914d03..de6c3b93e412f 100644 --- a/package.json +++ b/package.json @@ -59,8 +59,8 @@ "npm": "^6.12.1" }, "scripts": { - "preanalyze-bundles": "cross-env-shell NODE_ENV=production CALYPSO_ENV=production EMIT_STATS=true PROGRESS=true npm run -s build-client-evergreen", - "analyze-bundles": "webpack-bundle-analyzer client/stats.json public/evergreen -h 127.0.0.1 -p 9898 -s gzip", + "analyze-bundles": "npm run build-client-stats && webpack-bundle-analyzer client/stats.json public/evergreen -h 127.0.0.1 -p 9898 -s gzip", + "analyze-icfy": "npm run build-client-stats && node --max-old-space-size=4096 bin/icfy-analyze.js && mv client/stats.json client/chart.json \"$CIRCLE_ARTIFACTS/icfy\"", "autoprefixer": "postcss -u autoprefixer -r --no-map --config packages/calypso-build/postcss.config.js", "postcss": "postcss -r --config packages/calypso-build/postcss.config.js", "prebuild": "npm run install-if-deps-outdated", @@ -81,6 +81,7 @@ "build-client-both": "CONCURRENT_BUILDS=2 concurrently -c cyan -n \"fallback ,evergreen\" \"npm run build-client-fallback\" \"npm run build-client-evergreen\"", "build-client-if-prod": "node -e \"process.env.CALYPSO_ENV === 'production' && process.exit(1)\" || npm run build-client-both", "build-client-if-desktop": "node -e \"(process.env.CALYPSO_ENV === 'desktop' || process.env.CALYPSO_ENV === 'desktop-development') && process.exit(1)\" || npm run build-client-fallback", + "build-client-stats": "cross-env-shell NODE_ENV=production CALYPSO_ENV=production EMIT_STATS=true PROGRESS=true npm run build-client-evergreen", "build-packages": "npx lerna run prepare --stream", "build-packages:watch": "chokidar \"./packages/**\" -i \"./packages/*/dist/**\" -i \"**.css\" -i \"**.d.ts\" --debounce 1000 --throttle 10000 -c \"npm run build-packages\"", "clean": "npm run clean:packages && npm run clean:build && npm run clean:public", From 02d3d34c9aff26e8c0bf713ab271e7cd9106226b Mon Sep 17 00:00:00 2001 From: Jarda Snajdr Date: Tue, 18 Feb 2020 11:10:03 +0100 Subject: [PATCH 2/2] Remove usage of cross-env from build scripts until its exit code bugs are fixed --- package.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index de6c3b93e412f..403f58a3a4c5e 100644 --- a/package.json +++ b/package.json @@ -72,16 +72,16 @@ "build-docker": "node bin/build-docker.js", "build-static": "npx ncp static public", "prebuild-server": "mkdirp build", - "build-server": "cross-env-shell BROWSERSLIST_ENV=server webpack --config client/webpack.config.node.js --display errors-only", + "build-server": "BROWSERSLIST_ENV=server webpack --config client/webpack.config.node.js --display errors-only", "build-client": "npm run build-client-evergreen", "build-client-do": "node ${NODE_ARGS:---max_old_space_size=8192} ./node_modules/webpack/bin/webpack.js --config client/webpack.config.js --display errors-only", - "build-client-fallback": "cross-env-shell BROWSERSLIST_ENV=defaults npm run build-client-do", + "build-client-fallback": "BROWSERSLIST_ENV=defaults npm run build-client-do", "postbuild-client-fallback": "npm run validate-fallback-es5", - "build-client-evergreen": "cross-env-shell BROWSERSLIST_ENV=evergreen npm run build-client-do", + "build-client-evergreen": "BROWSERSLIST_ENV=evergreen npm run build-client-do", "build-client-both": "CONCURRENT_BUILDS=2 concurrently -c cyan -n \"fallback ,evergreen\" \"npm run build-client-fallback\" \"npm run build-client-evergreen\"", "build-client-if-prod": "node -e \"process.env.CALYPSO_ENV === 'production' && process.exit(1)\" || npm run build-client-both", "build-client-if-desktop": "node -e \"(process.env.CALYPSO_ENV === 'desktop' || process.env.CALYPSO_ENV === 'desktop-development') && process.exit(1)\" || npm run build-client-fallback", - "build-client-stats": "cross-env-shell NODE_ENV=production CALYPSO_ENV=production EMIT_STATS=true PROGRESS=true npm run build-client-evergreen", + "build-client-stats": "NODE_ENV=production CALYPSO_ENV=production EMIT_STATS=true PROGRESS=true npm run build-client-evergreen", "build-packages": "npx lerna run prepare --stream", "build-packages:watch": "chokidar \"./packages/**\" -i \"./packages/*/dist/**\" -i \"**.css\" -i \"**.d.ts\" --debounce 1000 --throttle 10000 -c \"npm run build-packages\"", "clean": "npm run clean:packages && npm run clean:build && npm run clean:public", @@ -107,8 +107,8 @@ "poststart": "run-p -s start-build-if-web start-build-if-desktop build-packages:watch", "reformat-files": "./node_modules/.bin/prettier --ignore-path .eslintignore --write \"**/*.{js,jsx,json,ts,tsx}\"", "start-build-do": "node ${NODE_ARGS:---max_old_space_size=8192} build/bundle.js", - "start-build-fallback": "cross-env-shell BROWSERSLIST_ENV=defaults npm run start-build-do", - "start-build-evergreen": "cross-env-shell BROWSERSLIST_ENV=evergreen npm run start-build-do", + "start-build-fallback": "BROWSERSLIST_ENV=defaults npm run start-build-do", + "start-build-evergreen": "BROWSERSLIST_ENV=evergreen npm run start-build-do", "start-build-if-desktop": "node -e \"(process.env.CALYPSO_ENV === 'desktop' || process.env.CALYPSO_ENV === 'desktop-development') && process.exit(1)\" || npm run start-build-fallback", "start-build-if-web": "node -e \"(process.env.CALYPSO_ENV !== 'desktop' && process.env.CALYPSO_ENV !== 'desktop-development') && process.exit(1)\" || npm run start-build-evergreen", "pretest": "npm run install-if-deps-outdated", @@ -132,7 +132,7 @@ "typecheck": "tsc --noEmit", "update-deps": "npx rimraf package-lock.json && npm run distclean && PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true npm i && replace --silent 'http://' 'https://' . --recursive --include='package-lock.json' && touch -m node_modules", "validate-fallback-es5": "npx eslint --parser-options=ecmaVersion:5 --no-eslintrc --no-ignore ./public/fallback/*.js", - "prewhybundled": "cross-env-shell NODE_ENV=production CALYPSO_ENV=production EMIT_STATS=withreasons npm run -s build-client-evergreen", + "prewhybundled": "NODE_ENV=production CALYPSO_ENV=production EMIT_STATS=withreasons npm run -s build-client-evergreen", "whybundled": "whybundled client/stats.json", "composite-checkout-demo": "webpack-dev-server --config ./packages/composite-checkout/webpack.config.demo.js --mode development", "components:storybook:start": "start-storybook -c packages/components/.storybook",