Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
[ci] Import flutter/packages install_chromium.sh (#6727)
Browse files Browse the repository at this point in the history
* [ci] Import flutter/packages install_chromium.sh

Brings over the newer flutter/packages version of install_chromium.sh as
part of pre-aligning the repositories for later merging.

Part of flutter/flutter#113764

* Update .cirrus.yml

Co-authored-by: David Iglesias <[email protected]>

Co-authored-by: David Iglesias <[email protected]>
  • Loading branch information
stuartmorgan and ditman authored Nov 22, 2022
1 parent 5d847ef commit 2a52394
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 22 deletions.
23 changes: 14 additions & 9 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ env:
CHANNEL: "master" # Default to master when not explicitly set by a task.
PLUGIN_TOOL_COMMAND: "dart ./script/tool/bin/flutter_plugin_tools.dart"

install_chrome_linux_template: &INSTALL_CHROME_LINUX
env:
CHROME_NO_SANDBOX: true
CHROME_DOWNLOAD_DIR: /tmp/chromium
CHROME_EXECUTABLE: $CHROME_DOWNLOAD_DIR/chrome-linux/chrome
CHROMEDRIVER_EXECUTABLE: $CHROME_DOWNLOAD_DIR/chromedriver/chromedriver
PATH: $PATH:$CHROME_DOWNLOAD_DIR/chrome-linux
install_chromium_script:
# Install a pinned version of Chromium and its corresponding ChromeDriver.
# Setting CHROME_EXECUTABLE above causes this version to be used for tests.
- ./script/install_chromium.sh

tool_setup_template: &TOOL_SETUP_TEMPLATE
tool_setup_script:
- .ci/scripts/prepare_tool.sh
Expand Down Expand Up @@ -284,16 +296,9 @@ task:
matrix:
CHANNEL: "master"
CHANNEL: "stable"
CHROME_NO_SANDBOX: true
CHROME_DIR: /tmp/web_chromium/
CHROME_EXECUTABLE: $CHROME_DIR/chrome-linux/chrome
install_script:
# Install a pinned version of Chromium and its corresponding ChromeDriver.
# Setting CHROME_EXECUTABLE above causes this version to be used for tests.
- ./script/install_chromium.sh "$CHROME_DIR"
<< : *INSTALL_CHROME_LINUX
chromedriver_background_script:
- cd "$CHROME_DIR"
- ./chromedriver/chromedriver --port=4444
- $CHROMEDRIVER_EXECUTABLE --port=4444
build_script:
- ./script/tool_runner.sh build-examples --web
drive_script:
Expand Down
36 changes: 23 additions & 13 deletions script/install_chromium.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,51 @@
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# This script may be run as:
# $ CHROME_DOWNLOAD_DIR=./whatever script/install_chromium.sh
set -e
set -x

readonly TARGET_DIR=$1
# The target directory where chromium is going to be downloaded
: "${CHROME_DOWNLOAD_DIR:=/tmp/chromium}" # Default value for the CHROME_DOWNLOAD_DIR env.

# The build of Chromium used to test web functionality.
#
# Chromium builds can be located here: https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Linux_x64/
#
# Check: https://github.com/flutter/engine/blob/main/lib/web_ui/dev/browser_lock.yaml
readonly CHROMIUM_BUILD=929514
# Check: https://github.com/flutter/engine/blob/master/lib/web_ui/dev/browser_lock.yaml
: "${CHROMIUM_BUILD:=950363}" # Default value for the CHROMIUM_BUILD env.

# Convenience defaults for CHROME_EXECUTABLE and CHROMEDRIVER_EXECUTABLE. These
# two values should be set in the environment from CI, so this script can validate
# that it has completed downloading chrome and driver successfully (and the expected
# files are executable)
: "${CHROME_EXECUTABLE:=$CHROME_DOWNLOAD_DIR/chrome-linux/chrome}"
: "${CHROMEDRIVER_EXECUTABLE:=$CHROME_DOWNLOAD_DIR/chromedriver/chromedriver}"

# The correct ChromeDriver is distributed alongside the chromium build above, as
# `chromedriver_linux64.zip`, so no need to hardcode any extra info about it.
readonly DOWNLOAD_ROOT="https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Linux_x64%2F${CHROMIUM_BUILD}%2F"

# Install Chromium.
mkdir "$TARGET_DIR"
readonly CHROMIUM_ZIP_FILE="$TARGET_DIR/chromium.zip"
mkdir "$CHROME_DOWNLOAD_DIR"
readonly CHROMIUM_ZIP_FILE="$CHROME_DOWNLOAD_DIR/chromium.zip"
wget --no-verbose "${DOWNLOAD_ROOT}chrome-linux.zip?alt=media" -O "$CHROMIUM_ZIP_FILE"
unzip -q "$CHROMIUM_ZIP_FILE" -d "$TARGET_DIR/"
unzip -q "$CHROMIUM_ZIP_FILE" -d "$CHROME_DOWNLOAD_DIR/"

# Install ChromeDriver.
readonly DRIVER_ZIP_FILE="$TARGET_DIR/chromedriver.zip"
readonly DRIVER_ZIP_FILE="$CHROME_DOWNLOAD_DIR/chromedriver.zip"
wget --no-verbose "${DOWNLOAD_ROOT}chromedriver_linux64.zip?alt=media" -O "$DRIVER_ZIP_FILE"
unzip -q "$DRIVER_ZIP_FILE" -d "$TARGET_DIR/"
# Rename TARGET_DIR/chromedriver_linux64 to the expected TARGET_DIR/chromedriver
mv -T "$TARGET_DIR/chromedriver_linux64" "$TARGET_DIR/chromedriver"

export CHROME_EXECUTABLE="$TARGET_DIR/chrome-linux/chrome"
unzip -q "$DRIVER_ZIP_FILE" -d "$CHROME_DOWNLOAD_DIR/"
# Rename CHROME_DOWNLOAD_DIR/chromedriver_linux64 to the expected CHROME_DOWNLOAD_DIR/chromedriver
mv -T "$CHROME_DOWNLOAD_DIR/chromedriver_linux64" "$CHROME_DOWNLOAD_DIR/chromedriver"

# Echo info at the end for ease of debugging.
#
# exports from this script cannot be used elsewhere in the .cirrus.yml file.
set +x
echo
readonly CHROMEDRIVER_EXECUTABLE="$TARGET_DIR/chromedriver/chromedriver"
echo "$CHROME_EXECUTABLE"
"$CHROME_EXECUTABLE" --version
echo "$CHROMEDRIVER_EXECUTABLE"
Expand Down

0 comments on commit 2a52394

Please sign in to comment.