From cdc159489a11acf712acbba66c7431d0a6ed7ce5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luukas=20P=C3=B6rtfors?= Date: Wed, 20 Dec 2023 20:53:52 +0200 Subject: [PATCH] chore: run tests in CI --- .github/workflows/rust.yml | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 07db8b6..08d72cd 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -20,6 +20,22 @@ jobs: test: name: Test Suite runs-on: ubuntu-latest + + services: + postgres: + image: postgres + env: + POSTGRES_DB: testaustime + POSTGRES_PASSWORD: postgres + POSTGRES_USER: postgres + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + steps: - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 @@ -27,9 +43,17 @@ jobs: profile: minimal toolchain: nightly override: true - - uses: actions-rs/cargo@v1 - with: - command: test + - name: Install Diesel + run: cargo install diesel_cli --features=postgres + - name: Create Test DB + env: + DATABASE_URL: postgres://postgres:postgres@localhost/testaustime + run: diesel migration run + + - name: Run tests + env: + TEST_DATABASE: postgres://postgres:postgres@localhost/testaustime + run: cargo test fmt: name: Rustfmt