mirror of
https://github.com/Phundrak/georm.git
synced 2026-07-29 04:19:18 +02:00
4c314c2f0b
Adds a SqliteDialect alongside PostgresDialect, gated by mutually exclusive postgres (default) / sqlite Cargo features, plus a feature-selected ActiveDatabase type alias used throughout the public Georm/Defaultable traits. Basic CRUD and Defaultable are fully covered by a new SQLite test suite (tests/sqlite/*) running against a real SQLite database, alongside split migrations/sqlite/*. Two real dialect differences surfaced beyond placeholder syntax: - SQLite's INTEGER columns type-infer as i64 in sqlx's compile-time query macros (unlike Postgres SERIAL -> i32), so the SQLite test models use i64 for integer PK/FK fields. - sqlx's SQLite query macros need bind arguments bound to a place rather than passed as an inline expression (fixed once, centrally, in SqlDialect::generate_relation_lookup). Composite-key entities with chrono::DateTime columns (tests/composite_key.rs) are not yet ported to SQLite: SQLite has no TIMESTAMPTZ equivalent, so sqlx infers TEXT date/time columns as String rather than DateTime<Utc> unless the query explicitly overrides the column type. That needs per-field type overrides threaded through the generated queries, left as follow-up. CI now matrixes over both backends; formatting/audit only run once since they don't vary by backend. examples/postgres/* stays out of --no-default-features builds by scoping sqlite lint/test just recipes to `-p georm` (it depends on georm's default postgres feature via Cargo feature unification, so building it under --features sqlite at the workspace level double-activates both dialects).
63 lines
2.0 KiB
YAML
63 lines
2.0 KiB
YAML
name: CI
|
|
on:
|
|
pull_request:
|
|
push:
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: ${{ github.ref != 'ref/heads/master' }}
|
|
|
|
jobs:
|
|
tests:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: catthehacker/ubuntu:js-latest
|
|
options: --security-opt seccomp=unconfined
|
|
permissions:
|
|
pull-requests: write
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
backend: [postgres, sqlite]
|
|
services:
|
|
postgres:
|
|
image: postgres:16-alpine
|
|
env:
|
|
POSTGRES_PASSWORD: georm
|
|
POSTGRES_USER: georm
|
|
POSTGRES_DB: georm
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 10s
|
|
--health-retries 5
|
|
env:
|
|
DATABASE_URL: ${{ matrix.backend == 'postgres' && 'postgresql://georm:georm@postgres:5432/georm' || 'sqlite:///tmp/georm-ci.db' }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Install Nix
|
|
uses: cachix/install-nix-action@v31
|
|
- name: Install devenv
|
|
run: nix profile install nixpkgs#devenv
|
|
- name: Create SQLite database file
|
|
if: matrix.backend == 'sqlite'
|
|
run: touch /tmp/georm-ci.db
|
|
- name: Migrate database (postgres)
|
|
if: matrix.backend == 'postgres'
|
|
run: devenv shell just migrate-postgres
|
|
- name: Migrate database (sqlite)
|
|
if: matrix.backend == 'sqlite'
|
|
run: devenv shell just migrate-sqlite
|
|
# Formatting and dependency audit don't vary by backend, so only run
|
|
# them once rather than duplicating across both matrix legs.
|
|
- name: Formatting check
|
|
if: matrix.backend == 'postgres'
|
|
run: devenv shell just format-check
|
|
- name: Audit
|
|
if: matrix.backend == 'postgres'
|
|
run: devenv shell just audit
|
|
- name: Lint
|
|
run: devenv shell just ${{ matrix.backend == 'postgres' && 'lint' || 'lint-sqlite' }}
|
|
- name: Tests
|
|
run: devenv shell just ${{ matrix.backend == 'postgres' && 'test-postgres' || 'test-sqlite' }}
|