Skip to content

Commit

Permalink
feat: processed chrome ver with env subst
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanbourdais committed Jun 26, 2023
1 parent 71f0ca3 commit ede2b99
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
14 changes: 8 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2.1
setup: true
orbs:
orb-tools: circleci/orb-tools@11.1
orb-tools: circleci/orb-tools@12.0.3
shellcheck: circleci/[email protected]

filters: &filters
Expand All @@ -16,21 +16,23 @@ workflows:
- orb-tools/pack:
filters: *filters
- orb-tools/review:
exclude: RC010
filters: *filters
- shellcheck/check:
exclude: SC2148,SC2038,SC2086,SC2002,SC2016
filters: *filters
- orb-tools/publish:
orb-name: circleci/browser-tools
vcs-type: << pipeline.project.type >>
orb_name: circleci/browser-tools
vcs_type: << pipeline.project.type >>
requires:
[orb-tools/lint, orb-tools/review, orb-tools/pack, shellcheck/check]
context: image-orbs
github-token: GHI_TOKEN
github_token: GHI_TOKEN
filters: *filters
# Triggers the next workflow in the Orb Development Kit.
- orb-tools/continue:
pipeline-number: << pipeline.number >>
vcs-type: << pipeline.project.type >>
orb_name: circleci/browser-tools
pipeline_number: << pipeline.number >>
vcs_type: << pipeline.project.type >>
requires: [orb-tools/publish]
filters: *filters
2 changes: 1 addition & 1 deletion .circleci/test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ workflows:
- int-test-all:
name: test-specific-version-all
executor: cimg-base
chrome-version: "92.0.4515.131"
chrome-version: "110.0.5481.177-1"
firefox-version: "90.0.1"
filters: *filters
- int-test-all:
Expand Down
25 changes: 16 additions & 9 deletions src/scripts/install-chrome.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash
if [[ $EUID == 0 ]]; then export SUDO=""; else export SUDO="sudo"; fi

# process ORB_PARAM_CHROME_VERSION
PROCESSED_CHROME_VERSION=$(circleci env subst "$ORB_PARAM_CHROME_VERSION")

# installation check
if uname -a | grep Darwin >/dev/null 2>&1; then
if ls /Applications/*Google\ Chrome* >/dev/null 2>&1; then
Expand Down Expand Up @@ -86,10 +90,10 @@ if uname -a | grep Darwin >/dev/null 2>&1; then
elif command -v yum >/dev/null 2>&1; then
echo "Preparing Chrome installation for RedHat-based systems"
# download chrome
if [[ "$ORB_PARAM_CHROME_VERSION" == "latest" ]]; then
if [[ "$PROCESSED_CHROME_VERSION" == "latest" ]]; then
CHROME_URL="https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm"
else
CHROME_URL="https://dl.google.com/linux/chrome/rpm/stable/x86_64/google-chrome-${ORB_PARAM_CHANNEL}-$ORB_PARAM_CHROME_VERSION-1.x86_64.rpm"
CHROME_URL="https://dl.google.com/linux/chrome/rpm/stable/x86_64/google-chrome-${ORB_PARAM_CHANNEL}-$PROCESSED_CHROME_VERSION-1.x86_64.rpm"
fi
curl --silent --show-error --location --fail --retry 3 \
--output google-chrome.rpm \
Expand All @@ -105,7 +109,7 @@ elif command -v yum >/dev/null 2>&1; then
else
# download chrome
echo "Preparing Chrome installation for Debian-based systems"
if [[ "$ORB_PARAM_CHROME_VERSION" == "latest" ]]; then
if [[ "$PROCESSED_CHROME_VERSION" == "latest" ]]; then
ENV_IS_ARM=$(! dpkg --print-architecture | grep -q arm; echo $?)
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | $SUDO apt-key add -
if [ "$ENV_IS_ARM" == "arm" ]; then
Expand All @@ -119,18 +123,21 @@ else
DEBIAN_FRONTEND=noninteractive $SUDO apt-get install -y google-chrome-${ORB_PARAM_CHANNEL}
else
# Google does not keep older releases in their PPA, but they can be installed manually. HTTPS should be enough to secure the download.
wget --no-verbose -O /tmp/chrome.deb "https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${ORB_PARAM_CHROME_VERSION}-1_amd64.deb" \
&& $SUDO apt-get install -y /tmp/chrome.deb \
wget --no-verbose -O /tmp/chrome.deb "https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${PROCESSED_CHROME_VERSION}_amd64.deb" \
&& $SUDO apt-get install -y apt-utils && $SUDO apt-get install -y /tmp/chrome.deb \
&& rm /tmp/chrome.deb
fi
fi

TESTING_CHROME_VERSION=${PROCESSED_CHROME_VERSION::-2}
# test/verify installation
if [[ "$ORB_PARAM_CHROME_VERSION" != "latest" ]]; then
if google-chrome-$ORB_PARAM_CHANNEL --version | grep "$ORB_PARAM_CHROME_VERSION" >/dev/null 2>&1; then
if [[ "$PROCESSED_CHROME_VERSION" != "latest" ]]; then
if google-chrome-$ORB_PARAM_CHANNEL --version | grep "$PROCESSED_CHROME_VERSION" >/dev/null 2>&1; then
:
elif google-chrome-$ORB_PARAM_CHANNEL --version | grep "$TESTING_CHROME_VERSION" >/dev/null 2>&1; then
:
else
echo "Google Chrome v${ORB_PARAM_CHROME_VERSION} (${ORB_PARAM_CHANNEL}) failed to install."
echo "Google Chrome v${PROCESSED_CHROME_VERSION} (${ORB_PARAM_CHANNEL}) failed to install."
exit 1
fi
else
Expand All @@ -141,5 +148,5 @@ else
exit 1
fi
echo "$(google-chrome-$ORB_PARAM_CHANNEL --version) has been installed to $(command -v google-chrome-$ORB_PARAM_CHANNEL)"
echo "Chrome: $ORB_PARAM_CHROME_VERSION" >>"${HOME}/.browser-versions"
echo "Chrome: $PROCESSED_CHROME_VERSION" >>"${HOME}/.browser-versions"
fi
1 change: 1 addition & 0 deletions src/scripts/install-chromedriver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ if [[ $CHROME_RELEASE -lt 70 ]]; then
;;
esac
else
echo $CHROMEDRIVER_RELEASE
CHROMEDRIVER_VERSION=$(curl --silent --show-error --location --fail --retry 3 \
"https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROMEDRIVER_RELEASE")
fi
Expand Down

0 comments on commit ede2b99

Please sign in to comment.