Skip to content

Commit

Permalink
tests: parallelize all the tests (GoogleChrome#11009)
Browse files Browse the repository at this point in the history
Co-authored-by: connorjclark and brendankenny
  • Loading branch information
paulirish authored and George Martin committed Aug 28, 2020
1 parent 1ff6b6d commit 3909476
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 83 deletions.
94 changes: 12 additions & 82 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,59 +22,21 @@ jobs:
with:
node-version: 10.x

- name: Setup protoc
uses: arduino/setup-protoc@7ad700d
with:
version: '3.7.1'
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 2.7
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install protobuf==3.7.1
# Chrome Stable is already installed by default.
- name: Install Chrome ToT
working-directory: /home/runner
run: bash $GITHUB_WORKSPACE/lighthouse-core/scripts/download-chrome.sh && mv chrome-linux chrome-linux-tot
env:
CHROME_PATH: /home/runner/chrome-linux-tot

# Cache yarn deps. thx https://github.com/actions/cache/blob/master/examples.md#node---yarn
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Set up node_modules cache
uses: actions/cache@v1
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn --frozen-lockfile
- run: yarn build-all

# Run tests that require headfull Chrome.
- run: sudo apt-get install xvfb
- run: xvfb-run --auto-servernum yarn unit
- run: xvfb-run --auto-servernum yarn test-clients
- run: xvfb-run --auto-servernum yarn test-bundle
- run: xvfb-run --auto-servernum yarn test-docs

- name: Smoke (ToT)
run: xvfb-run --auto-servernum yarn smoke --debug -j=1 --retries=2
env:
CHROME_PATH: /home/runner/chrome-linux-tot/chrome
- name: Smoke (stable)
run: xvfb-run --auto-servernum yarn smoke --debug -j=1 --retries=2

- name: yarn test-clients
run: xvfb-run --auto-servernum yarn test-clients
- name: yarn test-bundle
run: xvfb-run --auto-servernum yarn test-bundle
- name: yarn test-docs
run: xvfb-run --auto-servernum yarn test-docs

- run: yarn diff:sample-json
- run: yarn type-check
- run: yarn lint
- run: yarn test-lantern
- run: yarn test-legacy-javascript
- run: yarn i18n:checks
Expand All @@ -101,11 +63,7 @@ jobs:

# `unit` includes just unit and proto tests.
unit:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
name: unit_${{ matrix.os }}
runs-on: ubuntu-latest

steps:
- name: git clone
Expand Down Expand Up @@ -136,30 +94,20 @@ jobs:
- run: yarn test-proto # Run before unit-core because the roundtrip json is needed for proto tests.

- run: sudo apt-get install xvfb
if: matrix.os == 'ubuntu-latest'

- name: yarn unit
run: xvfb-run --auto-servernum yarn unit
if: matrix.os == 'ubuntu-latest'

# For windows, just test the potentially platform-specific code.
- name: yarn unit-cli
run: yarn unit-cli
if: matrix.os == 'windows-latest'
- run: yarn diff:sample-json
if: matrix.os == 'windows-latest'

# `smoke` runs as a matrix across 4 jobs:
# * The smoketest groups are split across two runners, to parallelize.
# * Then, those are run with both Chrome stable and ToT Chromium, in parallel
smoke:
runs-on: ubuntu-latest
strategy:
matrix:
chrome-channel: ['stable', 'ToT']
smoke-test-invert: [false, true]
# e.g. if smoke 0 fails, continue with smoke 1 anyway
fail-fast: false
runs-on: ubuntu-latest
env:
# The smokehouse tests run by job `smoke_0`. `smoke_1` will run the rest.
SMOKE_GROUP_1: a11y oopif pwa pwa2 pwa3 dbw redirects errors offline
Expand Down Expand Up @@ -187,24 +135,6 @@ jobs:
- run: yarn --frozen-lockfile

- run: sudo apt-get install xvfb
- name: Run smoke tests
run: xvfb-run --auto-servernum yarn smoke --debug -j=1 --retries=2 --invert-match ${{ matrix.smoke-test-invert }} $SMOKE_GROUP_1

# Only run smoke tests for windows against stable chrome.
smoke-windows:
runs-on: windows-latest
name: smoke_stable_windows

steps:
- name: git clone
uses: actions/checkout@v2

- name: Use Node.js 10.x
uses: actions/setup-node@v1
with:
node-version: 10.x

- run: yarn --frozen-lockfile

- name: Run smoke tests
run: yarn smoke --debug -j=1 --retries=2 dbw oopif offline lantern metrics
run: xvfb-run --auto-servernum yarn smoke --debug -j=1 --retries=2 --invert-match ${{ matrix.smoke-test-invert }} $SMOKE_GROUP_1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const ChromeLauncher = require('chrome-launcher');
const ChromeProtocol = require('../../../../lighthouse-core/gather/connections/cri.js');

// Load bundle, which creates a `global.runBundledLighthouse`.
// @ts-ignore - file exists if `yarn build-all` is run, but not used for types anyways.
// @ts-ignore - file won't exist until `yarn build-all`, but not used for types anyways.
require('../../../../dist/lighthouse-dt-bundle.js'); // eslint-disable-line

/** @type {import('../../../../lighthouse-core/index.js')} */
Expand Down

0 comments on commit 3909476

Please sign in to comment.