Skip to content

Commit

Permalink
ci: enable VNC over ssh
Browse files Browse the repository at this point in the history
  • Loading branch information
HowardBraham committed Jul 24, 2024
1 parent 83e4b2a commit 690fbc5
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ aliases:
git checkout -B "$CIRCLE_BRANCH" "$CIRCLE_SHA1"
fi
# Piggyback on this alias to enable VNC connections
# The if statement will only be true on node-browsers executors
if [ "${SHELL}" != "/bin/bash" ]; then
cp ~/project/.circleci/scripts/enable-vnc.sh ~/.bashrc
fi
# Check if MMI Optional tests should run
- &check-mmi-optional
name: Check if MMI Optional tests should run
Expand Down
21 changes: 21 additions & 0 deletions .circleci/scripts/enable-vnc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

# This script is based on the documentation from CircleCI, which does not work as written
# https://circleci.com/docs/browser-testing/#interacting-with-the-browser-over-vnc

set -e
set -u
set -o pipefail

cd ~/project

if [ ! -f installed.lock ]; then
touch installed.lock

sudo apt update
sudo apt install -y fluxbox tigervnc-standalone-server

export DISPLAY=:1
tigervncserver -SecurityTypes none -desktop fluxbox
fbsetbg -c app/images/icon-512.png
fi
28 changes: 28 additions & 0 deletions docs/ssh-to-circleci.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Debugging E2E tests by connecting to CircleCI over SSH and VNC

Developers often say "I can't reproduce this CI failure locally, but it fails on CircleCI."

If you find yourself in that situation, one option is to use Codespaces, which can reproduce some of these failures, and is a little bit easier to use.

The other NEW option is to SSH into CircleCI and use VNC.

1. You must be logged into CircleCI and have access to metamask-extension
2. "Rerun job with SSH" [Documentation](https://circleci.com/docs/ssh-access-jobs/)
3. Look for this instruction

```
You can now SSH into this box if your SSH public key is added:
$ ssh -p xxxxx xxx.xxx.xxx.xxx
```

4. Copy the command that CircleCI gives you and add `-L 5902:localhost:5901` (this will tunnel the VNC connection over SSH)
5. When you login to SSH, it automatically executes `/.circleci/scripts/enable-vnc.sh` to set up the connection
6. Use your favorite VNC viewer on your local machine to connect to `localhost:5902`
- Mac: Finder menu > GO > Connect to server (or <Cmd> + K), then use `vnc://localhost:5902`
- Linux: `tigervnc-viewer` is a good package to match the server
- Windows: [RealVNC Viewer](https://www.realvnc.com/en/connect/download/viewer/windows/) or [TightVNC](https://www.tightvnc.com/download.php)
7. Run your E2E tests as usual and watch the browser open in VNC

_Warning: be careful with parallelism. If you run "Rerun job with SSH" on a job that has `parallelism: 24`, it will rerun all 24 VMs with SSH._

_Note: this procedure was based on the documentation from CircleCI, which does not work as written https://circleci.com/docs/browser-testing/#interacting-with-the-browser-over-vnc_

0 comments on commit 690fbc5

Please sign in to comment.