X Tutup
Skip to content

Commit eebd736

Browse files
marclavaltbosch
authored andcommitted
feat(build): initial SauceLabs setup
Closes angular#2347
1 parent bb50cda commit eebd736

File tree

12 files changed

+320
-39
lines changed

12 files changed

+320
-39
lines changed

.travis.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ env:
1717
- KARMA_BROWSERS=DartiumWithWebPlatform
1818
- E2E_BROWSERS=Dartium
1919
- LOGS_DIR=/tmp/angular-build/logs
20+
- SAUCE_USERNAME=angular-ci
21+
- SAUCE_ACCESS_KEY=9b988f434ff8-fbca-8aa4-4ae3-35442987
2022
- ARCH=linux-x64
2123
# Token for tsd to increase github rate limit
2224
# See https://github.com/DefinitelyTyped/tsd#tsdrc
@@ -26,10 +28,15 @@ env:
2628
# (password is in Valentine)
2729
- TSDRC='{"token":"ef474500309daea53d5991b3079159a29520a40b"}'
2830
matrix:
29-
- MODE=js DART_CHANNEL=dev
30-
- MODE=dart DART_CHANNEL=stable
31-
- MODE=dart DART_CHANNEL=dev
32-
- MODE=dart_experimental DART_CHANNEL=dev
31+
- MODE=js DART_CHANNEL=dev
32+
- MODE=dart DART_CHANNEL=stable
33+
- MODE=dart DART_CHANNEL=dev
34+
- MODE=dart_experimental DART_CHANNEL=dev
35+
- MODE=saucelabs DART_CHANNEL=dev
36+
37+
matrix:
38+
allow_failures:
39+
- env: "MODE=saucelabs DART_CHANNEL=dev"
3340

3441
addons:
3542
firefox: "38.0"

gulpfile.js

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ var uglify = require('gulp-uglify');
4040
var shouldLog = require('./tools/build/logging');
4141
var tslint = require('gulp-tslint');
4242
var dartSdk = require('./tools/build/dart');
43+
var sauceConf = require('./sauce.conf');
4344

4445
require('./tools/check-environment')({
4546
requiredNpmVersion: '>=2.9.0',
@@ -530,13 +531,35 @@ gulp.task('test.all.dart', shell.task(['./scripts/ci/test_dart.sh']))
530531
// These tests run in the browser and are allowed to access
531532
// HTML DOM APIs.
532533
function getBrowsersFromCLI() {
534+
var isSauce = false;
533535
var args = minimist(process.argv.slice(2));
534-
return [args.browsers?args.browsers:'DartiumWithWebPlatform']
536+
var rawInput = args.browsers?args.browsers:'DartiumWithWebPlatform';
537+
var inputList = rawInput.replace(' ', '').split(',');
538+
var outputList = [];
539+
for (var i = 0; i < inputList.length; i++) {
540+
var input = inputList[i];
541+
if (sauceConf.customLaunchers.hasOwnProperty(input)) {
542+
//Non-sauce browsers case: overrides everything, ignoring other options
543+
outputList = [input];
544+
isSauce = false;
545+
break;
546+
} else if (sauceConf.customLaunchers.hasOwnProperty("SL_" + input.toUpperCase())) {
547+
isSauce = true;
548+
outputList.push("SL_" + input.toUpperCase());
549+
} else if (sauceConf.aliases.hasOwnProperty(input.toUpperCase())) {
550+
outputList = outputList.concat(sauceConf.aliases[input]);
551+
isSauce = true;
552+
} else {
553+
throw new Error('ERROR: unknown browser found in getBrowsersFromCLI()');
554+
}
555+
}
556+
return {
557+
browsersToRun: outputList.filter(function(item, pos, self) {return self.indexOf(item) == pos;}),
558+
isSauce: isSauce
559+
}
535560
}
536561

537-
538-
gulp.task('test.unit.js', ['build.js.dev'], function (neverDone) {
539-
562+
gulp.task('test.unit.js', ['build.js.dev'], function (done) {
540563
runSequence(
541564
'!test.unit.js/karma-server',
542565
function() {
@@ -548,6 +571,16 @@ gulp.task('test.unit.js', ['build.js.dev'], function (neverDone) {
548571
);
549572
});
550573

574+
gulp.task('test.unit.js.sauce', ['build.js.dev'], function (done) {
575+
var browserConf = getBrowsersFromCLI();
576+
if (browserConf.isSauce) {
577+
karma.server.start({configFile: __dirname + '/karma-js.conf.js',
578+
singleRun: true, browserNoActivityTimeout: 240000, captureTimeout: 120000, reporters: ['dots'], browsers: browserConf.browsersToRun},
579+
function(err) {done(); process.exit(err ? 1 : 0)});
580+
} else {
581+
throw new Error('ERROR: no Saucelabs browsers provided, add them with the --browsers option');
582+
}
583+
});
551584

552585
gulp.task('!test.unit.js/karma-server', function() {
553586
karma.server.start({configFile: __dirname + '/karma-js.conf.js', reporters: 'dots'});
@@ -598,13 +631,21 @@ gulp.task('!test.unit.dart/karma-server', function() {
598631

599632

600633
gulp.task('test.unit.js/ci', function (done) {
634+
var browserConf = getBrowsersFromCLI();
635+
karma.server.start({configFile: __dirname + '/karma-js.conf.js',
636+
singleRun: true, reporters: ['dots'], browsers: browserConf.browsersToRun}, done);
637+
});
638+
639+
gulp.task('test.unit.js.sauce/ci', function (done) {
601640
karma.server.start({configFile: __dirname + '/karma-js.conf.js',
602-
singleRun: true, reporters: ['dots'], browsers: getBrowsersFromCLI()}, done);
641+
singleRun: true, browserNoActivityTimeout: 240000, captureTimeout: 120000, reporters: ['dots', 'saucelabs'], browsers: sauceConf.aliases.CI},
642+
function(err) {done(); process.exit(err ? 1 : 0)});
603643
});
604644

605645
gulp.task('test.unit.dart/ci', function (done) {
646+
var browserConf = getBrowsersFromCLI();
606647
karma.server.start({configFile: __dirname + '/karma-dart.conf.js',
607-
singleRun: true, reporters: ['dots'], browsers: getBrowsersFromCLI()}, done);
648+
singleRun: true, reporters: ['dots'], browsers: browserConf.browsersToRun}, done);
608649
});
609650

610651

karma-dart.conf.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
var sauceConf = require('./sauce.conf');
2+
13
// Karma configuration
24
// Generated on Thu Sep 25 2014 11:52:02 GMT-0700 (PDT)
35
module.exports = function(config) {
@@ -48,11 +50,7 @@ module.exports = function(config) {
4850
'/packages/examples': '/base/dist/dart/examples/lib'
4951
},
5052

51-
customLaunchers: {
52-
DartiumWithWebPlatform: {
53-
base: 'Dartium',
54-
flags: ['--enable-experimental-web-platform-features'] }
55-
},
53+
customLaunchers: sauceConf.customLaunchers,
5654
browsers: ['DartiumWithWebPlatform'],
5755

5856
port: 9877

karma-js.conf.js

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
var sauceConf = require('./sauce.conf');
2+
13
// Karma configuration
24
// Generated on Thu Sep 25 2014 11:52:02 GMT-0700 (PDT)
35
module.exports = function(config) {
@@ -25,23 +27,42 @@ module.exports = function(config) {
2527
'node_modules/reflect-metadata/Reflect.js',
2628
'tools/build/file2modulename.js',
2729
'test-main.js',
28-
{pattern: 'modules/**/test/**/static_assets/**', included: false, watched: false}
30+
{pattern: 'modules/**/test/**/static_assets/**', included: false, watched: false},
31+
'modules/angular2/src/test_lib/shims_for_IE.ts'
2932
],
3033

3134
exclude: [
3235
'dist/js/dev/es5/**/e2e_test/**',
3336
],
3437

35-
customLaunchers: {
36-
DartiumWithWebPlatform: {
37-
base: 'Dartium',
38-
flags: ['--enable-experimental-web-platform-features'] },
39-
ChromeNoSandbox: {
40-
base: 'Chrome',
41-
flags: ['--no-sandbox'] }
38+
customLaunchers: sauceConf.customLaunchers,
39+
40+
sauceLabs: {
41+
testName: 'Angular2',
42+
startConnect: false,
43+
recordVideo: false,
44+
recordScreenshots: false,
45+
options: {
46+
'selenium-version': '2.45.0',
47+
'command-timeout': 600,
48+
'idle-timeout': 600,
49+
'max-duration': 5400
50+
}
4251
},
52+
4353
browsers: ['ChromeCanary'],
4454

4555
port: 9876
4656
});
57+
58+
if (process.env.TRAVIS) {
59+
config.sauceLabs.build = 'TRAVIS #' + process.env.TRAVIS_BUILD_NUMBER + ' (' + process.env.TRAVIS_BUILD_ID + ')';
60+
config.sauceLabs.tunnelIdentifier = process.env.TRAVIS_JOB_NUMBER;
61+
62+
// TODO(mlaval): remove once SauceLabs supports websockets.
63+
// This speeds up the capturing a bit, as browsers don't even try to use websocket.
64+
config.transports = ['xhr-polling'];
65+
}
4766
};
67+
68+

modules/angular2/src/test_lib/test_lib.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,15 @@ void _it(gnsFn, name, fn) {
177177
});
178178
}
179179

180-
void it(name, fn) {
180+
void it(name, fn, [timeOut = null]) {
181181
_it(gns.it, name, fn);
182182
}
183183

184-
void iit(name, fn) {
184+
void iit(name, fn, [timeOut = null]) {
185185
_it(gns.iit, name, fn);
186186
}
187187

188-
void xit(name, fn) {
188+
void xit(name, fn, [timeOut = null]) {
189189
_it(gns.xit, name, fn);
190190
}
191191

modules/angular2/src/test_lib/test_lib.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export function beforeEachBindings(fn) {
129129
});
130130
}
131131

132-
function _it(jsmFn, name, fn) {
132+
function _it(jsmFn, name, fn, timeOut) {
133133
var runner = runnerStack[runnerStack.length - 1];
134134

135135
jsmFn(name, function(done) {
@@ -156,19 +156,19 @@ function _it(jsmFn, name, fn) {
156156
inIt = false;
157157

158158
if (!async) done();
159-
});
159+
}, timeOut);
160160
}
161161

162-
export function it(name, fn) {
163-
return _it(jsmIt, name, fn);
162+
export function it(name, fn, timeOut = null) {
163+
return _it(jsmIt, name, fn, timeOut);
164164
}
165165

166-
export function xit(name, fn) {
167-
return _it(jsmXIt, name, fn);
166+
export function xit(name, fn, timeOut = null) {
167+
return _it(jsmXIt, name, fn, timeOut);
168168
}
169169

170-
export function iit(name, fn) {
171-
return _it(jsmIIt, name, fn);
170+
export function iit(name, fn, timeOut = null) {
171+
return _it(jsmIIt, name, fn, timeOut);
172172
}
173173

174174
// Some Map polyfills don't polyfill Map.toString correctly, which

modules/angular2/test/render/xhr_impl_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ export function main() {
2727
expect(text.trim()).toEqual('<p>hey</p>');
2828
async.done();
2929
});
30-
}));
30+
}), 10000);
3131

3232
it('should reject the Promise on failure', inject([AsyncTestCompleter], (async) => {
3333
PromiseWrapper.catchError(xhr.get(url404), (e) => {
3434
expect(e).toEqual(`Failed to load ${url404}`);
3535
async.done();
3636
return null;
3737
});
38-
}));
38+
}), 10000);
3939
});
4040
}

0 commit comments

Comments
 (0)
X Tutup