forked from TONresistor/teleton-agent
-
Notifications
You must be signed in to change notification settings - Fork 2
265 lines (205 loc) · 6.42 KB
/
ci.yml
File metadata and controls
265 lines (205 loc) · 6.42 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
# ---- Build Runtime (Node 20 + 22) ----
build-runtime:
name: CI / Build (Runtime)
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20, 22]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install root dependencies
run: npm ci
- name: Install WebUI dependencies
run: cd web && npm ci
- name: Build SDK workspace
run: npm run build -w packages/sdk
- name: Build full project
run: npm run build
- name: CLI smoke test
run: node dist/cli/index.js --help
- name: Upload build artifacts
if: matrix.node-version == 20
uses: actions/upload-artifact@v4
with:
name: dist-ci-${{ github.sha }}
path: dist/
retention-days: 7
# ---- Build SDK with DTS ----
build-sdk:
name: CI / Build (SDK with DTS)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install root dependencies
run: npm ci
- name: Build SDK with type declarations
run: npm run build -w packages/sdk
- name: Verify DTS output
run: |
if [ ! -f "packages/sdk/dist/index.d.ts" ]; then
echo "Error: TypeScript declarations not generated"
exit 1
fi
echo "DTS generated successfully: packages/sdk/dist/index.d.ts"
# ---- Lint (pull_request only) ----
lint:
name: CI / Lint
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install root dependencies
run: npm ci
- name: Build SDK (required for lint)
run: npm run build -w packages/sdk
- name: Lint
run: npm run lint
- name: Format check
run: npm run format:check
# ---- Tests (pull_request only) ----
test:
name: CI / Test
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install root dependencies
run: npm ci
- name: Build SDK workspace
run: npm run build -w packages/sdk
- name: Test with coverage
run: npm run test:coverage
- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-${{ github.sha }}
path: coverage/
retention-days: 7
- name: Coverage summary
run: |
echo "## Test Coverage" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
cat coverage/coverage-summary.json | node -e "
const d = JSON.parse(require('fs').readFileSync('/dev/stdin','utf8')).total;
console.log('Statements : ' + d.statements.pct + '%');
console.log('Branches : ' + d.branches.pct + '%');
console.log('Functions : ' + d.functions.pct + '%');
console.log('Lines : ' + d.lines.pct + '%');
" || cat coverage/coverage-summary.json
echo '```' >> "$GITHUB_STEP_SUMMARY"
# ---- TypeScript check (pull_request only) ----
typecheck:
name: CI / TypeScript
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install root dependencies
run: npm ci
- name: Build SDK (required for typecheck)
run: npm run build -w packages/sdk
- name: Type check
run: npm run typecheck
# ---- Security audit ----
security:
name: Security audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install root dependencies
run: npm ci
- name: Security audit
run: npm run audit:ci
# ---- Push-only quality checks (lint + typecheck + tests on main) ----
push-quality:
name: CI / Quality (push)
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install root dependencies
run: npm ci
- name: Build SDK workspace
run: npm run build -w packages/sdk
- name: Type check
run: npm run typecheck
- name: Lint
run: npm run lint
- name: Test with coverage
run: npm run test:coverage
# ---- Deploy to Vercel (pull_request only) ----
deploy-vercel:
name: Deploy to Vercel
runs-on: ubuntu-latest
needs: [build-runtime, typecheck]
if: github.event_name == 'pull_request'
environment:
name: pr-preview
url: ${{ steps.deploy.outputs.preview-url }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: dist-ci-${{ github.sha }}
path: dist/
- name: Install WebUI dependencies
run: cd web && npm ci
- name: Build WebUI
run: cd web && npm run build
- name: Deploy to Vercel
id: deploy
uses: amondnet/vercel-action@v25
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
working-directory: ./web
scope: ${{ secrets.VERCEL_ORG_ID }}
continue-on-error: true
- name: Skip note (no Vercel secrets)
if: steps.deploy.outcome == 'skipped' || steps.deploy.outcome == 'failure'
run: echo "Vercel deploy skipped — VERCEL_TOKEN / VERCEL_ORG_ID / VERCEL_PROJECT_ID secrets not configured"