Skip to content

ci: add gh action

ci: add gh action #1

Workflow file for this run

name: Build
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build-backend:
name: cargo test
runs-on: ubuntu-latest
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/car_ledger_db
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: car_ledger_db
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Install SQLx CLI
run: cargo install sqlx-cli
- name: Run database migrations
run: sqlx migrate run
working-directory: ./backend
- name: Build backend
run: cargo build --release
working-directory: ./backend
- name: Test backend
run: cargo test
working-directory: ./backend
formatting:
name: cargo fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt
- name: Rustfmt Check
uses: actions-rust-lang/rustfmt@v1
build-frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Install Trunk
run: npm install -g trunk
- name: Build frontend
run: trunk build --release
working-directory: ./frontend