Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 69e9c1e

Browse files
committed
ci: add CLI build track
1 parent 09f79e3 commit 69e9c1e

File tree

20 files changed

+112
-26
lines changed

20 files changed

+112
-26
lines changed

.travis.yml

+7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ env:
1717
# current angular release jobs
1818
- TASK=lint
1919
- TASK="run-e2e-tests --fast" SCRIPT=examples-install.sh
20+
- TASK="run-e2e-tests --fast --lang=ts --cli" SCRIPT=examples-install.sh
2021
- TASK=build-compile SCRIPT=deploy-install.sh WAIT="travis_wait 50" POST_SCRIPT="check-docs.sh -v"
2122
# current angular release branch jobs
2223
- TASK="run-e2e-tests --fast" SCRIPT=examples-install-preview.sh PREVIEW_BRANCH=$LATEST_RELEASE_BRANCH
@@ -27,6 +28,10 @@ env:
2728
matrix:
2829
fast_finish: true
2930
allow_failures:
31+
# cli based e2e tests
32+
- TASK="run-e2e-tests --fast --lang=ts --cli" SCRIPT=examples-install.sh
33+
# current angular release branch jobs
34+
- TASK="run-e2e-tests --fast" SCRIPT=examples-install-preview.sh PREVIEW_BRANCH=$LATEST_RELEASE_BRANCH
3035
# allow current angular release branch and master to fail
3136
# these should be moved to a daily task instead of being ran on every PR
3237
- env: TASK="run-e2e-tests --fast" SCRIPT=examples-install-preview.sh PREVIEW_BRANCH=$LATEST_RELEASE_BRANCH
@@ -39,6 +44,8 @@ before_install:
3944
install:
4045
- npm install --no-optional
4146
- if [[ -n "$SCRIPT" ]]; then echo "EXTRA INSTALL $SCRIPT"; ./scripts/$SCRIPT; fi
47+
# cli e2e tests need [email protected]
48+
- if [[ "$TASK" == "run-e2e-tests --fast --lang=ts --cli" ]]; then (cd public/docs/_examples && npm install [email protected]); fi
4249
before_script:
4350
- sh -e /etc/init.d/xvfb start
4451
script:

gulpfile.js

+43-14
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ var _exampleBoilerplateFiles = [
8989
'styles.css',
9090
'systemjs.config.js',
9191
'tsconfig.json',
92-
'tslint.json'
92+
'tslint.json',
93+
'angular-cli.json'
9394
];
9495

9596
var _exampleDartWebBoilerPlateFiles = ['a2docs.css', 'styles.css'];
@@ -154,6 +155,24 @@ function excludeDartPaths(paths) {
154155
return paths.filter(function (p) { return !isDartPath(p); });
155156
}
156157

158+
// Load example config and set defaults
159+
function getExampleConfig(appDir){
160+
var exampleConfig = {};
161+
try {
162+
exampleConfig = fs.readJsonSync(`${appDir}/${_exampleConfigFilename}`);
163+
} catch (e) { }
164+
165+
exampleConfig.build = exampleConfig.build || 'tsc';
166+
exampleConfig.run = exampleConfig.run || 'http-server:e2e';
167+
168+
// Override config if the cli flag is set for tests
169+
if (argv.cli){
170+
exampleConfig.build = 'build:cli';
171+
exampleConfig.run = 'http-server:cli';
172+
}
173+
return exampleConfig;
174+
}
175+
157176
/**
158177
* Run Protractor End-to-End Specs for Doc Samples
159178
* Alias for 'run-e2e-tests'
@@ -249,11 +268,32 @@ function findAndRunE2eTests(filter, outputFile) {
249268
localExamplePaths = localExamplePaths.filter(function (fn) {
250269
return fn.match('/'+lang+'(?:-[^/]*)?$') != null;
251270
});
271+
252272
localExamplePaths.forEach(function(examplePath) {
253273
examplePaths.push(examplePath);
254274
})
255275
});
256276

277+
// Filter suites that
278+
if (argv.cli){
279+
var cliSuitesSkipped = [];
280+
examplePaths = examplePaths.filter(function (appDir) {
281+
var config = getExampleConfig(appDir);
282+
if (config.skipCli){ cliSuitesSkipped.push(appDir); }
283+
return !config.skipCli;
284+
});
285+
if (cliSuitesSkipped.length > 0){
286+
var log = [''];
287+
log.push(`Suites skipped due to "skipCli" in ${_exampleConfigFilename}:`);
288+
cliSuitesSkipped.forEach(function(val) {
289+
log.push(' ' + val);
290+
});
291+
log = log.join('\n');
292+
gutil.log(log);
293+
fs.appendFileSync(outputFile, log);
294+
}
295+
}
296+
257297
// run the tests sequentially
258298
var status = { passed: [], failed: [] };
259299
return examplePaths.reduce(function (promise, examplePath) {
@@ -275,24 +315,13 @@ function findAndRunE2eTests(filter, outputFile) {
275315
// fileName; then shut down the example. All protractor output is appended
276316
// to the outputFile.
277317
function runE2eTsTests(appDir, outputFile) {
278-
// Grab protractor configuration or defaults to systemjs config.
279-
try {
280-
var exampleConfig = fs.readJsonSync(`${appDir}/${_exampleConfigFilename}`);
281-
} catch (e) {
282-
exampleConfig = {};
283-
}
284-
285-
var config = {
286-
build: exampleConfig.build || 'tsc',
287-
run: exampleConfig.run || 'http-server:e2e'
288-
};
289-
318+
var config = getExampleConfig(appDir);
290319
var appBuildSpawnInfo = spawnExt('npm', ['run', config.build], { cwd: appDir });
291320
var appRunSpawnInfo = spawnExt('npm', ['run', config.run, '--', '-s'], { cwd: appDir });
292321

293322
var run = runProtractor(appBuildSpawnInfo.promise, appDir, appRunSpawnInfo, outputFile);
294323

295-
if (fs.existsSync(appDir + '/aot/index.html')) {
324+
if (fs.existsSync(appDir + '/aot/index.html') && !argv.cli) {
296325
run = run.then(() => runProtractorAoT(appDir, outputFile));
297326
}
298327
return run;

public/docs/_examples/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ systemjs.config.js
88
*/**/tsconfig.json
99
tslint.json
1010
wallaby.js
11+
*/**/angular-cli.json
12+
*/ts/dist/**
1113

1214
_test-output
1315
**/ts/**/*.js
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"apps": [
3+
{
4+
"root": ".",
5+
"main": "app/main.ts",
6+
"styles": [
7+
"styles.css"
8+
],
9+
"scripts": [
10+
"./node_modules/core-js/client/shim.min.js",
11+
"./node_modules/zone.js/dist/zone.js"
12+
]
13+
}
14+
]
15+
}

public/docs/_examples/_boilerplate/package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"start:webpack": "webpack-dev-server --inline --progress --port 8080",
1818
"test:webpack": "karma start karma.webpack.conf.js",
1919
"build:webpack": "rimraf dist && webpack --config config/webpack.prod.js --bail",
20-
"build:cli": "ng build",
20+
"build:cli": "ng build --no-progress",
21+
"build:cli-aot": "ng build --aot --no-progress",
2122
"build:aot": "ngc -p tsconfig-aot.json && rollup -c rollup-config.js",
2223
"build:babel": "babel app -d app --extensions \".es6\" --source-maps",
2324
"copy-dist-files": "node ./copy-dist-files.js",
@@ -27,6 +28,8 @@
2728
"author": "",
2829
"license": "MIT",
2930
"dependencies": {},
30-
"devDependencies": {},
31+
"devDependencies": {
32+
"angular-cli": "1.0.0-beta.24"
33+
},
3134
"repository": {}
3235
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2-
"build": "build:aot",
3-
"run": "http-server:e2e"
4-
}
2+
"build": "build:aot",
3+
"run": "http-server:e2e",
4+
"skipCli": true
5+
}

public/docs/_examples/cb-component-communication/ts/app/countdown-parent.component.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ import { CountdownTimerComponent } from './countdown-timer.component';
1818
<button (click)="timer.stop()">Stop</button>
1919
<div class="seconds">{{timer.seconds}}</div>
2020
<countdown-timer #timer></countdown-timer>
21-
`,
22-
styleUrls: ['demo.css']
21+
`
2322
})
2423
export class CountdownLocalVarParentComponent { }
2524
// #enddocregion lv
@@ -34,8 +33,7 @@ export class CountdownLocalVarParentComponent { }
3433
<button (click)="stop()">Stop</button>
3534
<div class="seconds">{{ seconds() }}</div>
3635
<countdown-timer></countdown-timer>
37-
`,
38-
styleUrls: ['demo.css']
36+
`
3937
})
4038
export class CountdownViewChildParentComponent implements AfterViewInit {
4139

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"skipCli": true
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"skipCli": true
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"skipCli": true
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"skipCli": true
3+
}

public/docs/_examples/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"@types/angular-sanitize": "^1.3.3",
4141
"@types/jasmine": "~2.5.36",
4242
"@types/node": "^6.0.45",
43+
"angular-cli": "^1.0.0-beta.25.5",
4344
"angular2-template-loader": "^0.4.0",
4445
"awesome-typescript-loader": "^2.2.4",
4546
"babel-cli": "^6.16.0",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"skipCli": true
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"skipCli": true
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"skipCli": true
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"skipCli": true
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"skipCli": true
3+
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"unittesting": true
2+
"unittesting": true,
3+
"skipCli": true
34
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"unittesting": true
2+
"unittesting": true,
3+
"skipCli": true
34
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"build": "build:webpack",
3-
"run": "http-server:cli"
3+
"run": "http-server:cli",
4+
"skipCli": true
45
}

0 commit comments

Comments
 (0)