Skip to content

Commit 6e5d370

Browse files
committed
🎡 ci: add github actions workflow for code quality
1 parent 9cb984e commit 6e5d370

File tree

2 files changed

+65
-17
lines changed

2 files changed

+65
-17
lines changed

.github/workflows/ci.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
quality:
11+
name: Code Quality
12+
runs-on: ubuntu-latest
13+
defaults:
14+
run:
15+
working-directory: ./backend
16+
17+
steps:
18+
- name: 📥 Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: 🐍 Set up Python
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: '3.13'
25+
26+
- name: 💾 Cache UV
27+
uses: actions/cache@v3
28+
with:
29+
path: ~/.cache/uv
30+
key: ${{ runner.os }}-uv-${{ hashFiles('**/uv.lock') }}
31+
restore-keys: |
32+
${{ runner.os }}-uv-
33+
34+
- name: 📦 Install UV
35+
run: |
36+
curl -LsSf https://astral.sh/uv/install.sh | sh
37+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
38+
39+
- name: 🔧 Install dependencies
40+
run: |
41+
uv sync --dev
42+
43+
- name: 🧹 Run Ruff (linting)
44+
run: |
45+
uv run ruff check src/
46+
47+
- name: 🔍 Run MyPy (type checking)
48+
run: |
49+
uv run mypy src/
50+
51+
- name: 🎨 Check code formatting
52+
run: |
53+
uv run ruff format --check src/

backend/pyproject.toml

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ packages = ["src"]
2626

2727
[dependency-groups]
2828
dev = [
29-
"autoflake>=2.3.1",
3029
"mypy>=1.16.1",
3130
"poethepoet>=0.35.0",
3231
]
@@ -40,29 +39,25 @@ test = [
4039
]
4140

4241
[tool.poe.tasks]
42+
# Linting & Formatting
43+
format = "ruff format src/"
44+
lint = "ruff check --fix src/"
45+
check = "ruff check src/"
4346

44-
ruff-check = "ruff check src/"
45-
ruff-fix = "ruff check --fix src/"
46-
ruff-format = "ruff format src/"
47-
clean-imports = "autoflake --remove-all-unused-imports --remove-unused-variables --in-place --recursive src/"
48-
check-imports = "autoflake --check --remove-all-unused-imports --recursive src/"
47+
# Type checking
4948
type-check = "mypy src"
50-
type-check-relaxed = "mypy src --disable-error-code no-any-return --disable-error-code attr-defined"
49+
type-check-strict = "mypy src --strict"
5150

51+
# Development
5252
dev = "python run_dev.py"
5353
dev-reload = "uvicorn src.main:app --reload --host 0.0.0.0 --port 8000"
54-
run-prd = "uvicorn src.main:app --host 0.0.0.0 --port 8000"
5554

56-
format = ["ruff-format", "clean-imports"]
57-
lint = ["ruff-fix", "clean-imports", "type-check-relaxed"]
58-
check = ["ruff-check", "check-imports", "type-check-relaxed"]
59-
check-strict = ["ruff-check", "check-imports", "type-check"]
60-
all = ["ruff-fix", "ruff-format", "clean-imports", "type-check-relaxed"]
55+
# Production
56+
run = "uvicorn src.main:app --host 0.0.0.0 --port 8000"
6157

62-
test = "pytest tests/"
63-
test-cov = "pytest tests/ --cov=src --cov-report=html --cov-report=term"
64-
test-unit = "pytest tests/unit/"
65-
test-integration = "pytest tests/integration/"
58+
# CI pipeline
59+
ci = ["check", "type-check"]
60+
quality = ["format", "lint", "type-check"]
6661

6762
[tool.ruff]
6863
target-version = "py311"

0 commit comments

Comments
 (0)