From 791ce2b7fb2fd78c0e3548a84623edabe79c386c Mon Sep 17 00:00:00 2001 From: alschmiedt Date: Tue, 9 Feb 2021 12:57:27 -0800 Subject: [PATCH] Migrate our tests to use github actions (#4614) (#4626) --- .github/workflows/build.yml | 41 +++++++++++++++++++ .travis.yml | 25 ----------- tests/generators/run_generators_in_browser.js | 4 +- tests/mocha/run_mocha_tests_in_browser.js | 4 +- tests/run_all_tests.sh | 13 +++--- tests/scripts/setup_linux_env.sh | 6 +-- 6 files changed, 54 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..fba74a7d7 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,41 @@ +# This workflow will do a clean install, start the selenium server, and run +# all of our tests. + +name: Node.js CI + +on: push + +jobs: + build: + # TODO (#2114): re-enable osx build. + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [10.x, 12.x, 14.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v2 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Npm Install + run: npm install + + - name: Linux Test Setup + if: runner.os == 'Linux' + run: source ./tests/scripts/setup_linux_env.sh + + - name: MacOS Test Setup + if: runner.os == 'macOS' + run: source ./tests/scripts/setup_osx_env.sh + + - name: Run + run: npm run test:run + + env: + CI: true diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8384ecd53..000000000 --- a/.travis.yml +++ /dev/null @@ -1,25 +0,0 @@ -language: node_js -os: linux -dist: xenial -node_js: - - 10 - - 12 - - 14 -addons: - chrome: stable - firefox: latest - # TODO (#2114): re-enable osx build. - # - os: osx - # node_js: stable - # osx_image: xcode8.3 - # addons: - # firefox: latest -env: - - TRAVIS_CI=true -before_script: - - 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: - - npm run test:run diff --git a/tests/generators/run_generators_in_browser.js b/tests/generators/run_generators_in_browser.js index 0a1692a7c..f0bafe10c 100644 --- a/tests/generators/run_generators_in_browser.js +++ b/tests/generators/run_generators_in_browser.js @@ -44,8 +44,8 @@ async function runGeneratorsInBrowser() { }, path: '/wd/hub' }; - // Run in headless mode on Travis. - if (process.env.TRAVIS_CI) { + // Run in headless mode on Github Actions. + if (process.env.CI) { options.capabilities['moz:firefoxOptions'] = { args: ['-headless'] }; diff --git a/tests/mocha/run_mocha_tests_in_browser.js b/tests/mocha/run_mocha_tests_in_browser.js index af89bd7c0..5adeabc2d 100644 --- a/tests/mocha/run_mocha_tests_in_browser.js +++ b/tests/mocha/run_mocha_tests_in_browser.js @@ -24,8 +24,8 @@ async function runMochaTestsInBrowser() { }, path: '/wd/hub' }; - // Run in headless mode on Travis. - if (process.env.TRAVIS_CI) { + // Run in headless mode on Github Actions. + if (process.env.CI) { options.capabilities['goog:chromeOptions'] = { args: ['--headless', '--no-sandbox', '--disable-dev-shm-usage'] }; diff --git a/tests/run_all_tests.sh b/tests/run_all_tests.sh index 78044ea24..2ab36c251 100755 --- a/tests/run_all_tests.sh +++ b/tests/run_all_tests.sh @@ -1,18 +1,17 @@ #!/bin/bash -if [ ! -z $TRAVIS ]; then echo "Executing run_all_tests.sh from $(pwd)"; fi +if [ ! -z $CI ]; then echo "Executing run_all_tests.sh from $(pwd)"; fi # ANSI colors BOLD_GREEN='\033[1;32m' BOLD_RED='\033[1;31m' ANSI_RESET='\033[0m' -travis_fold () { +gh_actions_fold () { local startOrEnd=$1 # Either "start" or "end" - local id=$2 # The fold id. No spaces. - if [ ! -z $TRAVIS ]; then - echo "travis_fold:$startOrEnd:$id" + if [ ! -z $CI ]; then + echo "::$startOrEnd::" fi } @@ -37,10 +36,10 @@ run_test_command () { echo "=======================================" echo "== $test_id" - travis_fold start $test_id + gh_actions_fold group $command local test_result=$? - travis_fold end $test_id + gh_actions_fold endgroup if [ $test_result -eq 0 ]; then echo -e "${BOLD_GREEN}SUCCESS:${ANSI_RESET} ${test_id}" else diff --git a/tests/scripts/setup_linux_env.sh b/tests/scripts/setup_linux_env.sh index 6e21e87e3..3a24ac784 100755 --- a/tests/scripts/setup_linux_env.sh +++ b/tests/scripts/setup_linux_env.sh @@ -1,8 +1,8 @@ #!/bin/bash -if [ "${TRAVIS_OS_NAME}" == "linux" ] +if [ "${RUNNER_OS}" == "Linux" ] then - export CHROME_BIN="/usr/bin/google-chrome" - sh -e /etc/init.d/xvfb start & + Xvfb :99 & + export DISPLAY=:99 & npm run test:prepare > /dev/null & fi