Skip to content

Commit

Permalink
misc: improve download-chrome usabality
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark committed Nov 29, 2023
1 parent 4949ffb commit 5dc949e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 25 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
fetch-depth: 100
- run: bash core/scripts/github-actions-commit-range.sh
env:
CHROME_PATH: ${{ github.workspace }}/lighthouse/.tmp/chrome-tot/chrome
GITHUB_CONTEXT_PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
GITHUB_CONTEXT_BASE_SHA: ${{ github.event.before }}

Expand All @@ -38,11 +39,8 @@ jobs:
- run: yarn build-all

# Run pptr tests using ToT Chrome instead of stable default.
- name: Define ToT chrome path
run: echo "CHROME_PATH=/home/runner/chrome-linux-tot/chrome" >> $GITHUB_ENV
- name: Install Chrome ToT
working-directory: /home/runner
run: bash $GITHUB_WORKSPACE/core/scripts/download-chrome.sh && mv chrome-linux chrome-linux-tot
run: bash $GITHUB_WORKSPACE/core/scripts/download-chrome.sh

# Run tests that require headfull Chrome.
- run: sudo apt-get install xvfb
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/devtools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ jobs:
fail-fast: false
runs-on: ubuntu-latest
env:
CHROME_PATH: ${{ github.workspace }}/lighthouse/.tmp/chrome-tot/chrome
FORCE_COLOR: true
name: DevTools smoke ${{ matrix.smoke-test-shard }}/${{ strategy.job-total }}

Expand Down Expand Up @@ -159,11 +160,8 @@ jobs:
- run: yarn build-report
working-directory: ${{ github.workspace }}/lighthouse

- name: Define ToT chrome path
run: echo "CHROME_PATH=/home/runner/chrome-linux-tot/chrome" >> $GITHUB_ENV
- name: Install Chrome ToT
working-directory: /home/runner
run: bash ${{ github.workspace }}/lighthouse/core/scripts/download-chrome.sh && mv chrome-linux chrome-linux-tot
run: bash ${{ github.workspace }}/lighthouse/core/scripts/download-chrome.sh

- run: mkdir latest-run
working-directory: ${{ github.workspace }}/lighthouse
Expand Down
12 changes: 4 additions & 8 deletions .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@ jobs:

- name: Define ToT chrome path
if: matrix.chrome-channel == 'ToT'
run: echo "CHROME_PATH=/home/runner/chrome-linux-tot/chrome" >> $GITHUB_ENV
run: echo "CHROME_PATH=${{ github.workspace }}/lighthouse/.tmp/chrome-tot/chrome" >> $GITHUB_ENV

# Chrome Stable is already installed by default.
- name: Install Chrome ToT
if: matrix.chrome-channel == 'ToT'
working-directory: /home/runner
run: bash $GITHUB_WORKSPACE/core/scripts/download-chrome.sh && mv chrome-linux chrome-linux-tot
run: bash $GITHUB_WORKSPACE/core/scripts/download-chrome.sh

- run: yarn install --frozen-lockfile --network-timeout 1000000
- run: yarn build-report
Expand Down Expand Up @@ -127,6 +126,7 @@ jobs:
fail-fast: false
runs-on: ubuntu-latest
env:
CHROME_PATH: ${{ github.workspace }}/lighthouse/.tmp/chrome-tot/chrome
# The total number of shards. Set dynamically when length of *single* matrix variable is
# computable. See https://github.51.almunity/t/get-length-of-strategy-matrix-or-get-all-matrix-options/18342
SHARD_TOTAL: 3
Expand All @@ -146,12 +146,8 @@ jobs:
- run: yarn build-report
- run: yarn build-devtools

- name: Define ToT chrome path
run: echo "CHROME_PATH=/home/runner/chrome-linux-tot/chrome" >> $GITHUB_ENV

- name: Install Chrome ToT
working-directory: /home/runner
run: bash $GITHUB_WORKSPACE/core/scripts/download-chrome.sh && mv chrome-linux chrome-linux-tot
run: bash $GITHUB_WORKSPACE/core/scripts/download-chrome.sh

- name: yarn test-bundle
run: yarn test-bundle --shard=${{ matrix.smoke-test-shard }}/$SHARD_TOTAL --retries=2
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
runs-on: ubuntu-latest
name: node ${{ matrix.node }}
env:
CHROME_PATH: ${{ github.workspace }}/lighthouse/.tmp/chrome-tot/chrome
LATEST_NODE: '18'
FORCE_COLOR: true

Expand Down Expand Up @@ -53,11 +54,8 @@ jobs:
- run: yarn reset-link

# Run pptr tests using ToT Chrome instead of stable default.
- name: Define ToT chrome path
run: echo "CHROME_PATH=/home/runner/chrome-linux-tot/chrome" >> $GITHUB_ENV
- name: Install Chrome ToT
working-directory: /home/runner
run: bash $GITHUB_WORKSPACE/core/scripts/download-chrome.sh && mv chrome-linux chrome-linux-tot
run: bash $GITHUB_WORKSPACE/core/scripts/download-chrome.sh

- run: yarn test-proto # Run before unit-core because the roundtrip json is needed for proto tests.

Expand Down
21 changes: 16 additions & 5 deletions core/scripts/download-chrome.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,21 @@
##

# Download chrome inside of our CI env.
# Takes one arg - the location to extract ToT chrome to. Defaults to .tmp/chrome-tot
# If already exists, this script does nothing.

set -euo pipefail

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
LH_ROOT_DIR="$SCRIPT_DIR/../.."

chrome_out=${1:-"$LH_ROOT_DIR/.tmp/chrome-tot"}

if [ -e "$chrome_out" ]; then
echo "cached chrome found"
exit 0
fi

unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) machine=Linux;;
Expand All @@ -28,8 +40,7 @@ else
exit 1
fi

if [ -e "$CHROME_PATH" ]; then
echo "cached chrome found"
else
curl "$url" -Lo chrome.zip && unzip -q chrome.zip
fi
mkdir -p .tmp-download && cd .tmp-download
curl "$url" -Lo chrome.zip && unzip -q chrome.zip && rm chrome.zip
mv * "$chrome_out"
cd - && rmdir -f .tmp-download

0 comments on commit 5dc949e

Please sign in to comment.