Skip to content

Commit

Permalink
Speed up travis build (#9403)
Browse files Browse the repository at this point in the history
The travis build is now sharded into 4 parts: pre_build_checks, integration_tests, unit_tests, and validator_tests, each run in parallel. This should halve the total build time for PRs and pushes to master.
  • Loading branch information
rsimha authored May 18, 2017
1 parent 3af676e commit f62a93d
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 36 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ branches:
env:
global:
- NPM_CONFIG_PROGRESS="false"
matrix:
- BUILD_SHARD="pre_build_checks"
- BUILD_SHARD="integration_tests"
- BUILD_SHARD="unit_tests"
- BUILD_SHARD="validator_tests"
cache:
yarn: true
directories:
Expand Down
109 changes: 73 additions & 36 deletions build-system/pr-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,28 +212,34 @@ const command = {
let docFiles = files.filter(isDocFile);
timedExecOrDie(`${gulp} check-links --files ${docFiles.join(',')}`);
},
buildRuntime: function() {
runPreBuildChecks: function() {
timedExecOrDie(`${gulp} clean`);
timedExecOrDie(`${gulp} lint`);
},
buildRuntime: function() {
timedExecOrDie(`${gulp} clean`);
timedExecOrDie(`${gulp} build`);
timedExecOrDie(`${gulp} check-types`);
timedExecOrDie(`${gulp} dist --fortesting`);
},
testRuntime: function() {
// dep-check needs to occur after build since we rely on build to generate
// the css files into js files.
runDepAndTypeChecks: function() {
timedExecOrDie(`${gulp} build --css-only`);
timedExecOrDie(`${gulp} dep-check`);
timedExecOrDie(`${gulp} check-types`);
},
runUnitTests: function() {
// Unit tests with Travis' default chromium
timedExecOrDie(`${gulp} test --nobuild --compiled`);
// Integration tests with all saucelabs browsers
timedExecOrDie(
`${gulp} test --nobuild --saucelabs --integration --compiled`);
// All unit tests with an old chrome (best we can do right now to pass tests
// and not start relying on new features).
// Disabled because it regressed. Better to run the other saucelabs tests.
// timedExecOrDie(
// `${gulp} test --nobuild --saucelabs --oldchrome --compiled`);
},
runIntegrationTests: function() {
// Integration tests with all saucelabs browsers
timedExecOrDie(
`${gulp} test --nobuild --saucelabs --integration --compiled`);
},
runVisualDiffTests: function() {
// This must only be run for push builds, since Travis hides the encrypted
// environment variables required by Percy during pull request builds.
Expand All @@ -252,14 +258,30 @@ const command = {
};

function runAllCommands() {
command.testBuildSystem();
// Skip testDocumentLinks() during push builds.
command.buildRuntime();
command.presubmit();
command.runVisualDiffTests(); // Only called during push builds.
command.testRuntime();
command.buildValidatorWebUI();
command.buildValidator();
// Run different sets of independent tasks in parallel to reduce build time.
if (process.env.BUILD_SHARD == "pre_build_checks") {
command.testBuildSystem();
command.runPreBuildChecks();
command.runDepAndTypeChecks();
// Skip testDocumentLinks() during push builds.
}
if (process.env.BUILD_SHARD == "integration_tests") {
command.buildRuntime();
command.presubmit(); // Must be run after the runtime is built.
command.runVisualDiffTests(); // Only called during push builds.
command.runIntegrationTests();
}
if (process.env.BUILD_SHARD == "unit_tests") {
// Unit tests should need a CSS-only build, but for now, we need a full dist
// because some of the tests are integration tests.
// TODO(rsimha-amp, 9404): Clean up unit tests and change to css-only build.
command.buildRuntime();
command.runUnitTests();
}
if (process.env.BUILD_SHARD == "validator_tests") {
command.buildValidatorWebUI();
command.buildValidator();
}
}

/**
Expand Down Expand Up @@ -318,34 +340,49 @@ function main(argv) {
'\npr-check.js: detected build targets: ' +
sortedBuildTargets.join(', ') + '\n');

if (buildTargets.has('BUILD_SYSTEM')) {
command.testBuildSystem();
}
// Run different sets of independent tasks in parallel to reduce build time.
if (process.env.BUILD_SHARD == "pre_build_checks") {
if (buildTargets.has('BUILD_SYSTEM')) {
command.testBuildSystem();
}

if (buildTargets.has('DOCS')) {
command.testDocumentLinks(files);
}
if (buildTargets.has('DOCS')) {
command.testDocumentLinks(files);
}

if (buildTargets.has('RUNTIME')) {
command.buildRuntime();
if (buildTargets.has('RUNTIME')) {
command.runPreBuildChecks();
command.runDepAndTypeChecks();
}
}

// Presubmit needs to run after `gulp dist` as some checks runs through the
// dist/ folder.
// Also presubmit always needs to run even for just docs to check for
// copyright at the top.
command.presubmit();

if (buildTargets.has('RUNTIME')) {
command.testRuntime();
if (process.env.BUILD_SHARD == "integration_tests") {
if (buildTargets.has('RUNTIME')) {
command.buildRuntime();
command.runIntegrationTests();
}
// Presubmit needs to run after `gulp dist` as some checks run through
// the dist/ folder.
// Also presubmit always needs to run even for just docs to check for
// copyright at the top.
command.presubmit();
}

if (buildTargets.has('VALIDATOR_WEBUI')) {
command.buildValidatorWebUI();
if (process.env.BUILD_SHARD == "unit_tests" && buildTargets.has('RUNTIME')) {
// Unit tests should need a CSS-only build, but for now, we need a full dist
// because some of the tests are integration tests.
// TODO(rsimha-amp, 9404): Clean up unit tests and change to css-only build.
command.buildRuntime();
command.runUnitTests();
}

if (buildTargets.has('VALIDATOR')) {
command.buildValidator();
if (process.env.BUILD_SHARD == "validator_tests") {
if (buildTargets.has('VALIDATOR_WEBUI')) {
command.buildValidatorWebUI();
}
if (buildTargets.has('VALIDATOR')) {
command.buildValidator();
}
}

stopTimer('pr-check.js', startTime);
Expand Down

0 comments on commit f62a93d

Please sign in to comment.