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

tests: leverage job dependencies #10994

Closed
wants to merge 6 commits into from
Closed
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
91 changes: 37 additions & 54 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest

# A lot of steps in common between all jobs. Can be done better when this feature lands:
# https://github.saobby.my.eu.orgmunity/t/reusing-sharing-inheriting-steps-between-jobs-declarations/16851
# https://github.com/actions/runner/issues/438
Expand All @@ -22,53 +22,22 @@ jobs:
with:
node-version: 10.x

# 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 test-clients
- run: xvfb-run --auto-servernum yarn test-bundle
- run: xvfb-run --auto-servernum yarn test-docs

# Fail if any changes were written to source files (ex, from: build/build-cdt-lib.js).
- run: git diff --exit-code

# buildtracker runs `git merge-base HEAD origin/master` which needs more history than depth=1. https://github.com/paularmstrong/build-tracker/issues/106
- name: Deepen git fetch (for buildtracker)
run: git fetch --deepen=100
- name: Store in buildtracker
# TODO(paulirish): Don't allow this to fail the build. https://github.com/paularmstrong/build-tracker/issues/200
run: yarn bt-cli upload-build || true
env:
# https://buildtracker.dev/docs/guides/github-actions#configuration
BT_API_AUTH_TOKEN: ${{ secrets.BT_API_AUTH_TOKEN }}

- name: Upload dist
uses: actions/upload-artifact@v1
with:
name: dist
path: dist/

misc:
test:
runs-on: ubuntu-latest
needs: [build]
strategy:
# e.g. if lint fails, continue to the unit tests anyway
fail-fast: false

steps:
- name: git clone
uses: actions/checkout@v2
Expand All @@ -78,6 +47,12 @@ jobs:
with:
node-version: 10.x

- name: Download dist
uses: actions/download-artifact@v2
with:
name: dist
path: dist/

- run: yarn --frozen-lockfile

- run: yarn diff:sample-json
Expand All @@ -86,26 +61,24 @@ jobs:
- run: yarn test-lantern
- run: yarn test-legacy-javascript
- run: yarn i18n:checks
- run: yarn dogfood-lhci

unit:
runs-on: ubuntu-latest

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 tests that require headfull Chrome.
- run: sudo apt-get install xvfb
- name: yarn unit
run: xvfb-run --auto-servernum yarn unit
- 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

- 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:
Expand All @@ -114,17 +87,27 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install protobuf==3.7.1
- run: yarn test-proto # Run before unit-core because the roundtrip json is needed for proto tests.

- run: yarn --frozen-lockfile
- run: yarn dogfood-lhci

- run: yarn test-proto # Run before unit-core because the roundtrip json is needed for proto tests.
# Fail if any changes were written to source files (ex, from: build/build-cdt-lib.js).
- run: git diff --exit-code

# buildtracker runs `git merge-base HEAD origin/master` which needs more history than depth=1. https://github.com/paularmstrong/build-tracker/issues/106
- name: Deepen git fetch (for buildtracker)
run: git fetch --deepen=100
- name: Store in buildtracker
# TODO(paulirish): Don't allow this to fail the build. https://github.com/paularmstrong/build-tracker/issues/200
run: yarn bt-cli upload-build || true
env:
# https://buildtracker.dev/docs/guides/github-actions#configuration
BT_API_AUTH_TOKEN: ${{ secrets.BT_API_AUTH_TOKEN }}

- run: sudo apt-get install xvfb
- run: xvfb-run --auto-servernum yarn unit

smoke:
runs-on: ubuntu-latest

steps:
- name: git clone
uses: actions/checkout@v2
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,3 @@ proto/scripts/*_processed.json
# require any lock file to be checked in explicitly
yarn.lock

proto/sample_v2_round_trip.json
2 changes: 1 addition & 1 deletion lighthouse-core/test/test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function getProtoRoundTrip() {
let itIfProtoExists;
try {
sampleResultsRoundtripStr =
fs.readFileSync(__dirname + '/../../proto/sample_v2_round_trip.json', 'utf-8');
fs.readFileSync(__dirname + '/../../dist/proto/sample_v2_round_trip.json', 'utf-8');
describeIfProtoExists = describe;
itIfProtoExists = it;
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"ultradumbBenchmark": "./lighthouse-core/scripts/benchmark.js",
"minify-latest-run": "./lighthouse-core/scripts/lantern/minify-trace.js ./latest-run/defaultPass.trace.json ./latest-run/defaultPass.trace.min.json && ./lighthouse-core/scripts/lantern/minify-devtoolslog.js ./latest-run/defaultPass.devtoolslog.json ./latest-run/defaultPass.devtoolslog.min.json",
"compile-proto": "protoc --python_out=./ ./proto/lighthouse-result.proto && mv ./proto/*_pb2.py ./proto/scripts || (echo \"❌ Install protobuf ≥ 3.7.1 to compile the proto file.\" && false)",
"build-proto-roundtrip": "cd proto/scripts && PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION=2 python json_roundtrip_via_proto.py",
"build-proto-roundtrip": "mkdir -p dist/proto && cd proto/scripts && PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION=2 python json_roundtrip_via_proto.py",
"static-server": "node lighthouse-cli/test/fixtures/static-server.js"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion proto/scripts/json_roundtrip_via_proto.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

path_sample_preprocessed = path_dir + '/sample_v2_processed.json'
path_sample = path_dir + '/../../lighthouse-core/test/results/sample_v2.json'
path_round_trip = path_dir + '/../sample_v2_round_trip.json'
path_round_trip = path_dir + '/../../dist/proto/sample_v2_round_trip.json'

def clean():
try:
Expand Down