From 6322ed3f5f9cdbd41f504ae1fab042489a255f56 Mon Sep 17 00:00:00 2001 From: Nick Bland Date: Mon, 4 Sep 2023 21:45:34 +1000 Subject: [PATCH] Quickly update CI to incorporate postgres DB --- .gitlab-ci.yml | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3b223e7..85698b5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 \ No newline at end of file + - DATABASE_URL="postgres://postgres:password@postgres:5432/newsletter" cargo clippy -- -D warnings \ No newline at end of file