Skip to content

Commit

Permalink
Fix oppia#7423: Update node packages (oppia#7615)
Browse files Browse the repository at this point in the history
* Update webdriver-manager

* Update minor versions of node packages

* Update audit command

* Change condition package_json check

* Remove trailing space in build.py

* Remove server cleanup

* Remove sleep for cleanup

* Temporarily override variable

* Allow for directory to exist

* Make folder creation optional

* Upgrade ubuntu version on travis

* Remove jdk workaround

* Change xvfb to service on travis

* Add browser sleep

* Reenable embedding test

* Add embedding test to sleep exception
  • Loading branch information
kevinlee12 authored and nithusha21 committed Sep 15, 2019
1 parent ce4440f commit e059814
Show file tree
Hide file tree
Showing 9 changed files with 173 additions and 100 deletions.
15 changes: 7 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
sudo: required
# In order to install Chrome stable we need trusty distribution.
dist: trusty
dist: xenial
language: python
python:
- 2.7
- 2.7

services:
- xvfb

branches:
only:
Expand All @@ -13,6 +15,8 @@ branches:
- /^release-\d+\.\d+\.\d+-hotfix-\d+$/

env:
global:
CHROME_SOURCE_URL: https://github.com/webnicer/chrome-downloads/raw/master/x64.deb/google-chrome-stable_77.0.3865.75-1_amd64.deb
matrix:
# These lines are commented out because these checks are being run on CircleCI
# here: https://circleci.com/gh/oppia/oppia
Expand Down Expand Up @@ -76,14 +80,9 @@ notifications:
on_failure: always

before_install:
# For the rationale behind the next two lines, see:
# https://github.com/travis-ci/travis-ci/issues/6928#issuecomment-264227708
- source /opt/jdk_switcher/jdk_switcher.sh
- jdk_switcher use oraclejdk8
- pip install codecov
- export CHROME_BIN=/usr/bin/google-chrome-stable
- export DISPLAY=:99.0
- bash -e /etc/init.d/xvfb start

install:
- pushd $TRAVIS_BUILD_DIR
Expand Down
4 changes: 4 additions & 0 deletions core/tests/protractor_desktop/embedding.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ describe('Embedding', function() {
browser.switchTo().frame(driver.findElement(
by.css('.protractor-test-embedded-exploration > iframe')));
waitFor.pageToFullyLoad();

// TODO(kevinlee12): Remove this sleep.
browser.sleep(6000);

expect(driver.findElement(by.css('.protractor-test-float-form-input'))
.getAttribute('placeholder')).toBe(expectedPlaceholder);
browser.switchTo().defaultContent();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"typescript": "^3.4.5",
"uglify-js": "^3.5.8",
"underscore-template-loader": "^1.0.0",
"webdriver-manager": "^12.1.4",
"webdriver-manager": "13.0.0",
"webpack": "^4.30.0",
"webpack-cli": "^3.3.1",
"webpack-merge": "^4.2.1",
Expand Down
2 changes: 1 addition & 1 deletion scripts/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -1386,7 +1386,7 @@ def main(args=None):
generate_app_yaml()
if not options.minify_third_party_libs_only:
generate_build_directory(hashes)

save_hashes_to_file(dict())


Expand Down
8 changes: 5 additions & 3 deletions scripts/install_chrome_on_travis.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ def main(args=None):
home_directory, '.cache/TravisChrome/',
os.path.basename(chrome_source_url))

if not os.path.isfile(travis_chrome_path):
# Caching Chrome's Debian package after download to prevent connection
# problem.
# Caching Chrome's Debian package after download to prevent connection
# problem.
if not os.path.isdir(os.path.join(home_directory, '.cache/TravisChrome/')):
os.makedirs(os.path.join(home_directory, '.cache/TravisChrome/'))

if not os.path.isfile(travis_chrome_path):
os.chdir(os.path.join(home_directory, '.cache/TravisChrome/'))
python_utils.url_retrieve(
chrome_source_url, filename=os.path.basename(chrome_source_url))
Expand Down
4 changes: 3 additions & 1 deletion scripts/pre_commit_linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@
{
'regexp': re.compile(r'\b(browser.sleep)\('),
'message': 'In tests, please do not use browser.sleep().',
'excluded_files': (),
'excluded_files': (
'core/tests/protractor_desktop/embedding.js'
),
'excluded_dirs': ()
},
{
Expand Down
10 changes: 6 additions & 4 deletions scripts/pre_push_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
OPPIA_PARENT_DIR = os.path.join(FILE_DIR, os.pardir, os.pardir, os.pardir)
NPM_CMD = os.path.join(
OPPIA_PARENT_DIR, 'oppia_tools', 'node-10.15.3', 'bin', 'npm')
YARN_CMD = os.path.join(
OPPIA_PARENT_DIR, 'oppia_tools', 'yarn-v1.17.3', 'bin', 'yarn')
FRONTEND_TEST_SCRIPT = 'run_frontend_tests'
GIT_IS_DIRTY_CMD = 'git status --porcelain --untracked-files=no'

Expand Down Expand Up @@ -280,7 +282,7 @@ def _start_python_script(scriptname):

def _start_npm_audit():
"""Starts the npm audit checks and returns the returncode of the task."""
task = subprocess.Popen([NPM_CMD, 'audit'])
task = subprocess.Popen([YARN_CMD, 'audit'])
task.communicate()
return task.returncode

Expand Down Expand Up @@ -342,17 +344,17 @@ def _does_diff_include_js_or_ts_files(files_to_lint):


def _does_diff_include_package_json(files_to_lint):
"""Returns true if diff includes package.json or package-lock.json.
"""Returns true if diff includes package.json or yarn.lock.
Args:
files_to_lint: list(str). List of files to be linted.
Returns:
bool. Whether the diff contains changes in package.json or
package-lock.json.
yarn.lock.
"""
for filename in files_to_lint:
if filename == 'package.json' or filename == 'package-lock.json':
if filename == 'package.json' or filename == 'yarn.lock':
return True
return False

Expand Down
9 changes: 2 additions & 7 deletions scripts/run_e2e_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,8 @@
function cleanup {
# Send a kill signal to the dev server and Selenium server. The awk command
# gets just the process ID from the grepped line.
kill `ps aux | grep "[Dd]ev_appserver.py --host=0.0.0.0 --port=9001" | awk '{print $2}'`
kill `ps aux | grep node_modules/webdriver-manager/selenium | awk '{print $2}'`

# Wait for the servers to go down; suppress "connection refused" error output
# from nc since that is exactly what we are expecting to happen.
while ( nc -vz localhost 4444 >/dev/null 2>&1 ); do sleep 1; done
while ( nc -vz localhost 9001 >/dev/null 2>&1 ); do sleep 1; done
kill `ps aux | grep "[Dd]ev_appserver.py --host=0.0.0.0 --port=9001" | awk '{print $2}'` || true
kill `ps aux | grep node_modules/webdriver-manager/selenium | awk '{print $2}'` || true

if [ -d "../protractor-screenshots" ]; then
echo ""
Expand Down
Loading

0 comments on commit e059814

Please sign in to comment.