Skip to content

Commit a67134a

Browse files
committed
chore: add CI workflow for linting and testing with PostgreSQL service
1 parent 8e99168 commit a67134a

1 file changed

Lines changed: 81 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
lint:
16+
name: Lint
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v5
23+
with:
24+
enable-cache: true
25+
26+
- name: Set up Python
27+
run: uv python install
28+
29+
- name: Install dependencies
30+
run: uv sync --locked
31+
32+
- name: Ruff check
33+
run: uv run ruff check .
34+
35+
- name: Ruff format
36+
run: uv run ruff format --check .
37+
38+
test:
39+
name: Test
40+
runs-on: ubuntu-latest
41+
services:
42+
postgres:
43+
image: postgres:17
44+
env:
45+
POSTGRES_USER: postgres
46+
POSTGRES_PASSWORD: postgres
47+
POSTGRES_DB: learning-platform
48+
ports:
49+
- 5432:5432
50+
options: >-
51+
--health-cmd "pg_isready -U postgres"
52+
--health-interval 10s
53+
--health-timeout 5s
54+
--health-retries 5
55+
56+
env:
57+
POSTGRES_HOST: localhost
58+
POSTGRES_USER: postgres
59+
POSTGRES_PASSWORD: postgres
60+
POSTGRES_DB: learning-platform
61+
POSTGRES_PORT: 5432
62+
JWT_SECRET_KEY: ci-jwt-secret-key-for-testing-only-32chars
63+
AUTH_RESET_PASSWORD_TOKEN_SECRET: ci-reset-secret-for-testing-only-32ch
64+
AUTH_VERIFICATION_TOKEN_SECRET: ci-verification-secret-for-testing-32ch
65+
66+
steps:
67+
- uses: actions/checkout@v4
68+
69+
- name: Install uv
70+
uses: astral-sh/setup-uv@v5
71+
with:
72+
enable-cache: true
73+
74+
- name: Set up Python
75+
run: uv python install
76+
77+
- name: Install dependencies
78+
run: uv sync --locked
79+
80+
- name: Run tests
81+
run: uv run pytest -v -n auto

0 commit comments

Comments
 (0)