Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: use chrome on travis #7084

Merged
merged 2 commits into from
Jul 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
dist: trusty
sudo: false

addons:
chrome: stable

language: node_js

cache:
Expand Down Expand Up @@ -89,10 +92,6 @@ matrix:


before_install:
# Use a virtual display.
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export DISPLAY=:99.0; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sh -e /etc/init.d/xvfb start; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export CHROME_BIN=chromium-browser; fi
# Install yarn.
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH="$HOME/.yarn/bin:$PATH"
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/assets/1.0.0-proj/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.0.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
Expand Down
24 changes: 2 additions & 22 deletions tests/e2e/setup/500-create-project.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {join} from 'path';
import {git, ng, silentNpm} from '../utils/process';
import {expectFileToExist, replaceInFile} from '../utils/fs';
import {updateTsConfig, updateJsonFile, useNg2} from '../utils/project';
import {updateTsConfig, updateJsonFile, useNg2, useCIChrome} from '../utils/project';
import {gitClean, gitCommit} from '../utils/git';
import {getGlobalVariable} from '../utils/env';

Expand Down Expand Up @@ -36,27 +36,7 @@ export default function() {
json['dependencies'][pkgName] = packages[pkgName].tar;
});
}))
// There's a race condition happening in Chrome. Enabling logging in chrome used by
// protractor actually fixes it. Logging is piped to a file so it doesn't affect our setup.
// --no-sandbox is needed for Circle CI.
.then(() => replaceInFile('protractor.conf.js', `'browserName': 'chrome'`,
`'browserName': 'chrome',
chromeOptions: {
args: [
"--enable-logging",
"--no-sandbox",
]
}
`))
.then(() => replaceInFile('karma.conf.js', `browsers: ['Chrome'],`,
`browsers: ['ChromeNoSandbox'],
customLaunchers: {
ChromeNoSandbox: {
base: 'Chrome',
flags: ['--no-sandbox']
}
},
`))
.then(() => useCIChrome())
.then(() => argv['ng2'] ? useNg2() : Promise.resolve())
.then(() => {
if (argv['nightly'] || argv['ng-sha']) {
Expand Down
21 changes: 21 additions & 0 deletions tests/e2e/tests/misc/breaking-change.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createProjectFromAsset } from '../../utils/assets';
import { replaceInFile } from '../../utils/fs';
import { ng } from '../../utils/process';

// This test ensures a project generated with 1.0.0 will still work.
Expand All @@ -7,6 +8,26 @@ import { ng } from '../../utils/process';
export default function () {
return Promise.resolve()
.then(() => createProjectFromAsset('1.0.0-proj'))
// Update chrome configs.
.then(() => replaceInFile('protractor.conf.js', `'browserName': 'chrome'`,
`'browserName': 'chrome',
chromeOptions: {
args: [
"--enable-logging",
"--no-sandbox",
${process.env['TRAVIS'] ? '"--headless", "--disable-gpu"' : ''}
]
}
`))
.then(() => replaceInFile('karma.conf.js', `browsers: ['Chrome'],`,
`browsers: ['ChromeCI'],
customLaunchers: {
ChromeCI: {
base: '${process.env['TRAVIS'] ? 'ChromeHeadless' : 'Chrome'}',
flags: ['--no-sandbox']
}
},
`))
.then(() => ng('generate', 'component', 'my-comp'))
.then(() => ng('lint'))
.then(() => ng('test', '--single-run'))
Expand Down
37 changes: 34 additions & 3 deletions tests/e2e/utils/project.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {readFile, writeFile} from './fs';
import {execAndWaitForOutputToMatch, silentNpm, ng} from './process';
import {getGlobalVariable} from './env';
import { readFile, writeFile, replaceInFile } from './fs';
import { execAndWaitForOutputToMatch, silentNpm, ng } from './process';
import { getGlobalVariable } from './env';

const packages = require('../../../lib/packages').packages;

Expand Down Expand Up @@ -43,6 +43,7 @@ export function createProject(name: string, ...args: string[]) {
json['dependencies'][pkgName] = packages[pkgName].dist;
});
}))
.then(() => useCIChrome())
.then(() => argv['ng2'] ? useNg2() : Promise.resolve())
.then(() => {
if (argv.nightly || argv['ng-sha']) {
Expand Down Expand Up @@ -77,6 +78,36 @@ export function createProject(name: string, ...args: string[]) {
.then(() => silentNpm('install'));
}

export function useCIChrome() {
// There's a race condition happening in Chrome. Enabling logging in chrome used by
// protractor actually fixes it. Logging is piped to a file so it doesn't affect our setup.
// --no-sandbox is needed for Circle CI.
// Travis can use headless chrome, but not appveyor.
return Promise.resolve()
.then(() => replaceInFile('protractor.conf.js', `'browserName': 'chrome'`,
`'browserName': 'chrome',
chromeOptions: {
args: [
"--enable-logging",
"--no-sandbox",
${process.env['TRAVIS'] ? '"--headless", "--disable-gpu"' : ''}
]
}
`))
// Not a problem if the file can't be found.
.catch(() => null)
.then(() => replaceInFile('karma.conf.js', `browsers: ['Chrome'],`,
`browsers: ['ChromeCI'],
customLaunchers: {
ChromeCI: {
base: '${process.env['TRAVIS'] ? 'ChromeHeadless' : 'Chrome'}',
flags: ['--no-sandbox']
}
},
`))
.catch(() => null);
}

// Convert a Angular 4 project to Angular 2.
export function useNg2() {
const ng2Deps: any = {
Expand Down