mirror of
https://github.com/actions/runner-images.git
synced 2025-12-20 06:35:47 +00:00
[Ubuntu] Rework Сhromium installation to avoid using snap (#3029)
* rework chromium installation * added GetChromiumRevision function * changed getting chrome version * fixed GetChromiumRevision function * fixed CHROME_VERSION variable * move chromium installation to google-chrome.sh * added -qq for unzip * added comments to GetChromiumRevision function * updated tests and sofware report Co-authored-by: Nikita Bykov <v-nibyko@microsoft.com>
This commit is contained in:
@@ -12,5 +12,4 @@ for package in $common_packages $cmd_packages; do
|
||||
apt-get install -y --no-install-recommends $package
|
||||
done
|
||||
|
||||
invoke_tests "Apt"
|
||||
invoke_tests "Browsers" "Chromium"
|
||||
invoke_tests "Apt"
|
||||
@@ -1,12 +1,40 @@
|
||||
#!/bin/bash -e
|
||||
################################################################################
|
||||
## File: google-chrome.sh
|
||||
## Desc: Installs google-chrome and chromedriver
|
||||
## Desc: Installs google-chrome, chromedriver and chromium
|
||||
################################################################################
|
||||
|
||||
# Source the helpers for use with the script
|
||||
source $HELPER_SCRIPTS/install.sh
|
||||
|
||||
function GetChromiumRevision {
|
||||
CHROME_VERSION=$1
|
||||
|
||||
# Get the required Chromium revision corresponding to the Chrome version
|
||||
URL="https://omahaproxy.appspot.com/deps.json?version=${CHROME_VERSION}"
|
||||
REVISION=$(curl -s $URL | jq -r '.chromium_base_position')
|
||||
|
||||
# Take the first part of the revision variable to search not only for a specific version,
|
||||
# but also for similar ones, so that we can get a previous one if the required revision is not found
|
||||
FIRST_PART_OF_REVISION=${REVISION:0:${#REVISION}/2}
|
||||
URL="https://www.googleapis.com/storage/v1/b/chromium-browser-snapshots/o?delimiter=/&prefix=Linux_x64/${FIRST_PART_OF_REVISION}"
|
||||
VERSIONS=$(curl -s $URL | jq -r '.prefixes[]' | cut -d "/" -f 2 | sort --version-sort)
|
||||
|
||||
# If required Chromium revision is not found in the list
|
||||
# we should have to decrement the revision number until we find one.
|
||||
# This is mentioned in the documentation we use for this installation:
|
||||
# https://www.chromium.org/getting-involved/download-chromium
|
||||
RIGHT_REVISION=$(echo $VERSIONS | cut -f 1 -d " ")
|
||||
for version in $VERSIONS; do
|
||||
if [ $REVISION -lt $version ]; then
|
||||
echo $RIGHT_REVISION
|
||||
return
|
||||
fi
|
||||
RIGHT_REVISION=$version
|
||||
done
|
||||
echo $RIGHT_REVISION
|
||||
}
|
||||
|
||||
# Download and install Google Chrome
|
||||
CHROME_DEB_URL="https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb"
|
||||
CHROME_DEB_NAME="google-chrome-stable_current_amd64.deb"
|
||||
@@ -15,8 +43,8 @@ apt install "/tmp/${CHROME_DEB_NAME}" -f
|
||||
echo "CHROME_BIN=/usr/bin/google-chrome" | tee -a /etc/environment
|
||||
|
||||
# Parse Google Chrome version
|
||||
CHROME_VERSION=$(google-chrome --product-version)
|
||||
CHROME_VERSION=${CHROME_VERSION%.*}
|
||||
FULL_CHROME_VERSION=$(google-chrome --product-version)
|
||||
CHROME_VERSION=${FULL_CHROME_VERSION%.*}
|
||||
|
||||
# Determine the latest release of chromedriver
|
||||
# Compatibility of Google Chrome and Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/downloads/version-selection
|
||||
@@ -35,4 +63,22 @@ chmod +x $CHROMEDRIVER_BIN
|
||||
ln -s "$CHROMEDRIVER_BIN" /usr/bin/
|
||||
echo "CHROMEWEBDRIVER=$CHROMEDRIVER_DIR" | tee -a /etc/environment
|
||||
|
||||
# Download and unpack Chromium
|
||||
# Get Chromium version corresponding to the Google Chrome version
|
||||
REVISION=$(GetChromiumRevision $FULL_CHROME_VERSION)
|
||||
|
||||
ZIP_URL="https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Linux_x64%2F${REVISION}%2Fchrome-linux.zip?alt=media"
|
||||
ZIP_FILE="${REVISION}-chromium-linux.zip"
|
||||
|
||||
CHROMIUM_DIR="/usr/local/share/chromium"
|
||||
CHROMIUM_BIN="$CHROMIUM_DIR/chrome-linux/chrome"
|
||||
|
||||
# Download and unzip Chromium archive
|
||||
download_with_retries $ZIP_URL "/tmp" $ZIP_FILE
|
||||
mkdir $CHROMIUM_DIR
|
||||
unzip -qq /tmp/${ZIP_FILE} -d $CHROMIUM_DIR
|
||||
|
||||
ln -s $CHROMIUM_BIN /usr/bin/chromium
|
||||
|
||||
invoke_tests "Browsers" "Chrome"
|
||||
invoke_tests "Browsers" "Chromium"
|
||||
Reference in New Issue
Block a user