Quickly update CI to incorporate postgres DB

This commit is contained in:
Nick Bland 2023-09-04 21:45:34 +10:00
parent 679e257f7b
commit 6322ed3f5f

View File

@ -1,23 +1,49 @@
image: "registry.nickbland.dev/nickbland/rust-docker-ci:latest"
default:
before_script:
- rustc --version && cargo --version
image: "registry.nickbland.dev/nickbland/rust-docker-ci:latest"
cache:
key:
files:
- Cargo.lock
paths:
- .cargo/
- target/
policy: pull-push
variables:
FF_USE_FASTZIP: "true"
CACHE_COMPRESSION_LEVEL: "fastest"
stages:
- format
- test
format-code:
stage: format
script:
- cargo fmt -- --check
postgres-service:
stage: test
services:
- postgres:15-alpine
variables:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: newsletter
POSTGRES_HOST: postgres
script:
- SKIP_DOCKER=true ./scripts/init_db.sh # Migrate DB
test-code:
stage: test
needs: ["postgres-service"]
script:
- cargo test --verbose
- export DATABASE_URL="postgres://postgres:password@postgres:5432/newsletter" cargo test
lint-code:
stage: test
needs: ["postgres-service"]
script:
- cargo clippy -- -D warnings
format-code:
stage: test
script:
- cargo fmt -- --check
- DATABASE_URL="postgres://postgres:password@postgres:5432/newsletter" cargo clippy -- -D warnings