From 2649e1757f0d37f4e92b0302742e499d12de32d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Fri, 27 Sep 2019 15:09:09 -0400 Subject: [PATCH] chore: revamp Makefile to for parallel builds --- .travis.yml | 33 +++++-------- Makefile | 139 ++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 109 insertions(+), 63 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1ae4cb229356..14028abcd4d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,13 +6,6 @@ cache: os: linux -node_js: - # We test the latest version on circleci - - "11" - - "10" - - "8" - - "6" - env: global: - PATH=$HOME/.yarn/bin:$PATH @@ -21,33 +14,33 @@ env: before_install: - curl -o- -L https://yarnpkg.com/install.sh | bash -install: - # the `make test-ci` script runs this command already - - if [ "$JOB" != "test" ] && [ "$JOB" != "lint" ]; then yarn install; fi - - if [ "$JOB" = "lint" ]; then make bootstrap; fi - before_script: - if [ "$TRAVIS_OS_NAME" = "windows" ]; then choco install make; fi - - if [ "$JOB" = "babel-parser-flow-tests" ]; then make bootstrap-flow; fi - - if [ "$JOB" = "babel-parser-test262-tests" ]; then make bootstrap-test262; fi script: - - if [ "$JOB" = "test" ]; then make test-ci; fi - - if [ "$JOB" = "lint" ]; then make lint && make flow; fi - - if [ "$JOB" = "babel-parser-flow-tests" ]; then make test-flow-ci; fi - - if [ "$JOB" = "babel-parser-test262-tests" ]; then make test-test262-ci; fi + - if [ "$JOB" = "test" ]; then make -j test-ci; fi + - if [ "$JOB" = "lint" ]; then make -j code-quality-ci; fi + - if [ "$JOB" = "babel-parser-flow-tests" ]; then make -j test-flow-ci; fi + - if [ "$JOB" = "babel-parser-test262-tests" ]; then make -j test-test262-ci; fi matrix: fast_finish: true include: + - node_js: "node" + env: JOB=lint + # We test the latest version on circleci + - node_js: "11" + - node_js: "10" + # Move `windows` build to be the fourth since it is slow - os: windows node_js: "node" env: - JOB=test # https://travis-ci.community/t/build-doesnt-finish-after-completing-tests/288/9 - YARN_GPG=no - - node_js: "node" - env: JOB=lint + # Continue node_js matrix + - node_js: "8" + - node_js: "6" - node_js: "node" env: JOB=babel-parser-flow-tests - node_js: "node" diff --git a/Makefile b/Makefile index 1e88895bdd81..5506e57b3bd8 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,3 @@ -MAKEFLAGS = -j1 FLOW_COMMIT = 09669846b7a7ca5a6c23c12d56bb3bebdafd67e9 TEST262_COMMIT = ce2dfd49d13740e995c96c34686d45c7960e628c @@ -9,21 +8,42 @@ SOURCES = packages codemods .PHONY: build build-dist watch lint fix clean test-clean test-only test test-ci publish bootstrap -build: clean clean-lib +build: build-bundle +ifneq ("$(BABEL_COVERAGE)", "true") + $(MAKE) build-standalone +endif + +build-bundle: clean clean-lib yarn gulp build - node packages/babel-standalone/scripts/generate.js - node packages/babel-types/scripts/generateTypeHelpers.js + $(MAKE) generate-standalone generate-type-helpers # call build again as the generated files might need to be compiled again. yarn gulp build - # generate flow and typescript typings + $(MAKE) build-typings + $(MAKE) build-dist + +build-bundle-ci: bootstrap-only + $(MAKE) build-bundle + +generate-standalone: + node packages/babel-standalone/scripts/generate.js + +generate-type-helpers: + node packages/babel-types/scripts/generateTypeHelpers.js + +build-typings: build-flow-typings build-typescript-typings + +build-flow-typings: node packages/babel-types/scripts/generators/flow.js > packages/babel-types/lib/index.js.flow + +build-typescript-typings: node packages/babel-types/scripts/generators/typescript.js > packages/babel-types/lib/index.d.ts -ifneq ("$(BABEL_COVERAGE)", "true") - make build-standalone - make build-preset-env-standalone -endif -build-standalone: +build-standalone: build-babel-standalone build-preset-env-standalone + +build-standalone-ci: build-bundle-ci + $(MAKE) build-standalone + +build-babel-standalone: yarn gulp build-babel-standalone build-preset-env-standalone: @@ -35,25 +55,48 @@ prepublish-build-standalone: prepublish-build-preset-env-standalone: BABEL_ENV=production IS_PUBLISH=true yarn gulp build-babel-preset-env-standalone -build-dist: build +build-dist: build-polyfill-dist build-plugin-transform-runtime-dist + +build-polyfill-dist: cd packages/babel-polyfill; \ - scripts/build-dist.sh - cd packages/babel-plugin-transform-runtime; \ - node scripts/build-dist.js + scripts/build-dist.sh -watch: clean clean-lib +build-plugin-transform-runtime-dist: + cd packages/babel-plugin-transform-runtime; \ + node scripts/build-dist.js +build-no-bundle: clean clean-lib + BABEL_ENV=development yarn gulp build-no-bundle # Ensure that build artifacts for types are created during local # development too. - BABEL_ENV=development yarn gulp build-no-bundle - node packages/babel-types/scripts/generateTypeHelpers.js - node packages/babel-types/scripts/generators/flow.js > packages/babel-types/lib/index.js.flow - node packages/babel-types/scripts/generators/typescript.js > packages/babel-types/lib/index.d.ts + $(MAKE) generate-type-helpers + $(MAKE) build-typings + +watch: build-no-bundle BABEL_ENV=development yarn gulp watch +code-quality-ci: flowcheck-ci lint-ci + +flowcheck-ci: bootstrap-flowcheck + $(MAKE) flow + +code-quality: flow lint + flow: yarn flow check --strip-root +bootstrap-flowcheck: bootstrap-only + yarn gulp build-babel-types + $(MAKE) build-typings + +lint-ci: lint-js-ci lint-ts-ci + +lint-js-ci: bootstrap-only + $(MAKE) lint-js + +lint-ts-ci: bootstrap-flowcheck + $(MAKE) lint-ts + lint: lint-js lint-ts lint-js: @@ -62,7 +105,9 @@ lint-js: lint-ts: scripts/tests/typescript/lint.sh -fix: fix-json +fix: fix-json fix-js + +fix-js: yarn eslint scripts $(SOURCES) '*.js' --format=codeframe --fix fix-json: @@ -82,18 +127,20 @@ test-clean: # Does not work on Windows; use "yarn jest" instead test-only: BABEL_ENV=test ./scripts/test.sh - make test-clean + $(MAKE) test-clean test: lint test-only -test-ci: bootstrap +test-ci: jest-ci + +jest-ci: build-standalone-ci BABEL_ENV=test yarn jest --maxWorkers=4 --ci - make test-clean + $(MAKE) test-clean # Does not work on Windows test-ci-coverage: SHELL:=/bin/bash test-ci-coverage: - BABEL_COVERAGE=true BABEL_ENV=test make bootstrap + BABEL_COVERAGE=true BABEL_ENV=test $(MAKE) bootstrap BABEL_ENV=test TEST_TYPE=cov ./scripts/test-cov.sh bash <(curl -s https://codecov.io/bash) -f coverage/coverage-final.json @@ -106,7 +153,8 @@ bootstrap-flow: test-flow: node scripts/tests/flow/run_babel_parser_flow_tests.js -test-flow-ci: bootstrap test-flow +test-flow-ci: build-bundle-ci bootstrap-flow + $(MAKE) test-flow test-flow-update-whitelist: node scripts/tests/flow/run_babel_parser_flow_tests.js --update-whitelist @@ -117,10 +165,12 @@ bootstrap-test262: git clone --branch=master --single-branch --shallow-since=2019-01-01 https://github.com/tc39/test262.git build/test262 cd build/test262 && git checkout $(TEST262_COMMIT) + test-test262: node scripts/tests/test262/run_babel_parser_test262.js -test-test262-ci: bootstrap test-test262 +test-test262-ci: build-bundle-ci bootstrap-test262 + $(MAKE) test-test262 test-test262-update-whitelist: node scripts/tests/test262/run_babel_parser_test262.js --update-whitelist @@ -129,18 +179,14 @@ test-test262-update-whitelist: clone-license: ./scripts/clone-license.sh -prepublish-build: - make clean-lib - rm -rf packages/babel-runtime/helpers - rm -rf packages/babel-runtime-corejs2/helpers - rm -rf packages/babel-runtime-corejs2/core-js - NODE_ENV=production BABEL_ENV=production make build-dist - make clone-license +prepublish-build: clean-lib clean-runtime-helpers + NODE_ENV=production BABEL_ENV=production $(MAKE) build-dist + $(MAKE) clone-license prepublish: - make bootstrap-only - make prepublish-build - make test + $(MAKE) bootstrap-only + $(MAKE) prepublish-build + $(MAKE) test new-version: git pull --rebase @@ -149,7 +195,7 @@ new-version: # NOTE: Run make new-version first publish: prepublish yarn lerna publish from-git --require-scripts - make clean + $(MAKE) clean publish-ci: prepublish ifneq ("$(NPM_TOKEN)", "") @@ -160,21 +206,28 @@ else endif yarn lerna publish from-git --require-scripts --yes rm -f .npmrc - make clean + $(MAKE) clean + +bootstrap-only: lerna-bootstrap -bootstrap-only: clean-all +yarn-install: clean-all yarn --ignore-engines + +lerna-bootstrap: yarn-install yarn lerna bootstrap -- --ignore-engines bootstrap: bootstrap-only - make build - cd packages/babel-plugin-transform-runtime; \ - node scripts/build-dist.js + $(MAKE) build clean-lib: $(foreach source, $(SOURCES), \ $(call clean-source-lib, $(source))) +clean-runtime-helpers: + rm -rf packages/babel-runtime/helpers + rm -rf packages/babel-runtime-corejs2/helpers + rm -rf packages/babel-runtime-corejs2/core-js + clean-all: rm -rf node_modules rm -rf package-lock.json @@ -183,7 +236,7 @@ clean-all: $(foreach source, $(SOURCES), \ $(call clean-source-all, $(source))) - make clean + $(MAKE) clean define clean-source-lib rm -rf $(1)/*/lib