Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use make -j for parallel build #10506

Merged
merged 5 commits into from Oct 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 15 additions & 23 deletions .travis.yml
Expand Up @@ -6,48 +6,40 @@ cache:

os: linux

node_js:
# We test the latest version on circleci
- "11"
- "10"
- "8"
- "6"

env:
global:
- PATH=$HOME/.yarn/bin:$PATH
- JOB=test

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

install: skip
before_script:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- 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"
# Move `windows` build to be the third 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: "6"
- node_js: "10"
- node_js: "8"
- node_js: "node"
env: JOB=babel-parser-flow-tests
- node_js: "node"
Expand Down
62 changes: 28 additions & 34 deletions Gulpfile.js
Expand Up @@ -11,25 +11,20 @@ const filter = require("gulp-filter");
const gulp = require("gulp");
const path = require("path");
const webpack = require("webpack");
const merge = require("merge-stream");
const rollup = require("rollup");
const rollupBabel = require("rollup-plugin-babel");
const rollupNodeResolve = require("rollup-plugin-node-resolve");
const rollupReplace = require("rollup-plugin-replace");
const { registerStandalonePackageTask } = require("./scripts/gulp-tasks");

const sources = ["codemods", "packages"];
const defaultSourcesGlob = "./@(codemods|packages)/*/src/**/*.js";

function swapSrcWithLib(srcPath) {
const parts = srcPath.split(path.sep);
parts[1] = "lib";
parts[2] = "lib";
return parts.join(path.sep);
}

function getGlobFromSource(source) {
return `./${source}/*/src/**/*.js`;
}

function getIndexFromPackage(name) {
return `${name}/src/index.js`;
}
Expand All @@ -56,32 +51,28 @@ function rename(fn) {
});
}

function buildBabel(exclude) {
return merge(
sources.map(source => {
const base = path.join(__dirname, source);

let stream = gulp.src(getGlobFromSource(source), { base: base });

if (exclude) {
const filters = exclude.map(p => `!**/${p}/**`);
filters.unshift("**");
stream = stream.pipe(filter(filters));
}

return stream
.pipe(errorsLogger())
.pipe(newer({ dest: base, map: swapSrcWithLib }))
.pipe(compilationLogger())
.pipe(babel())
.pipe(
// Passing 'file.relative' because newer() above uses a relative
// path and this keeps it consistent.
rename(file => path.resolve(file.base, swapSrcWithLib(file.relative)))
)
.pipe(gulp.dest(base));
})
);
function buildBabel(exclude, sourcesGlob = defaultSourcesGlob) {
const base = __dirname;

let stream = gulp.src(sourcesGlob, { base: __dirname });

if (exclude) {
const filters = exclude.map(p => `!**/${p}/**`);
filters.unshift("**");
stream = stream.pipe(filter(filters));
}

return stream
.pipe(errorsLogger())
.pipe(newer({ dest: base, map: swapSrcWithLib }))
.pipe(compilationLogger())
.pipe(babel())
.pipe(
// Passing 'file.relative' because newer() above uses a relative
// path and this keeps it consistent.
rename(file => path.resolve(file.base, swapSrcWithLib(file.relative)))
)
.pipe(gulp.dest(base));
}

function buildRollup(packages) {
Expand Down Expand Up @@ -118,6 +109,9 @@ const bundles = ["packages/babel-parser"];

gulp.task("build-rollup", () => buildRollup(bundles));
gulp.task("build-babel", () => buildBabel(/* exclude */ bundles));
gulp.task("build-babel-types", () =>
buildBabel(/* exclude */ bundles, "packages/babel-types/src/**/*.js")
);
gulp.task("build", gulp.parallel("build-rollup", "build-babel"));

gulp.task("default", gulp.series("build"));
Expand All @@ -128,7 +122,7 @@ gulp.task(
"watch",
gulp.series("build-no-bundle", function watch() {
gulpWatch(
sources.map(getGlobFromSource),
defaultSourcesGlob,
{ debounceDelay: 200 },
gulp.task("build-no-bundle")
);
Expand Down