Commit Graph

131 Commits

Author SHA1 Message Date
Georges-Antoine Assi
892657465f fix: stage the config fixture for e2e and address review findings
The e2e job copied only the fixture library, not the config.yml declaring its
platform-folder-first layout, so the seeder scanned an empty library.

Reject `.` and `..` template sections: no directory listing yields either, so a
template carrying one discovered nothing and marked the platform's roms missing.

Drop the cached `full_path` when either half is set. A scan reads it and then
renames the file in place, which left the cached pair stale.

Point `build_physical_fs_name` at the index 0126 actually creates.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-08 09:11:16 -04:00
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
Zurdi
473526fc47 Merge pull request #4357 from sdornan/fix/zip-undecodable-compression-7zz
fix(hashing): read zips zipfile can't decode through 7zz
2026-09-06 13:52:16 +02:00
Georges-Antoine Assi
4a246a9c22 ci: set up Python through uv everywhere
i18n.yml was the only workflow reaching for actions/setup-python; the
other five use uv. Both locale checks are stdlib-only, so run them with
`uv run --no-project` rather than resolving the backend project.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-05 21:54:39 -04:00
Georges-Antoine Assi
a3aecdf045 chore(python): restore the C accelerators lost on 3.14
The runtime moved to 3.14 but the pinned versions did not, so packages
without cp314 wheels silently resolved to their pure-Python universal
wheels. Bump each to the first release that ships cp314 wheels, all
within the existing pyproject specs:

- SQLAlchemy 2.0.41 -> 2.0.52 (cyextension, and greenlet is back so
  sqlalchemy.ext.asyncio is functional rather than merely importable)
- multidict, propcache, frozenlist (aiohttp/yarl accelerators)
- wrapt 1.17.2 -> 1.17.3 (OpenTelemetry instrumentation proxies)
- coverage 7.9.2 -> 7.16.0 (CTracer, and CI runs the suite under --cov)
- mysql-connector-python 9.3.0 -> 9.7.0 (C extension protocol)
- debugpy 1.8.14 -> 1.8.21 (pydevd accelerators)
- pyinstrument 5.0.3 -> 5.1.3 (no longer compiled from sdist on every
  `uv sync --all-extras`, which broke the no-toolchain dev setup)
- anyio 4.9.0 -> 4.14.2, dropping a PEP 765 SyntaxWarning printed on
  every process start

Run pytest and the migrations workflow when the runtime or the lock
changes: nothing in the 3.14 bump lives under `backend/`, so neither
workflow triggered on it. `e2e.yml` already listed those paths.

Make `.python-version` the single home for the version: `uv python
install` and `actions/setup-python` both read it. In the dev Dockerfile
that also fixes the interpreter layer not being invalidated when the pin
changes, and the sigil install now derives site-packages from the venv.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-05 21:48:52 -04:00
Sam Dornan
3c547dfbd0 chore(python): move the backend to Python 3.14
Bumps the runtime everywhere it is pinned: requires-python, the
.python-version uv reads, both Dockerfiles (with the python:3.14-alpine3.23
and uv 3.14 image digests), the six workflows that install Python, and the
contributor docs.

Several locked C-extension versions had no cp314 wheels, so the Alpine
image fell back to building them from source and failed on the missing
C++ and Rust toolchains. Those packages are upgraded within their existing
pyproject ranges: pydantic 2.11.7 -> 2.13.5 (pydantic-core 2.46.5), uvloop
0.22.1, grpcio 1.83.1, httptools 0.8.0, inflate64 1.0.4, markupsafe 3.0.3,
pyyaml 6.0.3 and streaming-form-data 1.20.0. The lockfile also drops the
3.13-only resolution branches.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-05 08:57:10 -05:00
Sam Dornan
13f8095f0a test(hashing): cover the 7zz fallback with a real PPMd zip
The unit tests stamp PPMd onto a stored zip and mock 7zz, which proves the
dispatch but not that 7zz can read such an archive. This adds an
integration test that has 7zz write a genuine PPMd zip next to a stored
.cue, checks zipfile refuses it, and compares the member hashes the reader
yields against hashes of the source files. CI installs 7zip so the test
runs there; it skips where 7zz is absent.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-05 08:49:40 -05:00
Sam Dornan
2539520de4 Bump GitHub Actions to Node 24 runtimes
GitHub is deprecating the Node 20 action runtime. Every third-party action
in the workflows was still pinned to a Node 20 release, so each is moved to
its latest release, all of which declare `runs.using: node24`:

- actions/checkout v4.3.x -> v7.0.1
- astral-sh/setup-uv v6.7.0 -> v10.0.1
- docker/login-action v3.5.0 -> v4.6.0
- docker/metadata-action v5.8.0 -> v6.2.0
- docker/build-push-action v6.18.0 -> v7.3.0
- docker/setup-qemu-action v3.6.0 -> v4.3.0
- docker/setup-buildx-action v3.11.1 -> v4.3.0
- actions/github-script v7.1.0 -> v9.0.0
- actions/upload-artifact v4.6.2 -> v7.0.1
- peter-evans/create-pull-request v7.0.11 -> v8.1.1
- trunk-io/trunk-action v1.2.4 -> v2.0.0 (its nested actions were on Node 20)

actions/setup-node and actions/setup-python were already on Node 24 but are
bumped to v7.0.0 as well, and the setup-node reference in the trunk
setup-ci composite action is now SHA-pinned like the rest.

None of the removed inputs, deprecated envs, or event-specific behavior
changes in the crossed major versions are used by these workflows.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-03 21:45:49 -05:00
Georges-Antoine Assi
2a7953ed58 refactor: share the HLTB search wire contract with endpoint discovery
The discovery script imported build_search_payload from hltb_handler, which
pulls in handler/metadata/__init__ and so instantiates every metadata handler,
opens Redis and writes a config file at import time. That import side effect is
why the workflow needed a dummy ROMM_BASE_PATH.

The script also hand-forked the rest of the protocol (base headers, the /init
mint, the session headers and the honeypot body merge), so it validated a
candidate route against a copy of what the handler sends rather than against
the real thing.

Move the contract into utils/hltb_search.py, a leaf module both sides import,
and drop ROMM_BASE_PATH from CI.

Pace failed session mints too: _ensure_session retried on every lookup, so a
down or IP-blocking HLTB cost each ROM in a scan its own rate-limited /init
round trip.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-29 08:31:14 -04:00
Georges-Antoine Assi
eb22ce3ca5 ci: silence the checkov secret false positive on the HLTB workflow
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-29 08:09:06 -04:00
Sam Dornan
d2fafaa089 fix: validate the search contract during HLTB endpoint discovery
Minting a session only proved a candidate route was session-backed, not that it
answers the search the handler sends. A future session-minting route sorting
ahead of the game-search route would have been published on that evidence alone,
leaving installs without completion metadata until the fixture was corrected.

Discovery now completes the real exchange: it mints a session, POSTs a search
with it, and requires the HLTB game shape that search_games() reads back. The
payload is no longer duplicated for the check, it moves to build_search_payload()
so the handler and discovery send the same body.

Also fixes the workflow being unable to run this script at all. It imports the
backend config, which raises unless ROMM_AUTH_SECRET_KEY is set, and the workflow
set no environment, so every run (including the manual dispatches) died at import
before reaching any HLTB logic. That is why the fixture drifted from May despite
the workflow existing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-26 14:35:13 -05:00
Sam Dornan
d975aa8bc3 fix: restore HowLongToBeat lookups and repair endpoint discovery
HLTB lookups have returned nothing since HLTB rotated their search endpoint.
The published fixture still pointed at /api/bleed, which now 404s on both GET
and POST, and the handler fetches that fixture from master at every startup, so
every install was affected regardless of image version. The live endpoint is
/api/search/site, with the session mint at /api/search/site/init, which the
handler already derives as f"{search_url}/init".

The automation meant to keep the fixture current could not have fixed this on
its own. It only ran on workflow_dispatch, so it never ran unprompted, and HLTB
has since migrated to Turbopack: the homepage no longer serves a pages-router
_app chunk, so both app-chunk regexes matched nothing. The endpoint is also a
plain literal in the bundle now rather than the .concat() obfuscation the token
regex expected.

Discovery now reads _buildManifest.js, where Next.js lists every route as a
plain literal, and selects the route that has an /init sibling, the same pairing
HLTBHandler assumes. That rule uniquely picks /api/search/site out of the 90 API
routes in the manifest, and rejects near misses such as /api/forum/search. Each
candidate then has to mint a real session before the fixture is written, so a
dead URL cannot be published again.

A failed startup was also permanent and silent: _request() returned early
whenever there was no session and nothing re-minted one, so a container that
lost the mint at boot served no HLTB metadata for its whole lifetime with no
error after the startup warning. Failures are now logged, and lookups mint
lazily behind a lock so a scan's concurrent lookups do not each hit /init.

Fixes #4285

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-26 14:19:31 -05:00
Georges-Antoine Assi
7562195fc6 ci(e2e): stop the backend before post-job cleanup
setup-uv prunes the uv cache in its post-job hook whenever the cache key
misses, which happens on any change to uv.lock or pyproject.toml. The
backend is started with `uv run main.py` and left running, and `uv run`
holds the uv cache lock for its whole lifetime, so the prune blocks until
the runner kills cleanup at the 5 minute cap and the job fails with
`uv failed with exit code 2` despite every test passing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-04 19:06:46 -04:00
Georges-Antoine Assi
474ef5b6e8 Move the e2e seed scripts to .github/scripts
They exist to stand up a disposable instance for the Playwright suite, so
they belong with the workflow that runs them rather than in backend/tools/
next to the library-generation utilities.

Their sys.path bootstrap now points at backend/ explicitly (it relied on
being one level below it), the workflow invokes them from the repo root
instead of backend/, and .github/scripts/** joins the workflow's path
filters so editing a seeder still triggers the suite.
2026-07-26 13:05:54 -04:00
Georges-Antoine Assi
395fe93912 cleanup 2026-07-26 12:56:16 -04:00
Georges-Antoine Assi
65425c1476 Run the e2e suite in CI
Adds .github/workflows/e2e.yml: MariaDB + Valkey services, migrations, an
offline library scan, the fixture users, the backend, then Playwright --
whose webServer starts the Vite dev server. DEV_PORT (5000) is both what
main.py binds and what Vite's /api proxy targets, so neither side needs
configuring. Report and test-results upload as an artifact on failure.

`tools/seed_e2e_library.py` scans backend/romm_test/library with an empty
metadata_sources list, so CI never reaches out to a provider. It exits
non-zero on an empty library rather than leaving a confusing Playwright
timeout later.

Also fixes the flakiness that a CI-shaped rehearsal exposed. Root cause was
not slowness: the Vite dev server force-reloads the page when it discovers a
new dependency to pre-bundle, wiping the half-filled login form so the submit
never lands. Defences are a passive warm-up pass in global-setup.ts (absorb
the reload before anything depends on the page, then compile the routes under
test) and a retry in login(). Two smaller real bugs fell out of the same
investigation: `button[type="submit"]` matched two elements, because the
collapsed reset-password form has its own, and the warm-up's best-effort
`.catch()` calls inherited a 120s timeout, making setup take 8 minutes.

Verified from a cold Vite cache against a throwaway database and the fixture
library: 15/15 pass, no flakes, 2.7 minutes.
2026-07-26 10:29:51 -04:00
Georges-Antoine Assi
de63580fcf trunk fmt everything 2026-07-19 20:35:51 -04:00
Georges-Antoine Assi
27692ae212 chore(i18n): add linter enforcing alphabetically sorted locale files
Add check_i18n_sorted.py, which fails when any locale JSON file's keys
are not sorted alphabetically (recursively, so nested objects are
covered). Supports --fix to sort in place. Wire it into the i18n CI
workflow alongside the existing parity check, and sort all existing
locale files.

Generated-By: PostHog Code
Task-Id: 7cbf74de-6bf1-45c0-9c8e-c45f94119edc
2026-07-15 22:07:35 -04:00
Georges-Antoine Assi
355ee14352 feat: inject ScreenScraper dev credentials at build time
Remove the hardcoded (base64-obfuscated) ScreenScraper developer
credentials from the source tree and read them from the
SCREENSCRAPER_DEV_ID / SCREENSCRAPER_DEV_PASSWORD environment variables
instead.

The official images bake the values in at build time from CI secrets via
Docker build args; local builds and source runs read them from the
environment. env.template documents the vars (commented out) so an empty
value never overrides the image's built-in credentials.

Generated-By: PostHog Code
Task-Id: 05a9b58b-4c64-4f75-af3e-d27cc4c5702f
2026-07-13 13:06:31 -04:00
Georges-Antoine Assi
cbf134a576 Update .github/workflows/frontend-v1-frozen.yml
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-07-10 18:10:21 -04:00
Georges-Antoine Assi
70cddb8984 ci: fail PRs that modify the frozen frontend v1 UI
The v1 UI (frontend/src/{views,components,console,layouts}) is frozen and
slated for deletion; new frontend work belongs in frontend/src/v2/. This
workflow fails any PR that touches v1 UI files, with an "allow-v1-changes"
label escape hatch for sanctioned critical bug fixes.

Generated-By: PostHog Code
Task-Id: 55fda8a5-426e-479d-8221-26a8437e57bb
2026-07-10 18:00:37 -04:00
Georges-Antoine Assi
c9779a6302 Stop spamming PRs with coverage reports 2026-06-28 22:13:57 -04:00
Georges-Antoine Assi
93922faf91 Key Docker Hub namespace off push credential
Derive the Docker Hub namespace from DOCKER_NAMESPACE, falling back to
DOCKER_USERNAME and then github.repository_owner, so forks whose GitHub
owner name differs from their writable Docker Hub namespace can push.
GHCR is unaffected.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 11:43:03 -04:00
Georges-Antoine Assi
da7658a4aa Clarify GHCR-only preview build PR comment
Rename the comment step to reflect that PR builds only push to GHCR,
add a note explaining the hardcoded registry, and inline the image
string into the updateComment call.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 10:26:30 -04:00
Ian Mancini
967c146fe9 feat: add option to push experimental image to both registries 2026-06-21 20:40:38 -03:00
Ian Mancini
0f17e70350 feat: add action option to push test images to ghcr 2026-06-21 17:38:09 -03:00
Ian Mancini
7f129b9cf0 fix: use repository owner to allow forks to push images to Docker Hub 2026-06-21 16:28:34 -03:00
Georges-Antoine Assi
26cf4b36f8 Scope test-user grant to the romm_test namespace
Addresses review feedback: granting ALL PRIVILEGES on *.* is overly broad,
especially against a shared DB instance. A database-level grant on the
`romm\_test%` wildcard pattern still lets the user CREATE the per-worker
databases (romm_test_gw0, ...) needed by pytest-xdist, while confining it to
that namespace — verified that out-of-namespace CREATE DATABASE is denied.

PostgreSQL needs no equivalent change: its CI service user (POSTGRES_USER)
is the container superuser.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 21:34:46 -04:00
Georges-Antoine Assi
02815ec403 Run backend tests in parallel with pytest-xdist
Add pytest-xdist and run the backend test suite across multiple workers
(`-n 4` in CI). Each worker gets its own database so the autouse
`clear_database` fixture can't wipe rows another worker is mid-test with:

- Rootdir `backend/conftest.py` sets a per-worker `DB_NAME`
  (`romm_test_gw0`, ...) before any app module is imported, so each
  worker's engine binds to its own database.
- `tests/conftest.py` creates the per-worker database on demand (mariadb/
  mysql and postgresql paths) just before migrations run.
- The test user's grant is widened to `*.*` (setup.sql + CI) so it can
  `CREATE DATABASE` for the workers.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 21:02:47 -04:00
Georges-Antoine Assi
1e78a2ed59 Merge branch 'master' into claude/exciting-heisenberg-61PF9 2026-06-18 19:59:00 -04:00
zurdi
0450ab7887 chore: remove lint job from frontend workflow 2026-06-17 10:04:47 +02:00
zurdi
8f879d0b59 chore: update Node.js version to 24.16 across workflows and Dockerfile, and enhance package.json with npm version specification 2026-05-26 09:23:47 +00:00
Claude
95958b6687 test: integrate Hypothesis property-based testing for backend
Add Hypothesis to the test dependency group with CI/dev profiles, and
introduce property-based tests for high-value pure functions: crc32_to_hex,
filesystem and LaunchBox filename sanitization, LaunchBox metadata parsers,
and ROM filename tag parsing.

https://claude.ai/code/session_01GCTFmzuhvqNbSAfw3rGxmj
2026-05-21 16:40:04 +00:00
zurdi
df8f6178ef chore(frontend): set up vitest + storybook play() tests and align CI
Add Vitest 4 with happy-dom, @vue/test-utils, and a single
test/storybook.test.ts that auto-discovers every story under
src/v2/lib and runs its play() via composeStories — no Playwright,
just composition-based interaction tests. 89 stories now smoke-pass
in CI.

Scripts: lint:fix (auto-fix), lint (now scoped to ./src/v2; v1 is
frozen), lint:all (legacy sweep), test, test:watch, test:ui,
storybook:test.

eslint.config.js gets argsIgnorePattern: "^_" so unused-by-design
parameters can use the underscore convention.

CI: new frontend.yml runs lint, test, build in parallel on
frontend/** changes; typecheck.yml bumped to Node 22 with cached
npm ci. Existing typecheck job preserved for branch protection.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 11:52:44 +00:00
Georges-Antoine Assi
f2e8e337b2 Merge branch 'master' into save-sync 2026-04-05 21:47:53 -04:00
Georges-Antoine Assi
7c41fb5bac revert fs_name sibling roms 2026-04-05 17:57:48 -04:00
Georges-Antoine Assi
5da813c871 add perms to copilot setup step 2026-04-03 09:47:05 -04:00
zurdi
a18fd9c459 fix: remove conditional check for mariadb connectors installation 2026-03-20 13:43:47 +00:00
nendo
51c990dcba fix(ci): install mariadb connectors on all runners
uv sync installs sqlalchemy[mariadb-connector] regardless of which
database is being tested, so libmariadb-dev must be present on all
runners. The postgres migration job and pytest postgresql matrix were
missing this step.
2026-03-16 11:40:39 +09:00
Georges-Antoine Assi
2beba3d141 move to corrrect folder 2026-03-12 21:15:08 -04:00
Georges-Antoine Assi
b9e3ae6be3 add perm to job itself 2026-03-09 23:09:05 -04:00
Georges-Antoine Assi
30db3725f4 add comment at the beginnig 2026-03-09 23:02:52 -04:00
Georges-Antoine Assi
bdd5f4b078 add PR label to trigger preview build 2026-03-09 22:59:31 -04:00
Georges-Antoine Assi
2f7f6f65e7 run tests against postgres matrix 2026-03-08 10:20:09 -04:00
Georges-Antoine Assi
e79204ee4a continue-on-error: true in pytest publish report step 2026-02-03 09:22:09 -05:00
Georges-Antoine Assi
5f58deb3ec set more env vars 2026-01-26 21:50:41 -05:00
Georges-Antoine Assi
08839b85c2 add missing env var 2026-01-26 21:40:07 -05:00
Georges-Antoine Assi
958a337ce2 tweak test in migration file 2026-01-26 21:32:03 -05:00
Georges-Antoine Assi
2576ba6bbc Add workflow to run migrations on PR 2026-01-26 21:30:01 -05:00
Georges-Antoine Assi
743bddcb23 add valkey to pytest ci 2026-01-10 09:22:46 -05:00