[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:
Nikita Bykov
2021-04-02 19:21:33 +03:00
committed by GitHub
parent be27ebfdb3
commit b7f276c003
5 changed files with 54 additions and 12 deletions

View File

@@ -215,11 +215,9 @@ $browsersAndDriversList = @(
(Get-ChromeVersion),
(Get-ChromeDriverVersion),
(Get-FirefoxVersion),
(Get-GeckodriverVersion)
(Get-GeckodriverVersion),
(Get-ChromiumVersion)
)
if (Test-IsUbuntu20) {
$browsersAndDriversList = @(Get-ChromiumVersion) + $browsersAndDriversList
}
$markdown += New-MDList -Style Unordered -Lines $browsersAndDriversList
$markdown += New-MDHeader "Environment variables" -Level 4

View File

@@ -13,4 +13,3 @@ for package in $common_packages $cmd_packages; do
done
invoke_tests "Apt"
invoke_tests "Browsers" "Chromium"

View File

@@ -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"

View File

@@ -18,7 +18,7 @@ Describe "Chrome" {
}
}
Describe "Chromium" -Skip:(-not (Test-IsUbuntu20)) {
Describe "Chromium" {
It "Chromium" {
"chromium --version" | Should -ReturnZeroExitCode
}

View File

@@ -116,7 +116,6 @@
"apt": {
"common_packages": [
"build-essential",
"chromium-browser",
"dbus",
"dnsutils",
"dpkg",