Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: E2E Tests

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
e2e:
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- uses: actions/checkout@v4

# We use actions/setup-node just to have npm available to run the test script wrapper.
# The actual e2e test runs inside the Docker container.
- name: Use Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 22.x

- name: Enable KVM group perms
# This enables hardware acceleration for the Android emulator inside the Docker container
# since Docker on Linux can pass through /dev/kvm
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm

- name: Run E2E tests (Docker)
run: npm run test:e2e:docker
# We need to make sure the docker container can access /dev/kvm if we want hardware acceleration,
# but by default the `test-e2e-docker.sh` might not pass `--device /dev/kvm`...
# Let's check test-e2e-docker.sh again.
3 changes: 2 additions & 1 deletion docker/e2e/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:20-bookworm
FROM --platform=linux/amd64 node:20-bookworm

ENV DEBIAN_FRONTEND=noninteractive
ENV ANDROID_SDK_ROOT=/opt/android-sdk
Expand Down Expand Up @@ -55,6 +55,7 @@ RUN npm ci

COPY src ./src
COPY test ./test
COPY docs ./docs
COPY openpocket ./openpocket
COPY openpocket.config.example.json ./openpocket.config.example.json
COPY README.md ./README.md
Expand Down
9 changes: 7 additions & 2 deletions scripts/test-e2e-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ echo "[e2e] Building Docker image: ${IMAGE_TAG}"
docker build -f docker/e2e/Dockerfile -t "${IMAGE_TAG}" .

echo "[e2e] Running Docker container"
docker run --rm \
--shm-size="${SHM_SIZE}" \
DOCKER_RUN_ARGS=(--rm --shm-size="${SHM_SIZE}")
if [ -e /dev/kvm ]; then
echo "[e2e] Hardware virtualization (/dev/kvm) detected. Enabling KVM."
DOCKER_RUN_ARGS+=(--device /dev/kvm)
fi

docker run "${DOCKER_RUN_ARGS[@]}" \
-e OPENPOCKET_E2E_TASK="${OPENPOCKET_E2E_TASK:-Open Android Settings, then return to the home screen, then finish.}" \
"${IMAGE_TAG}"
Loading