CI
Type-check and build your queries in CI and on your host
Reylo's type check runs in CI as it does on your machine, against a database the job starts:
| Database | A throwaway one the job starts: a service container, or a file for SQLite |
| Schema | Your migrations or a schema file, applied before the type check |
| Connection | DATABASE_URL in the job's environment, or direct_url |
| Commands | The type check, then your build and your tests |
| Builds on a host | A database of its own, where the host builds before it migrates (below) |
GitHub Actions
Start Postgres as a service container, and point DATABASE_URL at it:
on: [push, pull_request]
jobs:
check:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:18
env:
POSTGRES_PASSWORD: postgres
ports: ["5432:5432"]
# wait until postgres accepts connections
options: >-
--health-cmd pg_isready
--health-interval 2s
--health-retries 30
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgresThen apply your schema, and run the type check, the build and your tests:
jobs:
check:
# ...
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with: { node-version: 24 }
- run: npm ci
# your migrations, or a schema file
- run: psql "$DATABASE_URL" -v ON_ERROR_STOP=1 -f schema.sql
# tsc --noEmit --runExternalCode
- run: npm run typecheck
- run: npm run build
- run: npm test- The build reads the database too. Reylo's plugins read each query's types from it as they bundle the query, and
next buildruns the type check itself. - A
DATABASE_URLin the environment wins over your.envfiles. Adirect_urlin.reylo.yamlwins over both, so if yours names a database, point it at a variable the job sets. - Reylo's engine is an optional dependency, installed for the runner's platform, so don't install with
--omit=optional. - Reylo keeps a cache of each query's analysis in
reylo/.cache/, which git ignores. A fresh checkout has none, so the type check analyzes every query on the database.
Schema
Apply your schema with the tool you already use, before the type check:
steps:
# ...
- run: npx reylo migrate deploy
- run: npm run typechecksteps:
# ...
- run: npx prisma migrate deploy
- run: npm run typechecksteps:
# ...
- run: npx drizzle-kit migrate
- run: npm run typechecksteps:
# ...
- run: |
for file in migrations/*.sql; do
psql "$DATABASE_URL" -v ON_ERROR_STOP=1 -f "$file"
done
- run: npm run typecheckA job that skips this step fails on the first table a query reads:
queries/get_user.sql(1,29): error reylo6: relation "users" does not exist (42P01)MySQL
Start MySQL in place of Postgres, and apply the schema with its client:
jobs:
check:
# ...
services:
mysql:
image: mysql:8.4
env:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
MYSQL_DATABASE: app
ports: ["3306:3306"]
options: >-
--health-cmd "mysqladmin ping -h 127.0.0.1 --silent"
--health-interval 2s
--health-retries 60
env:
DATABASE_URL: mysql://root@127.0.0.1:3306/app
steps:
# ...
# tcp, not localhost's socket
- run: mysql -h 127.0.0.1 -u root app < schema.sql
- run: npm run typecheckSQLite
SQLite needs no service: build the database file in a step.
jobs:
check:
# ...
env:
# the path starts at package.json
DATABASE_URL: file:./app.db
steps:
# ...
# or your migrations
- run: sqlite3 app.db < schema.sql
- run: npm run typecheckCloudflare D1
Run your migrations on the local database before the type check:
steps:
# ...
- run: npx reylo migrate deploy
- run: npm run typecheck
- run: npm run buildThe type check reads the local file that direct_url names, so the job needs no Cloudflare account. Cloudflare D1 and Durable Objects cover the rest.
A host that builds before it migrates
A host that builds before it migrates, such as Vercel, starts with no database that has your schema. Build against a database of its own:
- Create an empty database.
- Run your migrations into it, which also tries each one before it reaches production.
- Run the build with
direct_urlpointed at that database. - Drop it.
- Migrate your deployment's own database.
Errors
A query that doesn't match the schema fails the job, at its line and column:
queries/get_user.sql(1,18): error reylo6: column "emial" does not exist (42703)The build fails on the same error. A caller that reads a column the query no longer returns fails the type check too.