Skip to content

Commit 2a52394

Browse files
[ci] Import flutter/packages install_chromium.sh (#6727)
* [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]>
1 parent 5d847ef commit 2a52394

File tree

2 files changed

+37
-22
lines changed

2 files changed

+37
-22
lines changed

.cirrus.yml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@ env:
66
CHANNEL: "master" # Default to master when not explicitly set by a task.
77
PLUGIN_TOOL_COMMAND: "dart ./script/tool/bin/flutter_plugin_tools.dart"
88

9+
install_chrome_linux_template: &INSTALL_CHROME_LINUX
10+
env:
11+
CHROME_NO_SANDBOX: true
12+
CHROME_DOWNLOAD_DIR: /tmp/chromium
13+
CHROME_EXECUTABLE: $CHROME_DOWNLOAD_DIR/chrome-linux/chrome
14+
CHROMEDRIVER_EXECUTABLE: $CHROME_DOWNLOAD_DIR/chromedriver/chromedriver
15+
PATH: $PATH:$CHROME_DOWNLOAD_DIR/chrome-linux
16+
install_chromium_script:
17+
# Install a pinned version of Chromium and its corresponding ChromeDriver.
18+
# Setting CHROME_EXECUTABLE above causes this version to be used for tests.
19+
- ./script/install_chromium.sh
20+
921
tool_setup_template: &TOOL_SETUP_TEMPLATE
1022
tool_setup_script:
1123
- .ci/scripts/prepare_tool.sh
@@ -284,16 +296,9 @@ task:
284296
matrix:
285297
CHANNEL: "master"
286298
CHANNEL: "stable"
287-
CHROME_NO_SANDBOX: true
288-
CHROME_DIR: /tmp/web_chromium/
289-
CHROME_EXECUTABLE: $CHROME_DIR/chrome-linux/chrome
290-
install_script:
291-
# Install a pinned version of Chromium and its corresponding ChromeDriver.
292-
# Setting CHROME_EXECUTABLE above causes this version to be used for tests.
293-
- ./script/install_chromium.sh "$CHROME_DIR"
299+
<< : *INSTALL_CHROME_LINUX
294300
chromedriver_background_script:
295-
- cd "$CHROME_DIR"
296-
- ./chromedriver/chromedriver --port=4444
301+
- $CHROMEDRIVER_EXECUTABLE --port=4444
297302
build_script:
298303
- ./script/tool_runner.sh build-examples --web
299304
drive_script:

script/install_chromium.sh

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,51 @@
22
# Copyright 2013 The Flutter Authors. All rights reserved.
33
# Use of this source code is governed by a BSD-style license that can be
44
# found in the LICENSE file.
5+
6+
# This script may be run as:
7+
# $ CHROME_DOWNLOAD_DIR=./whatever script/install_chromium.sh
58
set -e
69
set -x
710

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

1014
# The build of Chromium used to test web functionality.
1115
#
1216
# Chromium builds can be located here: https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Linux_x64/
1317
#
14-
# Check: https://github.com/flutter/engine/blob/main/lib/web_ui/dev/browser_lock.yaml
15-
readonly CHROMIUM_BUILD=929514
18+
# Check: https://github.com/flutter/engine/blob/master/lib/web_ui/dev/browser_lock.yaml
19+
: "${CHROMIUM_BUILD:=950363}" # Default value for the CHROMIUM_BUILD env.
20+
21+
# Convenience defaults for CHROME_EXECUTABLE and CHROMEDRIVER_EXECUTABLE. These
22+
# two values should be set in the environment from CI, so this script can validate
23+
# that it has completed downloading chrome and driver successfully (and the expected
24+
# files are executable)
25+
: "${CHROME_EXECUTABLE:=$CHROME_DOWNLOAD_DIR/chrome-linux/chrome}"
26+
: "${CHROMEDRIVER_EXECUTABLE:=$CHROME_DOWNLOAD_DIR/chromedriver/chromedriver}"
1627

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

2132
# Install Chromium.
22-
mkdir "$TARGET_DIR"
23-
readonly CHROMIUM_ZIP_FILE="$TARGET_DIR/chromium.zip"
33+
mkdir "$CHROME_DOWNLOAD_DIR"
34+
readonly CHROMIUM_ZIP_FILE="$CHROME_DOWNLOAD_DIR/chromium.zip"
2435
wget --no-verbose "${DOWNLOAD_ROOT}chrome-linux.zip?alt=media" -O "$CHROMIUM_ZIP_FILE"
25-
unzip -q "$CHROMIUM_ZIP_FILE" -d "$TARGET_DIR/"
36+
unzip -q "$CHROMIUM_ZIP_FILE" -d "$CHROME_DOWNLOAD_DIR/"
2637

2738
# Install ChromeDriver.
28-
readonly DRIVER_ZIP_FILE="$TARGET_DIR/chromedriver.zip"
39+
readonly DRIVER_ZIP_FILE="$CHROME_DOWNLOAD_DIR/chromedriver.zip"
2940
wget --no-verbose "${DOWNLOAD_ROOT}chromedriver_linux64.zip?alt=media" -O "$DRIVER_ZIP_FILE"
30-
unzip -q "$DRIVER_ZIP_FILE" -d "$TARGET_DIR/"
31-
# Rename TARGET_DIR/chromedriver_linux64 to the expected TARGET_DIR/chromedriver
32-
mv -T "$TARGET_DIR/chromedriver_linux64" "$TARGET_DIR/chromedriver"
33-
34-
export CHROME_EXECUTABLE="$TARGET_DIR/chrome-linux/chrome"
41+
unzip -q "$DRIVER_ZIP_FILE" -d "$CHROME_DOWNLOAD_DIR/"
42+
# Rename CHROME_DOWNLOAD_DIR/chromedriver_linux64 to the expected CHROME_DOWNLOAD_DIR/chromedriver
43+
mv -T "$CHROME_DOWNLOAD_DIR/chromedriver_linux64" "$CHROME_DOWNLOAD_DIR/chromedriver"
3544

3645
# Echo info at the end for ease of debugging.
46+
#
47+
# exports from this script cannot be used elsewhere in the .cirrus.yml file.
3748
set +x
3849
echo
39-
readonly CHROMEDRIVER_EXECUTABLE="$TARGET_DIR/chromedriver/chromedriver"
4050
echo "$CHROME_EXECUTABLE"
4151
"$CHROME_EXECUTABLE" --version
4252
echo "$CHROMEDRIVER_EXECUTABLE"

0 commit comments

Comments
 (0)