Skip to content

ci: add PostgreSQL service to CI workflow for backend tests #9

ci: add PostgreSQL service to CI workflow for backend tests

ci: add PostgreSQL service to CI workflow for backend tests #9

Workflow file for this run

name: CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
DATABASE_URL: postgresql://imi_user:imi_passwd@localhost:5432/imi
jobs:
backend:
name: Backend
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend
services:
postgres:
image: postgres:latest
env:
POSTGRES_DB: imi
POSTGRES_USER: imi_user
POSTGRES_PASSWORD: imi_passwd
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
backend/target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
env:
DATABASE_URL: postgresql://imi_user:imi_passwd@localhost:5432/imi
frontend:
name: Frontend
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: './frontend/package-lock.json'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Type check
run: npm run typescript