-
Notifications
You must be signed in to change notification settings - Fork 34
Enable Cypress Testing in devcontainer #1649
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
Changes from 7 commits
f9bca53
39b264b
d8dabcd
0ac2237
e2ccac4
fe83adb
afd78fd
2c0cf10
56ddc0a
3fef1bf
0ea7534
0b556be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "id": "chrome", | ||
| "version": "1.0.0", | ||
| "name": "Google Chrome", | ||
| "description": "Installs Google Chrome Stable and supporting dependencies for Cypress browser testing.", | ||
| "installsAfter": ["ghcr.io/devcontainers/features/common-utils"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| export DEBIAN_FRONTEND=noninteractive | ||
|
|
||
| apt-get update | ||
|
|
||
| apt-get install -y \ | ||
| wget \ | ||
| gnupg \ | ||
| ca-certificates | ||
|
|
||
| mkdir -p /etc/apt/keyrings | ||
|
|
||
| wget -qO- https://dl.google.com/linux/linux_signing_key.pub \ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we don't need keys, can we remove these lines?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After digging into this further, I noticed we're already installing a Playwright-managed Chromium browser as part of the Python feature: PLAYWRIGHT_BROWSERS_PATH=/opt/playwright-browsers playwright install chromiumand I was able to verify that Cypress can successfully run against that Chromium binary directly. Given that, I'm going to spend some time tomorrow exploring a Chromium-based implementation that reuses the existing Playwright installation instead of adding a separate system Chrome install. There are still some challenges to work through:
For the current implementation, however, the PGP key setup is still required. The key is necessary for APT to trust Google's repository and perform the initial installation: apt-get update
apt-get install -y --no-install-recommends google-chrome-stableWithout the key, that installation path would fail signature verification and Chrome would not install successfully. So if we keep the current APT-based approach, the keyring configuration needs to stay. If we move entirely to the Playwright-managed Chromium approach, we could remove the Google repository and associated keys altogether. However, I expect that solution to be more fragile in the long term because it will require bridging Cypress' browser discovery and execution model with Playwright's browser installation and version-management model, introducing additional coordination, maintenance, and potential failure modes compared to a traditional system-installed browser. That said, I still don't fully understand the objections to the system-browser approach. I would be perfectly happy to make that installation Chromium instead of Chrome if there were a reliable way to do so in this environment. Unfortunately, on Linux ARM64, the options we've explored so far have either been unavailable, Snap-based, unmaintained, or otherwise problematic. Given those constraints, I still lean toward a stable system-installed browser. It keeps browser management at the operating-system level, aligns with how Cypress expects to discover and launch browsers, uses the same browser as GitHub Actions CI testing, and avoids introducing an implicit dependency between Cypress and Playwright-managed browser assets. I'll evaluate the Playwright Chromium approach tomorrow since it's already present and appears functional, but at the moment I view it as a workaround worth investigating in response to the concerns raised about the system-level install rather than a clearly cleaner or more maintainable solution than a conventional system-installed browser.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you running on a mac? I thought the dev container was set up as an x86 container.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @siefkenj Yes, I am running on Mac. I could force the x86 build through emulation, but it would be much slower. |
||
| | gpg --dearmor \ | ||
| > /etc/apt/keyrings/google-chrome.gpg | ||
|
|
||
| echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/google-chrome.gpg] https://dl.google.com/linux/chrome/deb/ stable main" \ | ||
| > /etc/apt/sources.list.d/google-chrome.list | ||
|
|
||
| apt-get update | ||
|
|
||
| apt-get install -y google-chrome-stable | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's change this to a chromium install. It's best to stay away from any "features" that chrome adds.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @siefkenj I tried the Ubuntu The previous Google Chrome feature worked correctly and allowed the existing Cypress workflows to run after addressing the DISPLAY issue. It also aligns with what the GitHub Actions CI jobs are currently using, since the Cypress diagnostics reported If Chromium is preferred, we'll likely need a different installation mechanism, such as a Playwright-managed Chromium install or another non-Snap Chromium distribution. Which direction would you like me to take? |
||
|
|
||
| google-chrome --version | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| export DEBIAN_FRONTEND=noninteractive | ||
|
|
||
| apt-get update | ||
| apt-get install -y --no-install-recommends \ | ||
| wget \ | ||
| unzip \ | ||
| ca-certificates | ||
|
|
||
| mkdir -p /opt/chrome-for-testing | ||
|
|
||
| ARCH=$(dpkg --print-architecture) | ||
|
|
||
| case "$ARCH" in | ||
| amd64) | ||
| PLATFORM="linux64" | ||
| ;; | ||
| arm64) | ||
| PLATFORM="linux-arm64" | ||
| ;; | ||
| *) | ||
| echo "Unsupported architecture: $ARCH" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
|
|
||
| URL="https://storage.googleapis.com/chrome-for-testing-public/LATEST_RELEASE_${PLATFORM}" | ||
|
|
||
| VERSION=$(wget -qO- "$URL") | ||
|
|
||
| wget -q \ | ||
| "https://storage.googleapis.com/chrome-for-testing-public/${VERSION}/${PLATFORM}/chrome-${PLATFORM}.zip" \ | ||
| -O /tmp/chrome.zip | ||
|
|
||
| unzip -q /tmp/chrome.zip -d /opt/chrome-for-testing | ||
|
|
||
| CHROME_BIN=$(find /opt/chrome-for-testing -type f -name chrome | head -n1) | ||
|
|
||
| ln -sf "${CHROME_BIN}" /usr/local/bin/google-chrome | ||
| ln -sf "${CHROME_BIN}" /usr/local/bin/google-chrome-stable | ||
|
|
||
| "${CHROME_BIN}" --version | ||
|
|
||
| rm -f /tmp/chrome.zip | ||
| rm -rf /var/lib/apt/lists/* |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "id": "chromium", | ||
| "version": "1.0.0", | ||
| "name": "Chromium", | ||
| "description": "Installs Chromium and supporting dependencies for Cypress browser testing.", | ||
| "installsAfter": ["ghcr.io/devcontainers/features/common-utils"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| export DEBIAN_FRONTEND=noninteractive | ||
|
|
||
| apt-get update | ||
| apt-get install -y --no-install-recommends \ | ||
| chromium-browser | ||
|
|
||
| # On Ubuntu, the `chromium-browser` package in the APT repositories is | ||
| # typically just a transitional package that redirects installation to | ||
| # the Snap version of Chromium. It does not install a standalone Chromium | ||
| # binary from APT, which can be problematic in containers and other | ||
| # environments where Snap is unavailable or unsupported. | ||
|
|
||
| # Cypress CI scripts currently use: | ||
| # cypress run -b chrome | ||
| # | ||
| # Provide Chrome-compatible executable names backed by Chromium so | ||
| # existing scripts continue to work. | ||
|
|
||
| ln -sf /usr/bin/chromium-browser /usr/local/bin/google-chrome | ||
| ln -sf /usr/bin/chromium-browser /usr/local/bin/google-chrome-stable | ||
|
|
||
| google-chrome --version | ||
|
|
||
| rm -rf /var/lib/apt/lists/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename this
chromium