* feat(seed): realistic, fast, debuggable seeded images generate_test_data.py can now seed a library whose images look like a real one, quickly, so gallery, sizing and image-conversion work can be tested without anyone's private cover art. The default (--image-fidelity 1) is unchanged: same seed, byte-identical files. - --image-fidelity 2: covers drawn at the real-world size mix (measured aggregates from one 8,396-cover library), the small cover made by RomM's own resize rule, and debug art on every image: the game's title, system and region; a box with rom id, size, kind and format; the original path; pure-colour corner pixels, named corners, percent ticks, crop boxes, a circle that shows stretching and a transparency ring. - --image-fidelity 3: the same over texture calibrated to real bytes per pixel, with 22% of big.png holding JPEG bytes as in real libraries. - --image-weighted-every N (default 10): at level 2, every Nth rom id is drawn at level 3, so one library serves layout and file-size work. - --image-media: also write ScreenScraper media (sizes provisional). - --image-workers / --image-limit: images are drawn in a process pool from a per-rom random stream (seed, rom id), identical to one process. 2,000 roms with images seed in about 18 s instead of about 10 minutes. - After a real run the seeder rotates the gallery's Redis cache, so a fresh seed never serves the previous library's lists. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(seed): keep rows independent of image flags; survive a cache failure - The screenshot count is drawn for every rom, whatever --images or --image-limit say, so those flags no longer shift the rows that follow (--no-images rows were already off in the previous seeder). With the defaults the draws are unchanged: level 1 output is still byte-identical. - A Redis error while rotating the gallery cache prints a warning instead of aborting after the rows are committed, so the report still prints. - Comments in seed_images.py trimmed to the repository's one-or-two-line rule. - tests/tools/test_generate_test_data.py runs the seeder with inserts recorded instead of written: rows match with --image-limit and --no-images, and a cache failure still reports the saved seed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(seed): document seeding a test library in DEVELOPER_SETUP Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(seed): code-review fixes for seeded images pr-ready step 2 (code-review xhigh --fix): - level-3 noise is drawn per channel and retuned, so PNG output reaches the measured 0.9 / 1.5 / 2.0 bytes per pixel spread - --image-media is rejected at --image-fidelity 1, where it did nothing - paths come from rom_fs_resources_path, get_media_resources_path, CoverSize and MetadataMediaType instead of being rebuilt - drop the unused path_column parameter and a no-op ImageChops call - draw a batch's images while the next batch is built and inserted - the cache-failure test checks the rows of the failing run - drop a duplicate media-off test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(seed): simplify pass over seeded images pr-ready step 3 (simplify): - extract small_cover_size from resize_cover_to_small, so the seeder draws the small cover at RomM's size instead of writing, reopening and overwriting it - draw_rom_images returns nothing and follows plan_rom_images, and files_written is derived from the plan - _fitted_size measures from a proportional guess instead of stepping down one point at a time (about a quarter of level-2 draw time) - one draw path for the pool and inline cases - drop the ink parameter, the CORNER_RING alias, the _fade_ring wrapper and the RomImageJob caption default; tighten comments - trim media from the two slowest tests and use dataclasses.replace Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(seed): humanizer pass over the seeding docs pr-ready step 5 (humanizer). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(seed): one image pipeline, dry runs write nothing, main owns its cleanup - level 1 mosaics go through plan_rom_images/draw_rom_images like the other levels, so they get media, workers and RomM's small-cover size - --dry-run plans image paths but writes no files - main() is a thin wrapper: it registers the UTC connect listener and removes it (disposing the pool) in a finally, and the image pool cancels queued draws on error; the test no longer patches SQLAlchemy - the recommendation feed cache is rotated with the gallery cache Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Georges-Antoine Assi <contact@me.gantoine.com>
9.9 KiB
Setting up RomM for development
Option 1: Using Docker
If you prefer to use Docker for development, you can set up RomM using the provided Docker Compose configuration. This method simplifies the setup process by encapsulating all dependencies within Docker containers.
Environment setup
Create the mock structure with at least one rom and empty config for manual testing
mkdir -p romm_mock/library/roms/switch
touch romm_mock/library/roms/switch/metroid.xci
mkdir -p romm_mock/resources
mkdir -p romm_mock/assets
mkdir -p romm_mock/config
touch romm_mock/config/config.yml
Copy env.template to .env and fill the variables
cp env.template .env
ROMM_BASE_PATH=/app/romm
DEV_MODE=true
Build the image
docker compose build # or `docker compose build --no-cache` to rebuild from scratch
The image builds on the same Alpine base as the production image. frontend/node_modules lives in an anonymous volume that outlives the container, so after a rebuild that changes dependencies or the base image, recreate it with docker compose up -d --renew-anon-volumes.
Spin up the Docker containers
docker compose up -d
And you're done! You can access the app at http://localhost:3000. Any changes made to the code will be automatically reflected in the app thanks to the volume mounts.
Optional stacks
Two extra stacks sit in their own files, since most work needs neither. Both join the dev stack's network, so bring docker compose up -d up first.
docker compose -f docker-compose.oidc.yml up -d # Authentik, for OIDC work
docker compose -f docker-compose.streaming.yml up -d # webstation, for streaming work
Authentik listens on http://localhost:9001; point RomM at it with the OIDC_* variables in .env. The webstation image is amd64-only and several GB; it reads romm_mock/webstation for emulator configs and BIOS, and its BROKER_SECRET follows STREAMING_BROKER_SECRET from .env.
Option 2: Manual setup
Environment setup
- Create the mock structure with at least one rom and empty config for manual testing
mkdir -p romm_mock/library/roms/switch
touch romm_mock/library/roms/switch/metroid.xci
mkdir -p romm_mock/resources
mkdir -p romm_mock/assets
mkdir -p romm_mock/config
touch romm_mock/config/config.yml
- Copy env.template to .env and fill the variables
cp env.template .env
- Install system dependencies
# https://mariadb.com/docs/skysql-previous-release/connect/programming-languages/c/install/#Installation_via_Package_Repository_(Linux):
sudo apt install libmariadb3 libmariadb-dev libpq-dev
# Build and configure RAHasher (optional)
# This is only required to calculate RA hashes
# Users on macOS can skip this step as RAHasher is not supported
git clone --recursive https://github.com/RetroAchievements/RALibretro.git
cd ./RALibretro
git checkout 1.8.3
git submodule update --init --recursive
make HAVE_CHD=1 -f ./Makefile.RAHasher
cp ./bin64/RAHasher /usr/bin/RAHasher
- Install python dependencies
scripts/dev-setup.sh installs the pinned uv, Python, and Node versions plus the backend and frontend dependencies in one step, and is safe to rerun. On systems without apt-get, install the MariaDB and PostgreSQL client headers yourself first. To do it by hand instead, follow the steps below.
You'll need uv installed
https://docs.astral.sh/uv/getting-started/installation/
curl -LsSf https://astral.sh/uv/install.sh | sh
Then create the virtual environment and install the dependencies using uv:
uv venv
source .venv/bin/activate
uv sync --all-extras --dev
- Spin up the database and other services
docker compose up -d
- Run the backend
Migrations will be run automatically when running the backend.
cd backend
uv run python3 main.py
- Run the task workers
A manual task run is refused, and a scheduled job stays queued, until an RQ worker listens on its queue; scans and streaming teardowns each have a worker of their own. Each command is a foreground process, so run them in separate terminals. -c config reads the Redis connection from the same REDIS_* settings in .env the backend uses.
cd backend
uv run rq worker -c config --worker-class handler.rq_worker.RomMWorker --with-scheduler high default low
cd backend
uv run rq worker -c config --worker-class handler.rq_worker.RomMWorker --with-scheduler scans
cd backend
uv run rq worker -c config --worker-class handler.rq_worker.PreloadingWorker --with-scheduler streaming
--with-scheduler releases delayed jobs, such as the rescans the filesystem watcher waits out, so each worker needs it. The recurring schedule is registered by the RQ cron process, which the workers then execute:
cd backend
uv run rq cron -c config tasks.cron_config
Setting up the frontend
- Install node.js dependencies
cd frontend
# npm version >= 9 needed
npm install
- Create symlink to resources
Vite serves cover art, screenshots and manuals from assets/romm/resources. The link target resolves from the link's own folder, hence the three levels up:
mkdir -p assets/romm
ln -s ../../../romm_mock/resources assets/romm/resources
- Run the frontend
npm run dev
- Storybook (v2 components)
Component docs and visual QA for frontend/src/ (port 6006):
npm run storybook
npm run storybook:test # play() + axe on every v2 story, in headless Chromium
storybook:test (and npm run test, which includes it) needs Playwright's Chromium: run npx playwright install chromium once.
For responsive layouts, use the viewport toolbar presets from .storybook/rommViewports.ts.
- Optional: local frontend against a remote RomM
To run npm run dev or npm run preview against another RomM instance (for example a home server with a full library), set DEV_PROXY_TARGET in the repo-root .env to its origin, such as https://romm.example.com. Vite then proxies /api, /ws and /assets/romm there instead of the local backend. Leave it empty to keep the default http://127.0.0.1:${DEV_PORT}. The remote's TLS certificate must be valid. Sign in with a username and password: OIDC login does not work through the proxy, because the identity provider redirects to the remote's OIDC_REDIRECT_URI, so the session never reaches localhost.
Seeding a test library
backend/tools/generate_test_data.py fills a database with a prod-like library (platforms, users, roms, files, saves, collections...) and draws cover art on disk. It writes to the database and RESOURCES_BASE_PATH from your .env, so point both at a throwaway database and folder, not a library you care about.
cd backend
uv run tools/generate_test_data.py --roms 2000 --image-fidelity 2 --wipe
That seeds 2,000 roms in under a minute. It prints the seed it used and a login (every seeded user's password is password). Useful flags, all listed in --help:
--wipedeletes the rows the script populates before seeding.--seed Nreproduces the same rows and images (default1337).--image-fidelitysets how real the covers are:1(default) draws one-size mosaics.2uses the real mix of cover sizes and shapes, drawn as debug art showing each rom's id, size and path.3also matches real file weights, and somebig.pngfiles hold JPEG data.
--image-limit Ndraws covers for the first N roms only, and--no-imagesskips them.--image-mediaadds ScreenScraper media (box3d, fanart...).--dry-runbuilds everything but writes nothing, image files included.
The seeded roms have no files under library/, so a scan would mark them missing. The frontend's assets/romm/resources symlink should point at the same resources folder, so the UI shows the seeded covers.
Setting up the linter
We use Trunk for linting, which combines multiple linters and formatters with sensible defaults and a single configuration file. You'll need to install the Trunk CLI to use it.
- Install the Trunk CLI
curl https://get.trunk.io -fsSL | bash
Alternative installation methods can be found in their docs. On commit, the linter will run automatically. To run it manually, use the following commands:
trunk fmt
trunk check
Type checking runs separately from Trunk, against the project's own environment. CI type-checks the whole backend on every backend change; to run it locally:
cd backend
uv run mypy --config-file ../.trunk/configs/mypy.ini .
Failing to install and run the linter will result in a failed CI check, which won't allow us to merge your PR.
Test setup
- Create the test user and database with root user
docker exec -i romm-db-dev mariadb -uroot -p<root password> < backend/romm_test/setup.sql
- Run tests
Migrations will be run automatically when running the tests.
cd backend
# path or test file can be passed as argument to test only a subset
uv run pytest [path/file]
# or run the following command to run all tests, one worker per CPU core
uv run pytest -n auto
Each -n worker gets its own database (romm_test_gw0, romm_test_gw1, ...), created on demand; setup.sql grants the test user the rights to create them. On MariaDB, a new worker database is copied from romm_test_template_<digest>, which the run migrates once and keeps for later runs. The digest covers alembic/, models/ and utils/, so editing any of them builds a new template. To migrate from scratch, drop both the worker databases and the template. On a machine with many cores, cap the workers with --maxprocesses 4 (CI's count) to keep the load on the database down. A serial run of the whole suite takes 20+ minutes. Drop -n auto when debugging with --pdb or -s, which don't work under parallel workers.