Repository navigation
99 lines (81 loc) · 2.59 KB
/
Copy pathcheck-formatting.yml
File metadata and controls
99 lines (81 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: check-build-and-formatting
on:
pull_request:
jobs:
check-all:
runs-on: ubuntu-latest
steps:
- name: Checkout repository (for forks and branches)
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
- name: Create backend .env file
run: |
cp backend/.env.example backend/.env
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- name: Install backend dependencies
run: |
cd backend &&
uv sync --locked &&
uv run prisma generate
- name: Setup Bun
uses: oven-sh/setup-bun@v1
- name: Install frontend dependencies
run: |
cd frontend &&
bun install
- name: black
run: |
cd backend &&
uv run black . --check
- name: ruff
run: |
cd backend &&
uv run ruff check .
- name: pyright
run: |
cd backend &&
uv run pyright .
- name: prettier
run: |
cd frontend &&
bun run prettier . --check
- name: frontend-build
run: |
cd frontend &&
CI=True bun run build
- name: Generate OpenAPI schema
run: |
cd backend &&
uv run python generate_openapi.py
- name: Generate frontend API client
run: |
cd frontend &&
bun run openapi -i ../backend/openapi.json -o src/api &&
bun run prettier --write src/api
- name: Check for schema differences
run: |
API_CHANGES=$(git diff --name-only | grep '^frontend/src/api/' || true)
if [ -z "$API_CHANGES" ]; then
echo "✓ Frontend API client is up to date"
exit 0
fi
# Allow only Page.ts with props change
if [ "$API_CHANGES" = "frontend/src/api/models/Page.ts" ]; then
if git diff -- frontend/src/api/models/Page.ts | grep -q 'props.*:'; then
CHANGE_COUNT=$(git diff --numstat -- frontend/src/api/models/Page.ts | awk '{print $1 + $2}')
if [ "$CHANGE_COUNT" -eq 2 ]; then
echo "✓ Only expected Page.ts props change (see README)"
exit 0
fi
fi
fi
echo "✗ Frontend API client out of sync"
echo "See README for regeneration steps"
git diff --stat | grep 'frontend/src/api/'
exit 1