Skip to content

Commit fccd693

Browse files
committed
add backend tests workflow
1 parent 5bddea3 commit fccd693

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Backend Tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths:
7+
- 'backend/**'
8+
- 'db_connector/**'
9+
- '.github/workflows/backend-tests.yml'
10+
pull_request:
11+
branches: [ main ]
12+
paths:
13+
- 'backend/**'
14+
- 'db_connector/**'
15+
- '.github/workflows/backend-tests.yml'
16+
17+
jobs:
18+
test:
19+
runs-on: ubuntu-latest
20+
21+
services:
22+
postgres:
23+
image: postgres:17
24+
env:
25+
POSTGRES_PASSWORD: testing
26+
POSTGRES_USER: postgres
27+
POSTGRES_DB: postgres
28+
options: >-
29+
--health-cmd pg_isready
30+
--health-interval 10s
31+
--health-timeout 5s
32+
--health-retries 5
33+
ports:
34+
- 5432:5432
35+
36+
env:
37+
DATABASE_URL: postgres://postgres:testing@localhost:5432/postgres
38+
JWT_SECRET: testing123
39+
FRONTEND_URL: http://localhost:3000
40+
41+
steps:
42+
- name: Checkout code
43+
uses: actions/checkout@v4
44+
45+
- name: Install Rust
46+
uses: dtolnay/rust-toolchain@stable
47+
with:
48+
components: rustfmt, clippy
49+
50+
- name: Cache Rust dependencies
51+
uses: Swatinem/rust-cache@v2
52+
with:
53+
workspaces: |
54+
backend
55+
db_connector
56+
57+
- name: Install diesel_cli
58+
run: cargo install diesel_cli --no-default-features --features postgres
59+
60+
- name: Wait for PostgreSQL
61+
run: |
62+
until pg_isready -h localhost -p 5432 -U postgres; do
63+
echo "Waiting for PostgreSQL..."
64+
sleep 2
65+
done
66+
67+
- name: Run database migrations
68+
working-directory: ./db_connector
69+
run: diesel migration run
70+
71+
- name: Run backend tests
72+
working-directory: ./backend
73+
run: cargo test --verbose
74+
75+
- name: Run db_connector tests
76+
working-directory: ./db_connector
77+
run: cargo test --verbose
78+
79+
- name: Check formatting
80+
working-directory: ./backend
81+
run: cargo fmt --check
82+
83+
- name: Run clippy
84+
working-directory: ./backend
85+
run: cargo clippy -- -D warnings

0 commit comments

Comments
 (0)