Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle circleci command being missing in chrome install #118

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

willzoltan
Copy link

@willzoltan willzoltan commented Dec 9, 2024

This allows usage of the Chrome install script in Dockerfiles where circleci is not installed. Note that none of the other install scripts reply on circleci. This was working until this PR last week

Example Dockerfile snippet:

FROM cimg/ruby:3.3.6-browsers
...
# Install Chrome tools
# Parameters taken from the source code of the ORB and https://circleci.com/developer/orbs/orb/circleci/browser-tools#commands-install-chromedriver
ENV ORB_PARAM_CHANNEL=stable
ENV ORB_PARAM_CHROME_VERSION=latest
ENV ORB_PARAM_REPLACE_EXISTING=false
RUN curl -sSL "https://raw.githubusercontent.com/CircleCI-Public/browser-tools-orb/main/src/scripts/install-chrome.sh" | bash

Without this change, line 5:

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

Fails with circleci: command not found and just sets PROCESSED_CHROME_VERSION to be empty

Before

#12 [ 7/11] RUN curl -sSL "https://raw.githubusercontent.com/CircleCI-Public/browser-tools-orb/main/src/scripts/install-chrome.sh" | bash
#12 0.070 + curl -sSL https://raw.githubusercontent.com/CircleCI-Public/browser-tools-orb/main/src/scripts/install-chrome.sh
#12 0.071 + bash
#12 0.271 bash: line 5: circleci: command not found
#12 0.278 Google Chrome is not currently installed; installing it
#12 0.283 Preparing Chrome installation for Debian-based systems
#12 0.398 Hit:1 https://download.docker.com/linux/ubuntu focal InRelease
#12 0.480 Hit:2 http://security.ubuntu.com/ubuntu focal-security InRelease
#12 0.520 Hit:3 http://archive.ubuntu.com/ubuntu focal InRelease
#12 0.600 Hit:4 http://archive.ubuntu.com/ubuntu focal-updates InRelease
#12 0.680 Hit:5 http://archive.ubuntu.com/ubuntu focal-backports InRelease
#12 0.877 Reading package lists...
#12 1.900 https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_latest-1_amd64.deb:
#12 1.900 2024-12-09 02:36:04 ERROR 404: Not Found.
#12 1.902 bash: line 157: -2: substring expression < 0
#12 1.903 bash: line 160: google-chrome-stable: command not found
#12 1.905 bash: line 162: google-chrome-stable: command not found
#12 1.907 Google Chrome v (stable) failed to install.

After

#12 [ 7/11] RUN curl -sSL "https://raw.githubusercontent.com/CircleCI-Public/browser-tools-orb/978e55bfbabc3e9e9368f08dcc2f0410f0c53916/src/scripts/install-chrome.sh" | bash
#12 0.070 + curl -sSL https://raw.githubusercontent.com/CircleCI-Public/browser-tools-orb/978e55bfbabc3e9e9368f08dcc2f0410f0c53916/src/scripts/install-chrome.sh
#12 0.071 + bash
#12 0.223 CircleCI CLI is not installed. Relying on the environment variable ORB_PARAM_CHROME_VERSION to be set manually.
#12 0.231 Google Chrome is not currently installed; installing it
#12 0.235 Preparing Chrome installation for Debian-based systems
#12 0.304 Warning: apt-key output should not be parsed (stdout is not a terminal)
#12 0.541 OK
#12 0.551 Installing Chrome for AMD64

Checklist

  • All new jobs, commands, executors, parameters have descriptions
  • Examples have been added for any significant new features
  • README has been updated, if necessary

Motivation, issues

Recent PR breaks our entire CircleCI pipeline

Description

  • add a case to the definition of PROCESSED_CHROME_VERSION env var when circleci is missing so that the ORB_PARAM_CHROME_VERSION env var is used. Use "latest" as backup

This allows usage of the script in Dockerfiles where circleci is not installed. Note that none of the other install scripts reply on circleci.

Example Dockerfile snippet:
```
# Install Chrome tools
# Parameters taken from the source code of the ORB and https://circleci.com/developer/orbs/orb/circleci/browser-tools#commands-install-chromedriver
ENV ORB_PARAM_CHANNEL=stable
ENV ORB_PARAM_CHROME_VERSION=latest
ENV ORB_PARAM_REPLACE_EXISTING=false
RUN curl -sSL "https://raw.githubusercontent.com/CircleCI-Public/browser-tools-orb/main/src/scripts/install-chrome.sh" | bash
```
@willzoltan willzoltan marked this pull request as ready for review December 9, 2024 11:21
@willzoltan willzoltan requested a review from a team as a code owner December 9, 2024 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant