Files
romm/.github/workflows/e2e.yml
Georges-Antoine Assi 2e90022dea fix(db): make virtual_collections and generated columns collation-agnostic
A MariaDB server configured with --character-set-server=utf8 makes the roms
table, string literals and JSON_TABLE columns utf8mb3, which breaks three
places that a default utf8mb4 server accepts:

- 0096/0101 pin `COLLATE utf8mb4_general_ci` on view output columns. An
  explicit utf8mb4 collation on a utf8mb3 value is rejected outright, so
  upgrading fails with "COLLATION 'utf8mb4_general_ci' is not valid for
  CHARACTER SET 'utf8mb3'". Each operand now goes through CONVERT(... USING
  utf8mb4) first, keeping the strong coercibility that 3758 needed.
- 0098 compares JSON_UNQUOTE output against string literals in NOT IN, REGEXP
  and NULLIF. JSON_UNQUOTE resolves under the connection charset while a
  literal in a generated-column expression takes the table's collation, so the
  two are an illegal mix. All of them now route through _maria_text, which
  wraps the value in CAST(... AS CHAR).

CI only ever exercised the default collation, so none of this was visible. The
migrations workflow now runs MariaDB as a matrix over utf8mb4_general_ci and
utf8mb3_unicode_ci. Service containers take docker create options and cannot
pass --character-set-server, so the server is started from a step instead.

MariaDB moves to 11.3.2 everywhere in CI, matching docker-compose. That image
dropped the mysqladmin symlink, so the service health checks move to the
image's own healthcheck.sh.

Verified on mariadb:11.3.2: alembic upgrade head reaches head under both
collations, and the generated_* columns and virtual_collections rows are
identical between them.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-06 08:46:38 -04:00

159 lines
5.0 KiB
YAML

name: Run E2E Tests
on:
pull_request:
paths:
- "frontend/**"
- "backend/**"
- ".github/workflows/e2e.yml"
- ".github/scripts/**"
- pyproject.toml
- uv.lock
- .python-version
push:
branches:
- "master"
paths:
- "frontend/**"
- "backend/**"
- ".github/workflows/e2e.yml"
- ".github/scripts/**"
- pyproject.toml
- uv.lock
- .python-version
permissions: read-all
jobs:
e2e:
runs-on: ubuntu-latest
services:
mariadb:
image: mariadb:11.3.2
ports:
- 3306
env:
MYSQL_USER: romm_e2e
MYSQL_PASSWORD: passwd
MYSQL_DATABASE: romm_e2e
MYSQL_ROOT_PASSWORD: passwd
options: --health-cmd="healthcheck.sh --connect --innodb_initialized" --health-interval=5s --health-timeout=2s --health-retries=3
valkey:
image: valkey/valkey:7.2
ports:
- 6379
options: >-
--health-cmd="redis-cli ping" --health-interval=5s --health-timeout=2s --health-retries=3
env:
DEV_PORT: 5000
DB_HOST: 127.0.0.1
DB_NAME: romm_e2e
DB_USER: romm_e2e
DB_PASSWD: passwd
ROMM_DB_DRIVER: mariadb
REDIS_HOST: 127.0.0.1
# Throwaway signing key for an ephemeral runner
ROMM_AUTH_SECRET_KEY: "e2e0000000000000000000000000000000000000000000000000000000000000"
# Fixture-user password, shared by the seeder and the specs
E2E_PASSWORD: e2e-Passw0rd!
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install mariadb connectors
run: |
sudo apt-get update
sudo apt-get install -y libmariadb3 libmariadb-dev
- name: Install uv
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
- name: Install python
run: uv python install
# pyproject.toml lives at the repo root, so sync from there
- name: Install backend dependencies
run: uv sync
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version-file: frontend/.nvmrc
cache: "npm"
cache-dependency-path: frontend/package-lock.json
- name: Install frontend dependencies
run: npm ci
working-directory: frontend
- name: Install Playwright browser
run: npx playwright install --with-deps chromium
working-directory: frontend
# ROMM_BASE_PATH must be writable (the app creates config/, resources/ and
# assets/ under it), so copy the fixture library out of the repo rather
# than scanning it in place.
- name: Stage the library fixture
run: |
mkdir -p "$RUNNER_TEMP/romm/resources" "$RUNNER_TEMP/romm/assets"
cp -R backend/romm_test/library "$RUNNER_TEMP/romm/library"
echo "ROMM_BASE_PATH=$RUNNER_TEMP/romm" >> "$GITHUB_ENV"
echo "DB_PORT=${{ job.services.mariadb.ports['3306'] }}" >> "$GITHUB_ENV"
echo "REDIS_PORT=${{ job.services.valkey.ports['6379'] }}" >> "$GITHUB_ENV"
# A migration failure is its own red step rather than a confusing server-start failure.
- name: Apply migrations
run: uv run alembic upgrade head
working-directory: backend
- name: Seed the library
run: uv run python .github/scripts/seed_e2e_library.py
# Seed user and clear the setup wizard
- name: Seed the e2e fixture users
run: uv run python .github/scripts/seed_e2e_users.py
- name: Start the backend
run: |
uv run main.py > "$RUNNER_TEMP/backend.log" 2>&1 &
echo "Waiting for the API to answer..."
for i in $(seq 1 60); do
if curl -sf "http://127.0.0.1:${DEV_PORT}/api/heartbeat" > /dev/null; then
echo "Backend up after ${i}s"
exit 0
fi
sleep 1
done
echo "Backend did not come up; last 100 log lines:"
tail -100 "$RUNNER_TEMP/backend.log"
exit 1
working-directory: backend
# Starts the Vite dev server and waits for port 3000.
- name: Run Playwright tests
run: npm run test:e2e
working-directory: frontend
- name: Upload Playwright report
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: playwright-report
path: |
frontend/playwright-report/
frontend/test-results/
retention-days: 7
- name: Dump backend log
if: failure()
run: tail -200 "$RUNNER_TEMP/backend.log" || true
# `uv run` holds the uv cache lock for as long as it lives, so leaving the
# backend up makes setup-uv's post-job `uv cache prune` block until the
# runner kills cleanup after 5 minutes, failing an otherwise green job.
- name: Stop the backend
if: always()
run: pkill -f "main.py" || true