Cache chrome for correct debian version

This commit is contained in:
Andrejs Cunskis 2022-11-08 12:49:31 +00:00 committed by Balasankar 'Balu' C
parent 03d90d36f2
commit 7d00e776ae
7 changed files with 40 additions and 13 deletions

View file

@ -4,7 +4,7 @@
- docker
- high-cpu
variables:
QEMU_IMAGE: tonistiigi/binfmt:qemu-v6.2.0
QEMU_IMAGE: tonistiigi/binfmt:qemu-v7.0.0
before_script:
- |
if [ "$PUSH_CUSTOM_IMAGE" == "true" ]; then
@ -43,6 +43,11 @@
needs: []
variables:
ARCH: linux/amd64,linux/arm64
parallel:
matrix:
- BUILD_OS: debian
OS_VERSION: bullseye
NOTIFY_VERSION_UPDATE: "true"
before_script:
- !reference [.install-qemu, before_script]
script:
@ -52,6 +57,8 @@
--build-arg CI_PROJECT_ID=$CI_PROJECT_ID \
--build-arg CI_JOB_TOKEN=$CI_JOB_TOKEN \
--build-arg CI_SLACK_WEBHOOK_URL=$CI_SLACK_WEBHOOK_URL \
--build-arg BUILD_OS=$BUILD_OS \
--build-arg OS_VERSION=$OS_VERSION \
--platform $ARCH \
-f "Dockerfile.cache-chrome" \
.

View file

@ -22,8 +22,10 @@ e2e-docker:
e2e-chrome:
extends:
- e2e-docker
variables:
CHROME: '107'
parallel:
matrix:
- RUBY: ['2.7', '3.0']
CHROME: ['106', '107']
# Image used for running full e2e test suite
e2e-full:

View file

@ -1,7 +1,12 @@
# Save amd64 chrome and arm64 .deb files to package registry
FROM debian:latest
ARG BUILD_OS=debian
ARG OS_VERSION=bullseye
FROM ${BUILD_OS}:${OS_VERSION}
ARG TARGETARCH
ARG BUILD_OS
ARG OS_VERSION
ARG CI_API_V4_URL
ARG CI_PROJECT_ID
ARG CI_JOB_TOKEN

View file

@ -7,6 +7,7 @@ ARG CUSTOM_BASE_IMAGE
FROM ${CUSTOM_BASE_IMAGE}
ARG BUILD_OS
ARG OS_VERSION
# TARGETARCH is automatically populated by buildx --platform argument
ARG TARGETARCH
@ -35,7 +36,7 @@ RUN if [ -n "$GIT_VERSION" ]; then /scripts/install-git && git --version; fi
# Chrome
ARG CHROME_VERSION
RUN if [ -n "$CHROME_VERSION" ]; then /scripts/install-chrome "$CHROME_VERSION" && ( google-chrome --version || chromium --version ); fi
RUN if [ -n "$CHROME_VERSION" ]; then /scripts/install-chrome "$CHROME_VERSION"; fi
# NodeJS and Yarn
ARG NODE_INSTALL_VERSION

View file

@ -15,7 +15,7 @@ function save-package() {
local REGISTRY_PACKAGE=${4:-$PKG}
local SOURCE_DEB=${5:-$DEB}
local URL="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${REGISTRY_PACKAGE}/${LATEST_VERSION}/${DEB}"
local URL="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${BUILD_OS}-${OS_VERSION}-${REGISTRY_PACKAGE}/${LATEST_VERSION}/${DEB}"
echo "Checking if ${PKG} v${LATEST_VERSION} is already cached"
local FILE_CHECK=$(curl --silent --location --head --output /dev/null --write "%{http_code}\\n" "$URL")
@ -81,6 +81,7 @@ function cache-chromium() {
function notify-chrome-updated() {
[ ! -f chrome-version ] && exit
[ -z "$CI_SLACK_WEBHOOK_URL" ] && exit
local chrome_version=$(cat chrome-version)
local msg="New version of chrome has been released: \`${chrome_version}\`!\n"
@ -103,5 +104,5 @@ if [ "$TARGETARCH" == "amd64" ]; then
cache-chromium
else
cache-chromium
notify-chrome-updated
[ "$NOTIFY_VERSION_UPDATE" == "true" ] && notify-chrome-updated || exit 0
fi

View file

@ -48,18 +48,26 @@ function build_debian() {
rm -rf /etc/apt/sources.list.d/google*.list
}
function build_ubi() {
echo "This OS is not supported for chrome install!"
exit 1
}
BUILD_OS=${BUILD_OS:-debian}
OS_VERSION=${OS_VERSION:-bullseye}
CHROME_VERSION=${1:-107.0.5304.87-1}
ARCH=${TARGETARCH:-amd64}
if [ "${ARCH}" == "amd64" ]; then
PKG=google-chrome-stable
else
PKG=chromium
fi
DOWNLOAD_URL_BASE="https://gitlab.com/api/v4/projects/1075790/packages/generic/${PKG}"
PKG=$([ "${ARCH}" == "amd64" ] && echo "google-chrome-stable" || echo "chromium")
DOWNLOAD_URL_BASE="https://gitlab.com/api/v4/projects/1075790/packages/generic/${BUILD_OS}-${OS_VERSION}-${PKG}"
if [[ $BUILD_OS =~ debian ]]; then
build_debian "$@"
elif [[ $BUILD_OS =~ ubi ]]; then
build_ubi "$@"
fi
if [ "${ARCH}" == "amd64" ]; then
google-chrome --version
else
chromium --version
fi

View file

@ -18,11 +18,13 @@ function print_image_args() {
debian:*)
CUSTOM_BASE_IMAGE="$1:$2"
BUILD_OS=debian
OS_VERSION=$2
;;
ubi:8.*)
CUSTOM_BASE_IMAGE="registry.access.redhat.com/ubi8/ubi:$2"
BUILD_OS=ubi
OS_VERSION=$2
;;
*) fail "Unknown image version $1:$2" ;;
@ -30,6 +32,7 @@ function print_image_args() {
printf -- "--build-arg CUSTOM_BASE_IMAGE=%s " "$CUSTOM_BASE_IMAGE"
printf -- "--build-arg BUILD_OS=%s " "$BUILD_OS"
printf -- "--build-arg OS_VERSION=%s " "$OS_VERSION"
}
function print_golang_args() {