Repository navigation
testing
cd backend
cargo fmt --check
cargo clippy --all-targets -- -D warnings
cargo testThe API tests run on the database that TEST_DATABASE_URL names (or DATABASE_URL if it isn't set). Each test gets its own fresh database with the migrations applied, so tests never see each other's data:
| Database | TEST_DATABASE_URL |
Each test gets |
|---|---|---|
| PostgreSQL |
postgres://rollcall:rollcall@localhost:5432/rollcall (docker compose up -d db) |
A new database rc_test_<random>
|
| SQLite | sqlite: |
A new file in the temp folder |
| MySQL/MariaDB | mysql://root:password@localhost:3306/ |
A new database rc_test_<random>
|
The user needs permission to create databases. The test databases are left behind, so use a throwaway server.
-
API tests (
backend/tests/api/) call the real router: a spool's whole life (adding it, weight changes and undo, the dashboard numbers), search and filters, and validation errors. They are one test program,api, with a module for each area (spools.rs,prints.rs,printers.rs,backups.rs,auth.rsand so on) and the helpers they share inmain.rs. A new test goes next to related tests in the module for its area;cargo test --test api <name>runs the ones whose name matches. -
Parser tests run the link parser on saved product pages in
backend/tests/fixtures/. They never use the network, so a store changing its page can't break the build. - Unit tests next to the code cover the color and brand tables, the title and text patterns, and the safety check for private addresses.
The OpenAPI document is made from the code (see the architecture), and these tests keep every copy and every hand-written part of it true:
-
docs/openapi.jsonis current (openapi::tests::the_committed_document_is_current, a unit test). After changing an endpoint or a type it sends or takes, runcargo run -- openapi > ../docs/openapi.jsoninbackend/, thennpm run gen:apiinfrontend/. -
Every operation is a real route, guarded as it says (
backend/tests/api/openapi.rs). Each documented operation is called on the real router: without signing in, the open ones answer and the others say 401; as a member, none is "not routed", and exactly the ones marked admin-only refuse. -
No route without a description: a plain
routecall inbackend/srcfails a unit test (the two exceptions are named there), and so does a schema name used by two types, a reference that leads nowhere, or an operation without a summary, an area or an answer. -
A description says what its handler does: the answer type in
responses(...)must be theJson<...>the function returns, and aQuery<...>it takes must be inparams(...)(openapi::tests::a_description_says_what_its_handler_takes_and_answers). -
The frontend's generated types are current:
npm run lintends withnpm run check:api, which fails whensrc/lib/api/schema.d.tsisn't whatdocs/openapi.jsongives.
Queries aren't checked when the code compiles, since one query runs on three databases. The API tests are what catch a broken query, so a change to a query or the schema should be tested on all of them; CI does that on every push. A schema change needs a migration for each database: a new file in backend/migrations/postgres/, sqlite/ and mysql/.
cd frontend
npm run lint && npm run check && npm test && npm run build-
npm run lintruns Prettier for the formatting, then ESLint (eslint.config.js: the recommended rules of ESLint, typescript-eslint andeslint-plugin-svelte) for mistakes, thennpm run check:api, which fails when the generated API types (src/lib/api/schema.d.ts) are not whatdocs/openapi.jsongives.npm run gen:apiwrites them again. -
npm run checkissvelte-check, which is TypeScript for the components too. -
npm testruns the Vitest tests, which sit next to what they test as*.test.ts:-
Unit tests for the helpers in
src/lib/util/: formatting, search, labels, the scan codes and so on. -
The API client (
src/lib/api/client.test.ts): errors in the server's words, timeouts, retries of slow requests, being signed out, and the view-only notice. -
Live updates (
src/lib/state/live.test.ts): one connection for all listeners, which topics a listener is told, and connecting again after the connection drops. -
The shared lists and the paged spool list (
src/lib/state/lookups.svelte.test.ts,spoolList.test.ts): what is fetched when, and what a change makes them read again. -
Component tests render a component in jsdom with
@testing-library/svelteand press its buttons: the spool picker, quick deduct on a spool card with its "Take the rest" warning, the end of a paged list, the reorder list and the view-only notice. A component test starts with// @vitest-environment jsdom;src/lib/testing/has a spool to test with and a stand-in for the server.
-
Unit tests for the helpers in
-
npm run buildis the production build.
One Playwright test (frontend/e2e/smoke.spec.ts) goes through the app in a real browser, as a new user would: it creates the first account, adds a spool by hand, logs a print by hand, and checks that the print's filament came off the spool.
It needs a Rollcall server on an empty database, because the first account can only be created once. With the frontend built and the backend compiled:
cd frontend
npm run build
npx playwright install chromium # once
# In another terminal: a server on a throwaway SQLite file.
cd backend
rm -f /tmp/rollcall-e2e.db
DATABASE_URL=sqlite:///tmp/rollcall-e2e.db BIND_ADDR=127.0.0.1:8099 \
STATIC_DIR=../frontend/build UPLOAD_DIR=/tmp/rollcall-e2e-uploads \
BACKUP_DIR=/tmp/rollcall-e2e-backups cargo run --release
# Back in frontend/:
E2E_BASE_URL=http://127.0.0.1:8099 npm run e2eDelete the database file before each run. CI doesn't run this test: it is for checking a larger change to the interface by hand before it is merged.
.github/workflows/tests.yml runs on every push and pull request:
| Job | What it checks |
|---|---|
| Lint | actionlint (with shellcheck) on the workflows, shellcheck on the shell scripts, hadolint on the Dockerfile, and markdownlint on the documentation |
| Backend | rustfmt, clippy, and the API tests on PostgreSQL 18, SQLite, MariaDB 11.4 and MySQL 8.4 |
| Frontend | The four checks above (not the end-to-end test) |
| Dependency advisories |
cargo audit on the backend's crates and npm audit on the frontend's packages, for known vulnerabilities. A finding fails the job, on a pull request too; an unmaintained or yanked crate is only listed. No other job waits for it, so it never holds back an image. An advisory with no fix yet, or about code Rollcall doesn't use, gets an --ignore for exactly that id in the workflow, with the reason |
| Docker image | Builds the image on amd64 and arm64, starts it next to PostgreSQL 18 and on its own with SQLite, checks the API, the web interface, saving a spool and the health check, and scans it with Trivy |
| Native build | Builds the static Linux server for x86_64 and aarch64 and packs the downloads. It installs each one as a systemd service with install.sh, then checks the API, the rollcall command, an upgrade, and uninstalling. The x86_64 download is also installed in Debian 13, Ubuntu 24.04, Rocky Linux 9 and Oracle Linux 9 containers |
| Native build (FreeBSD) | In a FreeBSD 14 virtual machine: builds the server, runs the API tests on SQLite, and installs and starts the rc.d service |
| Publish | On develop and main only: tags the tested images (see Docker) |
| Publish the native downloads | On develop and main only: puts the tested downloads on the develop-build or latest release (see Installing without Docker) |
It also runs each Monday, so a new Rust release or runner image that breaks the build shows up without a push. The Dockerfile's base images are pinned by digest, and Dependabot raises them.
This wiki is a copy of the docs folder, updated whenever it changes. To change a page, edit its file there: changes made here are overwritten.