chore(CI): upgrade to Circle CI v2 and leverage multiple containers for demo builds (#10991)

* trying Circle CI v2

* paths are fun

* seeing how long a demos build takes

* Batching Demo builds

* testing demo builds on CI2

* batches count from 0

* ok, looks good. preparing for master branch

* forgot `production=true` flag. let’s test that quick.

* forgot to save the file

* making sure that docs are still copied over to ionic-site in the deploy phase

* getting ready for the PR again
This commit is contained in:
Perry Govier
2017-03-30 21:32:29 -05:00
committed by Dan Bucholtz
parent eb468d2530
commit 44f36c4509
3 changed files with 67 additions and 25 deletions

View File

@@ -20,7 +20,6 @@ task('demos.prod', ['demos.prepare'], (done: Function) => {
// okay, first find out all of the demos tests to run by finding all of the 'main.ts' files
filterDemosEntryPoints().then((filePaths: string[]) => {
console.log(`Compiling ${filePaths.length} Demos ...`);
return buildDemos(filePaths);
}).then(() => {
done();
@@ -56,7 +55,15 @@ function getDemosEntryPoints() {
function buildDemos(filePaths: string[]) {
const functions = filePaths.map(filePath => () => {
var batches = chunkArrayInGroups(filePaths, argv.batches || 1);
var batch = argv.batch || 0;
if(batch >= batches.length) {
throw new Error(`Batch number higher than total number of batches.`);
}
console.log(`Compiling ${batches[batch].length} of ${filePaths.length} Demos ...`);
const functions = batches[batch].map(filePath => () => {
return buildDemo(filePath);
});
let concurrentNumber = 2;
@@ -94,6 +101,17 @@ function buildDemo(filePath: string) {
});
}
function chunkArrayInGroups(arr, size) {
var result = [];
for(var i = 0; i < arr.length; i++) {
if (!Array.isArray(result[i % size])) {
result[i % size] = [];
}
result[i % size].push(arr[i]);
}
return result;
}
task('demos.clean', (done: Function) => {
// this is a super hack, but it works for now
if (argv.skipClean) {

View File

@@ -30,7 +30,8 @@ task('docs.dgeni', () => {
}
});
task('docs.demos', ['demos.prod'], (done: Function) => {
task('docs.demos', (done: Function) => {
// Copy demos already built from gulp demos.prod task to ionic-site
const config = require('../../config.json');
const outputDir = join(config.docsDest, 'demos');
let promises = [];