From c1f205038e9a5bea9971335334bd63b2d57291c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Tue, 11 Aug 2020 16:01:30 -0400 Subject: [PATCH 1/7] chore: run node 6 and 8 test on GitHub actions --- .github/workflows/ci.yml | 45 ++++++++++++++++++++++++++++++++++ .github/workflows/coverage.yml | 21 ---------------- .travis.yml | 3 +-- 3 files changed, 46 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000000..ca3783bf74d5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,45 @@ +name: Node CI + +on: [push, pull_request] + +jobs: + latest-node-test: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Use Node.js latest + uses: actions/setup-node@v2-beta + with: + node-version: "*" + - name: Generate coverage report + run: | + make -j test-ci-coverage + - name: Upload coverage report + uses: codecov/codecov-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + + legacy-node-test: + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + node-version: [6.x, 8.x] + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Use Node.js latest + uses: actions/setup-node@v2-beta + with: + node-version: "*" # Build Babel on latest node versions + - name: Build + run: | + BABEL_ENV=production make -j bootstrap + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2-beta + with: + node-version: ${{ matrix.node-version }} + - name: Test on node.js ${{ matrix.node-version }} + run: | + BABEL_ENV=test ./node_modules/.bin/jest --ci diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml deleted file mode 100644 index f50b56856cea..000000000000 --- a/.github/workflows/coverage.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Report Coverage - -on: [push, pull_request] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Use Node.js latest - uses: actions/setup-node@v2-beta - with: - node-version: "*" - - name: Generate coverage report - run: | - make -j test-ci-coverage - - name: Upload coverage report - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.travis.yml b/.travis.yml index 0b5f27f648e6..f9f3ddcf42ee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,10 +41,9 @@ matrix: directories: - $HOME/AppData/Local/Temp/chocolatey # Continue node_js matrix - - node_js: "6" - node_js: "12" - node_js: "10" - - node_js: "8" + # Node.js 6 and 8 are tested on GitHub versions - node_js: "node" env: JOB=babel-parser-flow-tests - node_js: "node" From 888fc9ed3615a22e20d31cfc52a04a369a305448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Tue, 11 Aug 2020 16:46:43 -0400 Subject: [PATCH 2/7] fix: apply dynamicImportUrlToPath polyfill on publish --- babel.config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/babel.config.js b/babel.config.js index db550768d642..a5c7c6f3ba16 100644 --- a/babel.config.js +++ b/babel.config.js @@ -169,10 +169,10 @@ module.exports = function (api) { // the original absolute path. // NOTE: This plugin must run before @babel/plugin-transform-modules-commonjs, // and assumes that the target is the current node version. -function dynamicImportUrlToPath({ template }) { +function dynamicImportUrlToPath({ template, env }) { const currentNodeSupportsURL = !!require("url").pathToFileURL; - if (currentNodeSupportsURL) { + if (currentNodeSupportsURL && env() !== "production") { return { visitor: { CallExpression(path) { From 64f93a28015c4edc4f1314bec748a71b549bd389 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Tue, 11 Aug 2020 17:22:11 -0400 Subject: [PATCH 3/7] Apply hacks unconditionally --- .github/workflows/ci.yml | 4 ++-- babel.config.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ca3783bf74d5..d95d6dbb0f24 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,7 +3,7 @@ name: Node CI on: [push, pull_request] jobs: - latest-node-test: + test: runs-on: ubuntu-latest steps: - name: Checkout code @@ -20,7 +20,7 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} - legacy-node-test: + legacy-node-version-test: runs-on: ubuntu-latest strategy: fail-fast: true diff --git a/babel.config.js b/babel.config.js index a5c7c6f3ba16..e28869a0f676 100644 --- a/babel.config.js +++ b/babel.config.js @@ -109,7 +109,7 @@ module.exports = function (api) { "@babel/proposal-object-rest-spread", { useBuiltIns: true, loose: true }, ], - compileDynamicImport ? dynamicImportUrlToPath : null, + dynamicImportUrlToPath, compileDynamicImport ? "@babel/plugin-proposal-dynamic-import" : null, convertESM ? "@babel/transform-modules-commonjs" : null, From 25ace84eed2cd611ad9dcc82530323b6035e923b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Tue, 11 Aug 2020 18:11:05 -0400 Subject: [PATCH 4/7] try fix highlight issues --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d95d6dbb0f24..35fcf8552fce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,5 +41,7 @@ jobs: with: node-version: ${{ matrix.node-version }} - name: Test on node.js ${{ matrix.node-version }} + # Hack: --color has supports-color@5 returned true for GitHub CI + # Remove once `chalk` is bumped to 4.0. run: | - BABEL_ENV=test ./node_modules/.bin/jest --ci + BABEL_ENV=test node ./node_modules/.bin/jest --ci --color From 9f14d986601b552f3758f3cdad9a6814d10b3126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Thu, 13 Aug 2020 11:08:06 -0400 Subject: [PATCH 5/7] address review comments --- .github/workflows/ci.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 35fcf8552fce..932ee14d61dc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,8 +10,6 @@ jobs: uses: actions/checkout@v2 - name: Use Node.js latest uses: actions/setup-node@v2-beta - with: - node-version: "*" - name: Generate coverage report run: | make -j test-ci-coverage @@ -23,16 +21,13 @@ jobs: legacy-node-version-test: runs-on: ubuntu-latest strategy: - fail-fast: true matrix: node-version: [6.x, 8.x] steps: - name: Checkout code uses: actions/checkout@v2 - name: Use Node.js latest - uses: actions/setup-node@v2-beta - with: - node-version: "*" # Build Babel on latest node versions + uses: actions/setup-node@v2-beta # Build Babel on latest node versions - name: Build run: | BABEL_ENV=production make -j bootstrap From c07cc06b59ed6a623a7678dd10b9a15e864cc510 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Thu, 13 Aug 2020 14:38:41 -0400 Subject: [PATCH 6/7] chore: add test-legacy build env --- .github/workflows/ci.yml | 2 +- babel.config.js | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 932ee14d61dc..877c5a9b0d9a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: uses: actions/setup-node@v2-beta # Build Babel on latest node versions - name: Build run: | - BABEL_ENV=production make -j bootstrap + BABEL_ENV=test-legacy make -j bootstrap - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v2-beta with: diff --git a/babel.config.js b/babel.config.js index e28869a0f676..f6fb35028752 100644 --- a/babel.config.js +++ b/babel.config.js @@ -17,7 +17,8 @@ module.exports = function (api) { }; const envOpts = Object.assign({}, envOptsNoTargets); - const compileDynamicImport = env === "test" || env === "development"; + const compileDynamicImport = + env === "test" || env === "development" || env === "test-legacy"; let convertESM = true; let ignoreLib = true; @@ -55,6 +56,7 @@ module.exports = function (api) { ); if (env === "rollup") envOpts.targets = { node: nodeVersion }; break; + case "test-legacy": // In test-legacy environment, we build babel on latest node but test on minimum supported legacy versions case "production": // Config during builds before publish. envOpts.targets = { @@ -109,7 +111,7 @@ module.exports = function (api) { "@babel/proposal-object-rest-spread", { useBuiltIns: true, loose: true }, ], - dynamicImportUrlToPath, + compileDynamicImport ? dynamicImportUrlToPath : null, compileDynamicImport ? "@babel/plugin-proposal-dynamic-import" : null, convertESM ? "@babel/transform-modules-commonjs" : null, @@ -170,9 +172,9 @@ module.exports = function (api) { // NOTE: This plugin must run before @babel/plugin-transform-modules-commonjs, // and assumes that the target is the current node version. function dynamicImportUrlToPath({ template, env }) { - const currentNodeSupportsURL = !!require("url").pathToFileURL; - - if (currentNodeSupportsURL && env() !== "production") { + const currentNodeSupportsURL = + !!require("url").pathToFileURL && env() !== "test-legacy"; // test-legacy is run on legacy node versions without pathToFileURL support + if (currentNodeSupportsURL) { return { visitor: { CallExpression(path) { From c3cf71cf15165c88eab90b787d1c007356510a57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Fri, 14 Aug 2020 14:19:33 -0400 Subject: [PATCH 7/7] Update .travis.yml [skip ci] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Nicolò Ribaudo --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f9f3ddcf42ee..6f060cbcee73 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,7 +43,7 @@ matrix: # Continue node_js matrix - node_js: "12" - node_js: "10" - # Node.js 6 and 8 are tested on GitHub versions + # Node.js 6 and 8 are tested on GitHub actions - node_js: "node" env: JOB=babel-parser-flow-tests - node_js: "node"