diff --git a/.env.example b/.env.example index fab86f5..ecd2506 100644 --- a/.env.example +++ b/.env.example @@ -4,8 +4,11 @@ # Store object store files under `data/objects` BRIOCHE_REGISTRY_OBJECT_STORE_URL=relative-file:///./data/objects -# Store the database under `data/dev.db` -BRIOCHE_REGISTRY_DATABASE_URL=sqlite://./data/dev.db?mode=rwc +# Set to a running Postgres instance (see `docker-compose.yml`) +BRIOCHE_REGISTRY_DATABASE_URL=postgresql://postgres:brioche-registry@127.0.0.1:6543 # Used only for the sqlx CLI -DATABASE_URL=sqlite://./data/schema.db?mode=ro +DATABASE_URL=postgresql://postgres:brioche-registry@127.0.0.1:6543 + +# Set this to enable builds even without a running database +# CARGO_SQLX_OFFLINE=true diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index d6e8bc5..da70ca4 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -20,10 +20,17 @@ jobs: curl -L https://development-content.brioche.dev/tools/sqlx-cli_v0.7.1/cargo-sqlx -o ~/.local/bin/cargo-sqlx chmod +x ~/.local/bin/sqlx ~/.local/bin/cargo-sqlx echo "$HOME/.local/bin" >> $GITHUB_PATH + - name: Set up database + run: | + cp .env.example .env + docker-compose up -d - name: Check formatting run: cargo fmt -- --check - name: Check database schema - run: make check-db-schema + run: | + # NOTE: Run `cargo check` first to prevent the SQLx stuff in `brioche-core` from interfering + cargo check + cargo sqlx prepare --check - name: Check Clippy run: cargo clippy --all -- -Dwarnings test: diff --git a/Makefile b/Makefile index b906e41..35f0a79 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,3 @@ .PHONY: dev dev: cargo watch -x 'run -- serve' - -.PHONY: update-db-schema -update-db-schema: -# Run cargo check first to make sure `brioche` gets build. Otherwise, sqlx -# will try to check Brioche's queries and fail - cargo check || true - mkdir -p ./data - DATABASE_URL=sqlite://$(CURDIR)/data/schema.db?mode=rwc cargo sqlx migrate run - DATABASE_URL=sqlite://$(CURDIR)/data/schema.db cargo sqlx prepare - -.PHONY: check-db-schema -check-db-schema: -# Run cargo check first to make sure `brioche` gets build. Otherwise, sqlx -# will try to check Brioche's queries and fail - cargo check || true - mkdir -p ./data - DATABASE_URL=sqlite://$(CURDIR)/data/schema.db?mode=rwc cargo sqlx migrate run - DATABASE_URL=sqlite://$(CURDIR)/data/schema.db cargo sqlx prepare --check