X Tutup
Skip to content

Commit 51e6f33

Browse files
committed
chore(build): Make PRs 15m faster.
Don't precompile Dart2JS for pull requests, instead serve the dart sources with pub serve. We were already testing with Dartium so all we lose is some test coverage of defects exposed only by the Dart2JS transpiler. This still runs the dart transformer. Fixes angular#3030
1 parent 4769888 commit 51e6f33

File tree

11 files changed

+128
-32
lines changed

11 files changed

+128
-32
lines changed

DEVELOPER.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ rights to built them in your operating system.
187187
### E2E tests
188188

189189
1. `$(npm bin)/gulp build.js.cjs` (builds benchpress and tests into `dist/js/cjs` folder).
190-
2. `$(npm bin)/gulp serve.js.prod serve.js.dart2js` (runs a local webserver).
190+
2. `$(npm bin)/gulp serve.js.prod serve.dart` (runs a local webserver).
191191
3. `$(npm bin)/protractor protractor-js.conf.js`: JS e2e tests.
192192
4. `$(npm bin)/protractor protractor-dart2js.conf.js`: dart2js e2e tests.
193193

@@ -197,7 +197,7 @@ Angular specific command line options when running protractor:
197197
### Performance tests
198198

199199
1. `$(npm bin)/gulp build.js.cjs` (builds benchpress and tests into `dist/js/cjs` folder)
200-
2. `$(npm bin)/gulp serve.js.prod serve.js.dart2js` (runs a local webserver)
200+
2. `$(npm bin)/gulp serve.js.prod serve.dart` (runs a local webserver)
201201
3. `$(npm bin)/protractor protractor-js.conf.js --benchmark`: JS performance tests
202202
4. `$(npm bin)/protractor protractor-dart2js.conf.js --benchmark`: dart2js performance tests
203203

gulpfile.js

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ var BENCHPRESS_BUNDLE_CONFIG = {
150150
'rx'
151151
],
152152
dest: CONFIG.dest.benchpress_bundle
153-
}
153+
};
154154

155155
// ------------
156156
// clean
@@ -245,6 +245,7 @@ gulp.task('build/analyze.dart', dartanalyzer(gulp, gulpPlugins, {
245245

246246
// ------------
247247
// pubbuild
248+
// WARNING: this task is very slow (~15m as of July 2015)
248249

249250
gulp.task('build/pubbuild.dart', pubbuild(gulp, gulpPlugins, {
250251
src: CONFIG.dest.dart,
@@ -330,6 +331,17 @@ function jsServeDartJs() {
330331
})();
331332
}
332333

334+
function proxyServeDart() {
335+
return jsserve(gulp, gulpPlugins, {
336+
port: 8002,
337+
proxies: [
338+
{route: '/examples', url: 'http://localhost:8004'},
339+
{route: '/benchmarks_external', url: 'http://localhost:8008'},
340+
{route: '/benchmarks', url: 'http://localhost:8006'}
341+
]
342+
})();
343+
}
344+
333345
// ------------------
334346
// web servers
335347
gulp.task('serve.js.dev', ['build.js.dev'], function(neverDone) {
@@ -351,19 +363,33 @@ gulp.task('serve.e2e.prod', ['build.js.prod', 'build.js.cjs', 'build.css.materia
351363

352364
gulp.task('serve.js.dart2js', jsServeDartJs);
353365

366+
gulp.task('!proxyServeDart', proxyServeDart);
367+
368+
gulp.task('serve.dart', function(done) {
369+
runSequence([
370+
'!proxyServeDart',
371+
'serve/examples.dart',
372+
'serve/benchmarks.dart',
373+
'serve/benchmarks_external.dart'
374+
], done);
375+
});
376+
354377
gulp.task('serve/examples.dart', pubserve(gulp, gulpPlugins, {
355378
command: DART_SDK.PUB,
356-
path: CONFIG.dest.dart + '/examples'
379+
path: CONFIG.dest.dart + '/examples',
380+
port: 8004
357381
}));
358382

359383
gulp.task('serve/benchmarks.dart', pubserve(gulp, gulpPlugins, {
360384
command: DART_SDK.PUB,
361-
path: CONFIG.dest.dart + '/benchmarks'
385+
path: CONFIG.dest.dart + '/benchmarks',
386+
port: 8006
362387
}));
363388

364389
gulp.task('serve/benchmarks_external.dart', pubserve(gulp, gulpPlugins, {
365390
command: DART_SDK.PUB,
366-
path: CONFIG.dest.dart + '/benchmarks_external'
391+
path: CONFIG.dest.dart + '/benchmarks_external',
392+
port: 8008
367393
}));
368394

369395
// --------------
@@ -751,7 +777,6 @@ gulp.task('build.dart', function(done) {
751777
'build/packages.dart',
752778
'build/pubspec.dart',
753779
'build/analyze.dart',
754-
'build/pubbuild.dart',
755780
'build.dart.material.css',
756781
sequenceComplete(done)
757782
);

modules/benchmarks_external/src/compiler/compiler_benchmark.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,33 +56,33 @@ createTemplate(String html) {
5656
return div;
5757
}
5858

59-
@Directive(selector: '[dir0]', map: const {'attr0': '=>prop'})
59+
@Decorator(selector: '[dir0]', map: const {'attr0': '=>prop'})
6060
class Dir0 {
6161
Object prop;
6262
}
6363

64-
@Directive(selector: '[dir1]', map: const {'attr1': '=>prop'})
64+
@Decorator(selector: '[dir1]', map: const {'attr1': '=>prop'})
6565
class Dir1 {
6666
Object prop;
6767

6868
constructor(Dir0 dir0) {}
6969
}
7070

71-
@Directive(selector: '[dir2]', map: const {'attr2': '=>prop'})
71+
@Decorator(selector: '[dir2]', map: const {'attr2': '=>prop'})
7272
class Dir2 {
7373
Object prop;
7474

7575
constructor(Dir1 dir1) {}
7676
}
7777

78-
@Directive(selector: '[dir3]', map: const {'attr3': '=>prop'})
78+
@Decorator(selector: '[dir3]', map: const {'attr3': '=>prop'})
7979
class Dir3 {
8080
Object prop;
8181

8282
constructor(Dir2 dir2) {}
8383
}
8484

85-
@Directive(selector: '[dir4]', map: const {'attr4': '=>prop'})
85+
@Decorator(selector: '[dir4]', map: const {'attr4': '=>prop'})
8686
class Dir4 {
8787
Object prop;
8888

npm-shrinkwrap.clean.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9382,6 +9382,9 @@
93829382
"node-uuid": {
93839383
"version": "1.4.3"
93849384
},
9385+
"on-headers": {
9386+
"version": "1.0.0"
9387+
},
93859388
"parse5": {
93869389
"version": "1.3.2"
93879390
},
@@ -9533,6 +9536,9 @@
95339536
}
95349537
}
95359538
},
9539+
"proxy-middleware": {
9540+
"version": "0.13.0"
9541+
},
95369542
"q": {
95379543
"version": "1.3.0"
95389544
},

npm-shrinkwrap.json

Lines changed: 17 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,10 @@
103103
"mock-fs": "^2.5.0",
104104
"node-html-encoder": "0.0.2",
105105
"node-uuid": "1.4.x",
106+
"on-headers": "^1.0.0",
106107
"parse5": "1.3.2",
107108
"protractor": "2.1.0",
109+
"proxy-middleware": "^0.13.0",
108110
"q": "^1.0.1",
109111
"react": "^0.13.2",
110112
"rewire": "^2.3.3",

scripts/ci/test_e2e_dart.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,17 @@ function killServer () {
1212
kill $serverPid
1313
}
1414

15-
./node_modules/.bin/gulp serve.js.dart2js&
16-
serverPid=$!
15+
# Serving pre-compiled dart JS takes an extra 15m.
16+
# So we do this only for post-commit testing.
17+
# Pull requests test with Dartium and pub serve
18+
if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then
19+
./node_modules/.bin/gulp build/pubbuild.dart
20+
./node_modules/.bin/gulp serve.js.dart2js&
21+
serverPid=$!
22+
else
23+
./node_modules/.bin/gulp serve.dart&
24+
serverPid=$!
25+
fi
1726

1827
./node_modules/.bin/gulp build.css.material&
1928

scripts/ci/test_perf.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,17 @@ function killServer () {
1313
kill $serverPid
1414
}
1515

16-
./node_modules/.bin/gulp serve.js.prod serve.js.dart2js&
17-
serverPid=$!
16+
# Serving pre-compiled dart JS takes an extra 15m.
17+
# So we do this only for post-commit testing.
18+
# Pull requests test with Dartium and pub serve
19+
if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then
20+
./node_modules/.bin/gulp build/pubbuild.dart
21+
./node_modules/.bin/gulp serve.js.prod serve.js.dart2js&
22+
serverPid=$!
23+
else
24+
./node_modules/.bin/gulp serve.js.prod serve.dart&
25+
serverPid=$!
26+
fi
1827

1928
trap killServer EXIT
2029

scripts/ci/test_server_dart.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,17 @@ cd $SCRIPT_DIR/../..
1111
webdriverServerPid=$!
1212
ps -ef | grep webdriver-manager
1313

14-
./node_modules/.bin/gulp serve.js.dart2js&
15-
serverPid=$!
14+
# Serving pre-compiled dart JS takes an extra 15m.
15+
# So we do this only for post-commit testing.
16+
# Pull requests test with Dartium and pub serve
17+
if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then
18+
./node_modules/.bin/gulp build/pubbuild.dart
19+
./node_modules/.bin/gulp serve.js.dart2js&
20+
serverPid=$!
21+
else
22+
./node_modules/.bin/gulp serve.dart&
23+
serverPid=$!
24+
fi
1625

1726
function killAllServers () {
1827
kill $serverPid

tools/build/jsserve.js

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,40 @@
1+
var onHeaders = require('on-headers');
2+
var proxy = require('proxy-middleware');
3+
var url = require('url');
4+
15
module.exports = function(gulp, plugins, config) {
26
return function() {
37
plugins.connect.server({
4-
root: [__dirname+'/../../'+config.path],
8+
root: [__dirname + '/../../' + config.path],
59
port: config.port,
610
livereload: false,
711
open: false,
812
middleware: function(connect, opt) {
9-
return [
10-
connect.favicon()
11-
]
13+
config.proxies = config.proxies || [];
14+
var middlewares =
15+
config.proxies.map(function(entry) { return makeProxy(entry.route, entry.url); });
16+
middlewares.push(connect.favicon());
17+
// pub serve can't give the right content-type header for jsonp requests
18+
// so we must turn off Chromium strict MIME type checking
19+
// see https://github.com/angular/angular/issues/3030#issuecomment-123453168
20+
middlewares.unshift(stripHeader('x-content-type-options'));
21+
return middlewares;
1222
}
1323
})();
1424
};
1525
};
26+
27+
function makeProxy(route, urlParam) {
28+
var options = url.parse(urlParam);
29+
options.route = route;
30+
return proxy(options);
31+
}
32+
33+
function stripHeader(toStrip) {
34+
return function(req, res, next) {
35+
onHeaders(res, function onHeaders() {
36+
res.removeHeader(toStrip);
37+
});
38+
next();
39+
};
40+
}

0 commit comments

Comments
 (0)
X Tutup