From f13dca2caed91ab53867bd45b398bfcfa07eaa4a Mon Sep 17 00:00:00 2001 From: Howard Braham Date: Wed, 24 Jul 2024 17:49:41 -0400 Subject: [PATCH] ci: enable VNC over ssh --- .circleci/config.yml | 3 +++ .circleci/scripts/enable-vnc.sh | 21 +++++++++++++++++++++ docs/ssh-to-circleci.md | 28 ++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 .circleci/scripts/enable-vnc.sh create mode 100644 docs/ssh-to-circleci.md diff --git a/.circleci/config.yml b/.circleci/config.yml index ae81189b5626..a8a103e866dc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -88,6 +88,9 @@ aliases: git checkout -B "$CIRCLE_BRANCH" "$CIRCLE_SHA1" fi + # Piggyback on this alias to enable VNC connections + cp ~/project/.circleci/scripts/enable-vnc.sh ~/.bashrc + # Check if MMI Optional tests should run - &check-mmi-optional name: Check if MMI Optional tests should run diff --git a/.circleci/scripts/enable-vnc.sh b/.circleci/scripts/enable-vnc.sh new file mode 100644 index 000000000000..4c2205713d0c --- /dev/null +++ b/.circleci/scripts/enable-vnc.sh @@ -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 diff --git a/docs/ssh-to-circleci.md b/docs/ssh-to-circleci.md new file mode 100644 index 000000000000..cc906a6fb979 --- /dev/null +++ b/docs/ssh-to-circleci.md @@ -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 + 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_