2023-08-29 18:16:49 +10:00
|
|
|
default:
|
|
|
|
before_script:
|
|
|
|
- rustc --version && cargo --version
|
2023-09-04 21:45:34 +10:00
|
|
|
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"
|
2023-08-29 18:16:49 +10:00
|
|
|
|
|
|
|
stages:
|
2023-09-04 21:45:34 +10:00
|
|
|
- format
|
2023-08-29 18:16:49 +10:00
|
|
|
- test
|
|
|
|
|
2023-09-04 21:45:34 +10:00
|
|
|
format-code:
|
|
|
|
stage: format
|
|
|
|
script:
|
|
|
|
- cargo fmt -- --check
|
|
|
|
|
|
|
|
postgres-service:
|
2023-08-29 18:16:49 +10:00
|
|
|
stage: test
|
2023-09-04 21:45:34 +10:00
|
|
|
services:
|
|
|
|
- postgres:15-alpine
|
|
|
|
variables:
|
|
|
|
POSTGRES_USER: postgres
|
|
|
|
POSTGRES_PASSWORD: password
|
|
|
|
POSTGRES_DB: newsletter
|
|
|
|
POSTGRES_HOST: postgres
|
2023-08-29 18:16:49 +10:00
|
|
|
script:
|
2023-09-04 21:45:34 +10:00
|
|
|
- SKIP_DOCKER=true ./scripts/init_db.sh # Migrate DB
|
2023-08-29 18:16:49 +10:00
|
|
|
|
2023-09-04 21:45:34 +10:00
|
|
|
test-code:
|
2023-08-29 18:16:49 +10:00
|
|
|
stage: test
|
2023-09-04 21:45:34 +10:00
|
|
|
needs: ["postgres-service"]
|
2023-08-29 18:16:49 +10:00
|
|
|
script:
|
2023-09-04 21:45:34 +10:00
|
|
|
- export DATABASE_URL="postgres://postgres:password@postgres:5432/newsletter" cargo test
|
|
|
|
|
|
|
|
lint-code:
|
2023-08-29 18:16:49 +10:00
|
|
|
stage: test
|
2023-09-04 21:45:34 +10:00
|
|
|
needs: ["postgres-service"]
|
2023-08-29 18:16:49 +10:00
|
|
|
script:
|
2023-09-04 21:45:34 +10:00
|
|
|
- DATABASE_URL="postgres://postgres:password@postgres:5432/newsletter" cargo clippy -- -D warnings
|