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

Fix travis by running browser tests in headless mode #3001

Merged
merged 34 commits into from
Sep 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0244452
Attempt to fix travis
samelhusseini Sep 11, 2019
626ad9e
Use sudo.
samelhusseini Sep 11, 2019
544ef04
Add sources
samelhusseini Sep 11, 2019
aa767f4
apt-get update
samelhusseini Sep 11, 2019
fe08a3e
Switch distros
samelhusseini Sep 11, 2019
175552b
Workaround
samelhusseini Sep 11, 2019
3fba91f
Switch to bionic
samelhusseini Sep 11, 2019
3087735
Run chrome headless
samelhusseini Sep 11, 2019
4d46739
Revert running chrome headless.
samelhusseini Sep 11, 2019
4fecdee
Update before install do run apt-get clean.
samelhusseini Sep 11, 2019
a9ce1b1
Revert back to trusty.
samelhusseini Sep 11, 2019
cec1a9a
sudo + bionic
samelhusseini Sep 11, 2019
de1e510
Use latest chrome, acquired through addons.
samelhusseini Sep 11, 2019
7b326f6
Use chrome stable.
samelhusseini Sep 11, 2019
ca4825d
Update chrome driver.
samelhusseini Sep 11, 2019
bacb3eb
Update to latest chrome driver.
samelhusseini Sep 11, 2019
a2fe009
Do a travis update.
samelhusseini Sep 11, 2019
442af06
Use chrome stable.
samelhusseini Sep 11, 2019
2da6d8b
Try no sandbox.
samelhusseini Sep 11, 2019
fd4f64c
Try disabling ipv6
samelhusseini Sep 11, 2019
eee8ab3
Use selenium-standalone npm package
samelhusseini Sep 11, 2019
17a601e
npm run test in travis
samelhusseini Sep 11, 2019
e5b3674
split prepare
samelhusseini Sep 11, 2019
86a016b
npm run test in test script
samelhusseini Sep 11, 2019
e24f6ba
use npm run all.
samelhusseini Sep 11, 2019
bd2f8b4
Run in paralell
samelhusseini Sep 11, 2019
7f96f4d
run with xvfb
samelhusseini Sep 11, 2019
3fd945f
Add xvfb start / stop
samelhusseini Sep 11, 2019
01b4efd
Headless and no sandbox
samelhusseini Sep 11, 2019
a0886e8
Run firefox headless
samelhusseini Sep 11, 2019
6e3ecb7
attempt to have travis stop after prepare
samelhusseini Sep 11, 2019
150a1b1
Cleanup scripts.
samelhusseini Sep 11, 2019
abbe64a
Only run in headless on travis.
samelhusseini Sep 11, 2019
331ff6c
Use concurrently instead of npm run all.
samelhusseini Sep 12, 2019
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
12 changes: 5 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
language: node_js
os: linux
dist: trusty
dist: xenial
node_js:
- 8
- 10
addons:
chrome: stable
firefox: latest
apt:
packages:
- google-chrome-stable
# TODO (#2114): reenable osx build.
# - os: osx
# node_js: stable
# osx_image: xcode8.3
# addons:
# firefox: latest

env:
- TRAVIS_CI=true
before_script:
# Symlink closure library used by test/jsunit
- ln -s $(npm root)/google-closure-library ../closure-library
- export DISPLAY=:99.0
- if [ "${TRAVIS_OS_NAME}" == "linux" ]; then ( tests/scripts/setup_linux_env.sh ) fi
- if [ "${TRAVIS_OS_NAME}" == "osx" ]; then ( tests/scripts/setup_osx_env.sh ) fi
- sleep 2

script:
- tests/run_all_tests.sh
- npm run test:run
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
"package": "gulp package",
"prepare": "gulp blockly_node_javascript_en",
"release": "gulp release",
"test": "tests/run_all_tests.sh",
"test": "concurrently 'npm run test:prepare' 'sleep 5 && npm run test:run'",
"test:run": "tests/run_all_tests.sh",
"test:prepare": "npm run test:setupselenium && npm run test:startselenium",
"test:setupselenium": "selenium-standalone install --config=./tests/scripts/selenium-config.js",
"test:startselenium": "selenium-standalone start --config=./tests/scripts/selenium-config.js",
"typings": "gulp typings"
},
"main": "./index.js",
Expand All @@ -38,6 +42,7 @@
"license": "Apache-2.0",
"devDependencies": {
"chai": "^4.2.0",
"concurrently": "^4.1.2",
"eslint": "^5.13.0",
"fs": "0.0.1-security",
"google-closure-compiler": "^20190618.0.0",
Expand All @@ -54,6 +59,7 @@
"mocha": "^6.1.4",
"pixelmatch": "^4.0.2",
"pngjs": "^3.4.0",
"selenium-standalone": "^6.16.0",
"rimraf": "^2.6.3",
"typescript-closure-tools": "^0.0.7",
"webdriverio": "^5.11.5",
Expand Down
6 changes: 6 additions & 0 deletions tests/generators/run_generators_in_browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ async function runGeneratorsInBrowser() {
browserName: 'firefox'
}
};
// Run in headless mode on Travis.
if (process.env.TRAVIS_CI) {
options.capabilities['moz:firefoxOptions'] = {
args: ['-headless']
};
}

var url = 'file://' + __dirname + '/index.html';
var prefix = 'tests/generators/tmp/generated';
Expand Down
6 changes: 6 additions & 0 deletions tests/jsunit/run_jsunit_tests_in_browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ async function runJsUnitTestsInBrowser() {
browserName: 'chrome'
}
};
// Run in headless mode on Travis.
if (process.env.TRAVIS_CI) {
options.capabilities['goog:chromeOptions'] = {
args: ['--headless', '--no-sandbox', '--disable-dev-shm-usage']
};
}

var url = 'file://' + __dirname + '/index.html';
console.log('Starting webdriverio...');
Expand Down
6 changes: 6 additions & 0 deletions tests/mocha/run_mocha_tests_in_browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ async function runMochaTestsInBrowser() {
browserName: 'chrome'
}
};
// Run in headless mode on Travis.
if (process.env.TRAVIS_CI) {
options.capabilities['goog:chromeOptions'] = {
args: ['--headless', '--no-sandbox', '--disable-dev-shm-usage']
};
}

var url = 'file://' + __dirname + '/index.html';
console.log('Starting webdriverio...');
Expand Down
3 changes: 0 additions & 3 deletions tests/run_all_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ run_test_command () {
fi
}

# Set up the environment (Chrome, Selenium, etc.)
run_test_command "test_setup" "tests/scripts/test_setup.sh"

# Lint the codebase.
run_test_command "eslint" "eslint ."

Expand Down
6 changes: 6 additions & 0 deletions tests/screenshot/gen_screenshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ async function buildBrowser(url, isRtl) {
},
logLevel: 'warn'
};
// Run in headless mode on Travis.
if (process.env.TRAVIS_CI) {
options.capabilities['goog:chromeOptions'] = {
args: ['--headless', '--no-sandbox', '--disable-dev-shm-usage']
};
}
console.log('Starting webdriverio...');
const browser = await webdriverio.remote(options);
var injectBlockly = function(isRtl) {
Expand Down
Binary file removed tests/scripts/.selenium_connect.sh.swp
Binary file not shown.
17 changes: 0 additions & 17 deletions tests/scripts/get_chromedriver.sh

This file was deleted.

15 changes: 0 additions & 15 deletions tests/scripts/get_geckdriver.sh

This file was deleted.

14 changes: 0 additions & 14 deletions tests/scripts/get_selenium.sh

This file was deleted.

27 changes: 27 additions & 0 deletions tests/scripts/selenium-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* eslint-disable */

module.exports = {
// check for more recent versions of selenium here:
// https://selenium-release.storage.googleapis.com/index.html
version: '3.9.1',
baseURL: 'https://selenium-release.storage.googleapis.com',
drivers: {
chrome: {
// check for more recent versions of chrome driver here:
// https://chromedriver.storage.googleapis.com/index.html
version: '77.0.3865.40',
arch: process.arch,
baseURL: 'https://chromedriver.storage.googleapis.com'
},
firefox: {
// check for more recent versions of chrome driver here:
// https://chromedriver.storage.googleapis.com/index.html
version: '0.21.0',
arch: process.arch,
baseURL: 'https://github.com/mozilla/geckodriver/releases/download'
},
},
requestOpts: { // see https://github.com/request/request#requestoptions-callback
timeout: 10000
},
};
10 changes: 0 additions & 10 deletions tests/scripts/selenium_connect.sh

This file was deleted.

2 changes: 1 addition & 1 deletion tests/scripts/setup_linux_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
if [ "${TRAVIS_OS_NAME}" == "linux" ]
then
export CHROME_BIN="/usr/bin/google-chrome"
export DISPLAY=:99.0
sh -e /etc/init.d/xvfb start &
npm run test:prepare > /dev/null &
fi
3 changes: 2 additions & 1 deletion tests/scripts/setup_osx_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ if [ "${TRAVIS_OS_NAME}" == "osx" ]
then
brew cask install google-chrome
sudo Xvfb :99 -ac -screen 0 1024x768x8 &
export CHROME_BIN="/Applications/Google Chrome.app"
export CHROME_BIN="/Applications/Google Chrome.app"
npm run test:prepare > /dev/null &
fi
23 changes: 0 additions & 23 deletions tests/scripts/test_setup.sh

This file was deleted.