Skip to content

Commit

Permalink
Update CI/CD pipeline to handle Postgres migration
Browse files Browse the repository at this point in the history
  • Loading branch information
kylewlacy committed Jun 9, 2024
1 parent b9edfed commit 20fd3bf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 21 deletions.
7 changes: 5 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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:[email protected]:6543

# Used only for the sqlx CLI
DATABASE_URL=sqlite://./data/schema.db?mode=ro

# Set this to enable builds even without a running database
# CARGO_SQLX_OFFLINE=true
6 changes: 5 additions & 1 deletion .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ 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: cargo sqlx prepare -- --check
- name: Check Clippy
run: cargo clippy --all -- -Dwarnings
test:
Expand Down
18 changes: 0 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 20fd3bf

Please sign in to comment.