-
Notifications
You must be signed in to change notification settings - Fork 0
155 lines (135 loc) · 4.28 KB
/
ci.yml
File metadata and controls
155 lines (135 loc) · 4.28 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: CI
on:
push:
branches: [main]
tags: ['v*']
pull_request:
branches: [main]
jobs:
quality:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20]
steps:
- uses: actions/checkout@v5
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v5
with:
node-version: ${{ matrix.node-version }}
# Install dependencies
- name: Install frontend dependencies
run: cd frontend && npm ci
- name: Install backend dependencies
run: cd backend && npm ci
# Type checking
- name: Typecheck frontend
run: |
cd frontend && npx tsc --noEmit 2>&1 || {
echo ""
echo "::error::Frontend type check failed. Fix the TypeScript errors above."
exit 1
}
- name: Typecheck backend
run: |
cd backend && npx tsc --noEmit 2>&1 || {
echo ""
echo "::error::Backend type check failed. Fix the TypeScript errors above."
exit 1
}
# Linting
- name: Lint frontend
run: |
cd frontend
OUTPUT=$(npx eslint . 2>&1) || {
echo "$OUTPUT"
echo ""
echo "::error::Frontend lint failed. Run 'cd frontend && npx eslint . --fix' to auto-fix, then commit."
exit 1
}
echo "$OUTPUT"
- name: Lint backend
run: |
cd backend
OUTPUT=$(npx eslint . 2>&1) || {
echo "$OUTPUT"
echo ""
echo "::error::Backend lint failed. Run 'cd backend && npx eslint . --fix' to auto-fix, then commit."
exit 1
}
echo "$OUTPUT"
# Formatting
- name: Format check
run: |
UNFORMATTED=$(npx -y prettier --list-different "frontend/**/*.{ts,tsx,js,jsx,json}" "backend/**/*.{ts,js,json}" "*.{json,md,yml,yaml}" 2>/dev/null || true)
if [ -n "$UNFORMATTED" ]; then
echo "Unformatted files:"
echo "$UNFORMATTED"
echo ""
echo "::error::Files above are not formatted. Run 'npx prettier --write .' locally and commit."
exit 1
fi
echo "All files formatted correctly."
# Tests
- name: Test frontend
run: |
cd frontend && npm test 2>&1 || {
echo ""
echo "::error::Frontend tests failed. Run 'cd frontend && npm test' locally to debug."
exit 1
}
- name: Test backend
run: |
cd backend && npm test 2>&1 || {
echo ""
echo "::error::Backend tests failed. Run 'cd backend && npm test' locally to debug."
exit 1
}
# Build
- name: Build frontend
run: |
cd frontend && npx vite build 2>&1 || {
echo ""
echo "::error::Frontend build failed. Run 'cd frontend && npx vite build' locally to debug."
exit 1
}
- name: Build backend
run: |
cd backend && npm run build 2>&1 || {
echo ""
echo "::error::Backend build failed. Run 'cd backend && npm run build' locally to debug."
exit 1
}
# Docker publish — only on version tags, after CI passes
docker:
needs: quality
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: idemerge/llm-api-radar
tags: |
type=semver,pattern={{version}}
type=semver,pattern=v{{version}}
type=raw,value=latest
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max