Skip to content

Commit

Permalink
chore(infrastructure): Set up continuous integration
Browse files Browse the repository at this point in the history
* Add .travis.yml file to the repo, enabling TravisCI to run against PRs
  for master and branches of.
* Set up Sauce Labs running on the last two versions of every major
  browser (excluding Android 4 and Opera). Android 4 is quite old, and
  Opera is very similar to Chrome as it uses blink/chromium under the
  hood.
* Work around [SauceLabs PR restriction](https://docs.travis-ci.com/user/pull-requests#Pull-Requests-and-Security-Restrictions) by falling back to running
  tests on Chrome and FF latest only when PR comes from a repo fork. SL
  Tests are then run when the PR gets merged to master.
* Fix false negative in IE11 for mdl-auto-init test.

Part of #4464
  • Loading branch information
traviskaufman committed Jul 21, 2016
1 parent ff30193 commit 8680fb6
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 2 deletions.
26 changes: 26 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
sudo: required
dist: trusty
language: node_js
node_js:
- node # stable
- '4' # LTS
branches:
only:
- master
before_install:
- '[ -n "$SAUCE_ACCESS_KEY" ] || echo "NON-SECURE BUILD. Falling back to Chrome + FF only.'
- '[ -n "$SAUCE_ACCESS_KEY" ] || export CHROME_BIN=/usr/bin/google-chrome'
- '[ -n "$SAUCE_ACCESS_KEY" ] || export DISPLAY=:99.0'
- '[ -n "$SAUCE_ACCESS_KEY" ] || sh -e /etc/init.d/xvfb start'
- '[ -n "$SAUCE_ACCESS_KEY" ] || sudo apt-get update'
- '[ -n "$SAUCE_ACCESS_KEY" ] || sudo apt-get install -y libappindicator1 fonts-liberation'
- '[ -n "$SAUCE_ACCESS_KEY" ] || wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb'
- '[ -n "$SAUCE_ACCESS_KEY" ] || sudo dpkg -i google-chrome*.deb'
env:
global:
- SAUCE_USERNAME=material-sauce
-
secure: aJ9IOc3ngZAujpeNdRRfEZf32tEiPJhNEt/QeoKspP+ivDDxtX4tP+5PlefnQqu5z4M1puF4A6UyiKXZJ5AThFBX0L+FP531lCNibZppyK7KZgl68O92iBooA0EZH45Pb36v9rN5Xl4ZwzJhcx8QiFWXwHp3fQHCgtoxiSdaOBt3l63Wg1vCFPSPPI/8BGiJDwxrOretholor63gMBXUoxJl2ZCMG8NnT5KF1YBzi6ZEWtMLBnuEeKxQcgi3l70UJfR9K/VTfxaoctGrc9UfmyJmD27gGHdBZc0HfZF0Z00SufXn7hILUqfaioJPzRylKxEy0h0KTeX5ZBEQNeLXSIxfcnFHbKk5OeTCkIF+cs9hUrhQfwTpoxyLNPNNeg8P2DMkUvBy/QllEuiESg3LcJlM/ziLhHJpZ7MerbSAZC91rQKX7N/2R8UkaKH6GkEMf5JtK+t1s1fgInBMfPt6oqY250GFq6QJaO/n9a5ndBnDIkjBqbUQYD+8IE793t9HjAN7XwYBk+WgLiStWR+FACLN1VLg8+9K6SfnQujOO2ZYXe2Q2Bdbwk5QqJQCvvb1WHKRMOG2+DN9A2S8zOVfGdC1B9Ih/UZXmXF0r+fEOiY2yuWhgSwd5r16KERxgnG189Gs+7kveT0gfl8SUdEXTEF+fATGEcG+RIv2LSrCNVY=
addons:
firefox: latest
sauce_connect: true
92 changes: 91 additions & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,85 @@
const path = require('path');
const webpackConfig = require('./webpack.config')[0];

const USING_TRAVISCI = Boolean(process.env.TRAVIS);
const USING_SL = Boolean(process.env.SAUCE_USERNAME && process.env.SAUCE_ACCESS_KEY);

const SL_LAUNCHERS = {
'sl-chrome-stable': {
base: 'SauceLabs',
browserName: 'chrome',
version: '51'
},
'sl-chrome-beta': {
base: 'SauceLabs',
browserName: 'chrome',
version: 'beta'
},
'sl-chrome-previous': {
base: 'SauceLabs',
browserName: 'chrome',
version: '50'
},
'sl-firefox-stable': {
base: 'SauceLabs',
browserName: 'firefox'
},
'sl-firefox-previous': {
base: 'SauceLabs',
browserName: 'firefox',
version: '47'
},
// NOTE(traviskaufman): Tried adding Firefox beta but it was consistently flaky. Holding off on adding
// it in for now. If it proves to be less flaky in the future, we should add it.
'sl-safari-stable': {
base: 'SauceLabs',
browserName: 'safari',
version: '9',
platform: 'OS X 10.11'
},
'sl-safari-previous': {
base: 'SauceLabs',
browserName: 'safari',
version: '8',
platform: 'OS X 10.10'
},
'sl-ie': {
base: 'SauceLabs',
browserName: 'internet explorer',
version: '11',
platform: 'Windows 8.1'
},
'sl-edge': {
base: 'SauceLabs',
browserName: 'microsoftedge',
version: '13',
platform: 'Windows 10'
},
'sl-android-stable': {
base: 'SauceLabs',
browserName: 'android',
version: '5.0'
},
'sl-ios-safari-latest': {
base: 'SauceLabs',
browserName: 'iphone',
platform: 'OS X 10.10',
version: '9.1'
},
'sl-ios-safari-previous': {
base: 'SauceLabs',
browserName: 'iphone',
version: '8.4'
}
};

const TRAVISCI_FALLBACK_LAUNCHERS = {
'travisci-chrome': {
base: 'Chrome',
flags: ['--no-sandbox']
}
};

module.exports = function(config) {
config.set({
basePath: '',
Expand All @@ -15,8 +94,12 @@ module.exports = function(config) {
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
browsers: ['Chrome'],
browsers: getBrowsers(),
browserDisconnectTimeout: 20000,
browserNoActivityTimeout: 240000,
captureTimeout: 120000,
concurrency: Infinity,
customLaunchers: USING_SL ? SL_LAUNCHERS : TRAVISCI_FALLBACK_LAUNCHERS,

coverageReporter: {
dir: 'coverage',
Expand Down Expand Up @@ -47,3 +130,10 @@ module.exports = function(config) {
}
});
};

function getBrowsers() {
if (USING_SL) {
return Object.keys(SL_LAUNCHERS);
}
return USING_TRAVISCI ? Object.keys(TRAVISCI_FALLBACK_LAUNCHERS).concat(['Firefox']) : ['Chrome'];
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
"karma": "^1.1.1",
"karma-chrome-launcher": "^1.0.1",
"karma-coverage": "^1.1.0",
"karma-firefox-launcher": "^1.0.0",
"karma-sauce-launcher": "^1.0.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-tap": "^2.0.1",
"karma-webpack": "^1.7.0",
Expand Down
2 changes: 1 addition & 1 deletion test/unit/mdl-auto-init/mdl-auto-init.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const createFixture = () => bel`

const setupTest = () => {
mdlAutoInit.deregisterAll();
mdlAutoInit.register(FakeComponent.name, FakeComponent);
mdlAutoInit.register('FakeComponent', FakeComponent);
return createFixture();
};

Expand Down

0 comments on commit 8680fb6

Please sign in to comment.