mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-14 22:09:26 +00:00
Get revision for chromium from new source (#7988)
This commit is contained in:
committed by
GitHub
parent
1190d2f46f
commit
51de0dda19
@@ -8,48 +8,27 @@
|
|||||||
source $HELPER_SCRIPTS/install.sh
|
source $HELPER_SCRIPTS/install.sh
|
||||||
|
|
||||||
function GetChromiumRevision {
|
function GetChromiumRevision {
|
||||||
CHROME_VERSION=$1
|
CHROME_REVISION=$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')
|
|
||||||
|
|
||||||
# Temporarily hardcode revision as both requests
|
|
||||||
# for 115.0.5790.102 and 115.0.5790.98 return old incorrect revision
|
|
||||||
if [ $REVISION -eq "1583" ]; then
|
|
||||||
REVISION="1148114"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Some Google Chrome versions are based on Chromium revisions for which a (usually very old) Chromium release with the same number exist. So far this has heppened with 4 digits long Chromium revisions (1060, 1086).
|
|
||||||
# Use the previous Chromium release when this happens to avoid downloading and installing very old Chromium releases that would break image build because of incompatibilities.
|
|
||||||
# First reported with: https://github.com/actions/runner-images/issues/5256
|
|
||||||
if [ ${#REVISION} -le 4 ]; then
|
|
||||||
CURRENT_REVISIONS=$(curl -s "https://omahaproxy.appspot.com/all.json?os=linux&channel=stable")
|
|
||||||
PREVIOUS_VERSION=$(echo "$CURRENT_REVISIONS" | jq -r '.[].versions[].previous_version')
|
|
||||||
URL="https://omahaproxy.appspot.com/deps.json?version=${PREVIOUS_VERSION}"
|
|
||||||
REVISION=$(curl -s $URL | jq -r '.chromium_base_position')
|
|
||||||
fi
|
|
||||||
# Take the first part of the revision variable to search not only for a specific version,
|
# 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
|
# 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}
|
CHROME_REVISION_PREFIX=${CHROME_REVISION:0:${#CHROME_REVISION}/2+1}
|
||||||
FIRST_PART_OF_PREVIOUS_REVISION=$(expr $FIRST_PART_OF_REVISION - 1)
|
SEARCH_URL="https://www.googleapis.com/storage/v1/b/chromium-browser-snapshots/o?delimiter=/&prefix=Linux_x64"
|
||||||
URL="https://www.googleapis.com/storage/v1/b/chromium-browser-snapshots/o?delimiter=/&prefix=Linux_x64"
|
|
||||||
# Revision can include a hash instead of a number. Need to filter it out https://github.com/actions/runner-images/issues/5256
|
# Revision can include a hash instead of a number. Need to filter it out https://github.com/actions/runner-images/issues/5256
|
||||||
VERSIONS=$((curl -s $URL/${FIRST_PART_OF_REVISION} | jq -r '.prefixes[]' && curl -s $URL/${FIRST_PART_OF_PREVIOUS_REVISION} | jq -r '.prefixes[]') | grep -E "Linux_x64\/[0-9]+\/"| cut -d "/" -f 2 | sort --version-sort)
|
REVISIONS_AVAILABLE=$(curl -s $SEARCH_URL/${CHROME_REVISION_PREFIX} | jq -r '.prefixes[]' | grep -E "Linux_x64\/[0-9]+\/"| cut -d "/" -f 2 | sort --version-sort)
|
||||||
|
|
||||||
# If required Chromium revision is not found in the list
|
# If required Chromium revision is not found in the list
|
||||||
# we should have to decrement the revision number until we find one.
|
# we should have to decrement the revision number until we find one.
|
||||||
# This is mentioned in the documentation we use for this installation:
|
# This is mentioned in the documentation we use for this installation:
|
||||||
# https://www.chromium.org/getting-involved/download-chromium
|
# https://www.chromium.org/getting-involved/download-chromium
|
||||||
RIGHT_REVISION=$(echo $VERSIONS | cut -f 1 -d " ")
|
LATEST_VALID_REVISION=$(echo $REVISIONS_AVAILABLE | cut -f 1 -d " ")
|
||||||
for version in $VERSIONS; do
|
for REVISION in $REVISIONS_AVAILABLE; do
|
||||||
if [ $REVISION -lt $version ]; then
|
if [ "$CHROME_REVISION" -lt "$REVISION" ]; then
|
||||||
echo $RIGHT_REVISION
|
break
|
||||||
return
|
|
||||||
fi
|
fi
|
||||||
RIGHT_REVISION=$version
|
LATEST_VALID_REVISION=$REVISION
|
||||||
done
|
done
|
||||||
echo $RIGHT_REVISION
|
echo $LATEST_VALID_REVISION
|
||||||
}
|
}
|
||||||
|
|
||||||
# Download and install Google Chrome
|
# Download and install Google Chrome
|
||||||
@@ -67,36 +46,38 @@ FULL_CHROME_VERSION=$(google-chrome --product-version)
|
|||||||
CHROME_VERSION=${FULL_CHROME_VERSION%.*}
|
CHROME_VERSION=${FULL_CHROME_VERSION%.*}
|
||||||
echo "Chrome version is $FULL_CHROME_VERSION"
|
echo "Chrome version is $FULL_CHROME_VERSION"
|
||||||
|
|
||||||
# Determine the download url for chromedriver
|
# Get chrome versions information
|
||||||
CHROME_VERSIONS_JSON=$(curl -fsSL https://googlechromelabs.github.io/chrome-for-testing/latest-patch-versions-per-build-with-downloads.json)
|
CHROME_PLATFORM="linux64"
|
||||||
CHROMEDRIVER_VERSION=$(echo $CHROME_VERSIONS_JSON | jq -r '.builds["'"$CHROME_VERSION"'"].version')
|
CHROME_VERSIONS_URL="https://googlechromelabs.github.io/chrome-for-testing/latest-patch-versions-per-build-with-downloads.json"
|
||||||
CHROMEDRIVER_URL=$(echo $CHROME_VERSIONS_JSON | jq -r '.builds["'"$CHROME_VERSION"'"].downloads.chromedriver[] | select(.platform=="linux64").url')
|
CHROME_VERSIONS_JSON=$(curl -fsSL "${CHROME_VERSIONS_URL}")
|
||||||
|
|
||||||
# Download and unpack the latest release of chromedriver
|
# Download and unpack the latest release of chromedriver
|
||||||
echo "Installing chromedriver version $CHROMEDRIVER_VERSION"
|
CHROMEDRIVER_VERSION=$(echo "${CHROME_VERSIONS_JSON}" | jq -r '.builds["'"$CHROME_VERSION"'"].version')
|
||||||
download_with_retries $CHROMEDRIVER_URL "/tmp" "chromedriver_linux64.zip"
|
CHROMEDRIVER_URL=$(echo "${CHROME_VERSIONS_JSON}" | jq -r '.builds["'"$CHROME_VERSION"'"].downloads.chromedriver[] | select(.platform=="'"${CHROME_PLATFORM}"'").url')
|
||||||
unzip -qq /tmp/chromedriver_linux64.zip -d /usr/local/share
|
CHROMEDRIVER_ARCHIVE="chromedriver_linux64.zip"
|
||||||
|
|
||||||
CHROMEDRIVER_DIR="/usr/local/share/chromedriver-linux64"
|
CHROMEDRIVER_DIR="/usr/local/share/chromedriver-linux64"
|
||||||
CHROMEDRIVER_BIN="$CHROMEDRIVER_DIR/chromedriver"
|
CHROMEDRIVER_BIN="$CHROMEDRIVER_DIR/chromedriver"
|
||||||
|
|
||||||
|
echo "Installing chromedriver version $CHROMEDRIVER_VERSION"
|
||||||
|
download_with_retries $CHROMEDRIVER_URL "/tmp" $CHROMEDRIVER_ARCHIVE
|
||||||
|
unzip -qq /tmp/$CHROMEDRIVER_ARCHIVE -d /usr/local/share
|
||||||
|
|
||||||
chmod +x $CHROMEDRIVER_BIN
|
chmod +x $CHROMEDRIVER_BIN
|
||||||
ln -s "$CHROMEDRIVER_BIN" /usr/bin/
|
ln -s "$CHROMEDRIVER_BIN" /usr/bin/
|
||||||
echo "CHROMEWEBDRIVER=$CHROMEDRIVER_DIR" | tee -a /etc/environment
|
echo "CHROMEWEBDRIVER=$CHROMEDRIVER_DIR" | tee -a /etc/environment
|
||||||
|
|
||||||
# Download and unpack Chromium
|
# Download and unpack Chromium
|
||||||
# Get Chromium version corresponding to the Google Chrome version
|
CHROME_REVISION=$(echo "${CHROME_VERSIONS_JSON}" | jq -r '.builds["'"$CHROME_VERSION"'"].revision')
|
||||||
REVISION=$(GetChromiumRevision $FULL_CHROME_VERSION)
|
CHROMIUM_REVISION=$(GetChromiumRevision $CHROME_REVISION)
|
||||||
|
CHROMIUM_URL="https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Linux_x64%2F${CHROMIUM_REVISION}%2Fchrome-linux.zip?alt=media"
|
||||||
ZIP_URL="https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Linux_x64%2F${REVISION}%2Fchrome-linux.zip?alt=media"
|
CHROMIUM_ARCHIVE="${CHROMIUM_REVISION}-chromium-linux.zip"
|
||||||
ZIP_FILE="${REVISION}-chromium-linux.zip"
|
|
||||||
|
|
||||||
CHROMIUM_DIR="/usr/local/share/chromium"
|
CHROMIUM_DIR="/usr/local/share/chromium"
|
||||||
CHROMIUM_BIN="$CHROMIUM_DIR/chrome-linux/chrome"
|
CHROMIUM_BIN="${CHROMIUM_DIR}/chrome-linux/chrome"
|
||||||
|
|
||||||
# Download and unzip Chromium archive
|
echo "Installing chromium revision $CHROMIUM_REVISION"
|
||||||
download_with_retries $ZIP_URL "/tmp" $ZIP_FILE
|
download_with_retries $CHROMIUM_URL "/tmp" $CHROMIUM_ARCHIVE
|
||||||
mkdir $CHROMIUM_DIR
|
mkdir $CHROMIUM_DIR
|
||||||
unzip -qq /tmp/${ZIP_FILE} -d $CHROMIUM_DIR
|
unzip -qq /tmp/$CHROMIUM_ARCHIVE -d $CHROMIUM_DIR
|
||||||
|
|
||||||
ln -s $CHROMIUM_BIN /usr/bin/chromium
|
ln -s $CHROMIUM_BIN /usr/bin/chromium
|
||||||
ln -s $CHROMIUM_BIN /usr/bin/chromium-browser
|
ln -s $CHROMIUM_BIN /usr/bin/chromium-browser
|
||||||
|
|||||||
Reference in New Issue
Block a user