Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/scripts/sqlite-query-check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""Prepare a migration-derived schema and verify SQLx offline query metadata."""
import json
import os
from pathlib import Path
import sqlite3
import sys

work = Path(os.environ["GFA_SQLX_WORK_DIR"])
database = work / "schema.sqlite"
queries = work / "queries"

if sys.argv[1] == "prepare":
queries.mkdir(parents=True, exist_ok=True)
database.unlink(missing_ok=True)
for path in queries.glob("query-*.json"):
path.unlink()
with sqlite3.connect(database) as connection:
for migration in sorted(Path("crates/adapters/gfa-store/migrations/sqlite").glob("*.sql")):
connection.executescript(migration.read_text())
elif sys.argv[1] == "verify":
def metadata(directory):
return {path.name: json.loads(path.read_text()) for path in directory.glob("query-*.json")}

generated = metadata(queries)
if not generated or generated != metadata(Path(".sqlx")):
raise SystemExit("SQLx metadata is missing or stale; regenerate it from the migrations.")
else:
raise SystemExit("usage: sqlite-query-check.py prepare|verify")
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,18 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Prepare SQLite schema for query checking
run: python3 .github/scripts/sqlite-query-check.py prepare
env:
GFA_SQLX_WORK_DIR: ${{ runner.temp }}/gfa-sqlx
- run: cargo test --workspace --all-features --locked
env:
DATABASE_URL: sqlite:${{ runner.temp }}/gfa-sqlx/schema.sqlite
SQLX_OFFLINE_DIR: ${{ runner.temp }}/gfa-sqlx/queries
- name: Verify offline query metadata
run: python3 .github/scripts/sqlite-query-check.py verify
env:
GFA_SQLX_WORK_DIR: ${{ runner.temp }}/gfa-sqlx
- run: cargo xtask check-deps
- run: cargo check -p gfa-games --no-default-features --locked
lint:
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading