-
Notifications
You must be signed in to change notification settings - Fork 123
421 lines (354 loc) · 13.3 KB
/
release-dev.yml
File metadata and controls
421 lines (354 loc) · 13.3 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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
---
name: Dev Pre-release
"on":
push:
branches:
- dev
workflow_dispatch:
concurrency:
group: dev-prerelease
cancel-in-progress: true
jobs:
security-scan:
name: Security Scan (Trivy)
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Install git-crypt
run: sudo apt-get update && sudo apt-get install -y git-crypt
- name: Unlock repository
env:
GIT_CRYPT_KEY: ${{ secrets.GIT_CRYPT_KEY }}
run: bash .github/workflows/scripts/setup-git-crypt.sh
- name: Run Trivy filesystem scan
uses: aquasecurity/trivy-action@b6643a29fecd7f34b3597bc6acb0a98b03d33ff8 # 0.33.1
with:
scan-type: "fs"
scan-ref: "."
scanners: "vuln,secret"
severity: "CRITICAL,HIGH"
exit-code: "1"
ignore-unfixed: true
skip-dirs: ".venv,node_modules,console/node_modules,launcher,docs/site/api,console"
trivyignores: ".trivyignore"
format: "table"
output: trivy-results.txt
- name: Publish Trivy results to step summary
if: always()
run: |
if [[ -s trivy-results.txt ]]; then
{
echo "### Security Scan Results"
echo "<details><summary>Click to expand Trivy output</summary>"
echo ""
echo '```'
cat trivy-results.txt
echo '```'
echo "</details>"
} >> $GITHUB_STEP_SUMMARY
else
echo "### Security Scan: No issues found" >> $GITHUB_STEP_SUMMARY
fi
# All jobs run in parallel for maximum speed
python-tests:
name: Python Unit Tests
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Install git-crypt
run: sudo apt-get update && sudo apt-get install -y git-crypt
- name: Unlock repository
env:
GIT_CRYPT_KEY: ${{ secrets.GIT_CRYPT_KEY }}
run: bash .github/workflows/scripts/setup-git-crypt.sh
- name: Set up Python 3.12
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: "3.12"
- name: Install Python dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install . pytest pytest-cov pytest-asyncio
- name: Run unit tests with coverage
run: |
python3 -m pytest installer/tests/unit/ launcher/tests/unit/ -v \
--cov=installer --cov=launcher \
--cov-report=term --cov-report=xml
console-tests:
name: Console Unit Tests
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Install git-crypt
run: sudo apt-get update && sudo apt-get install -y git-crypt
- name: Unlock repository
env:
GIT_CRYPT_KEY: ${{ secrets.GIT_CRYPT_KEY }}
run: bash .github/workflows/scripts/setup-git-crypt.sh
- name: Setup Bun
uses: oven-sh/setup-bun@3d267786b128fe76c2f16a390aa2448b815359f3 # v2
with:
bun-version: latest
- name: Install dependencies
working-directory: console
run: bun install
- name: Run console tests
working-directory: console
run: bun test
console-build:
name: Console Build & Typecheck
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Install git-crypt
run: sudo apt-get update && sudo apt-get install -y git-crypt
- name: Unlock repository
env:
GIT_CRYPT_KEY: ${{ secrets.GIT_CRYPT_KEY }}
run: bash .github/workflows/scripts/setup-git-crypt.sh
- name: Setup Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6
with:
node-version: "22"
- name: Setup Bun
uses: oven-sh/setup-bun@3d267786b128fe76c2f16a390aa2448b815359f3 # v2
with:
bun-version: latest
- name: Install dependencies
working-directory: console
run: bun install
- name: Typecheck
working-directory: console
run: bun run typecheck
- name: Build hooks
working-directory: console
run: bun run build
- name: Build viewer
working-directory: console
run: bun run build:viewer
build-pilot-arm64:
name: Build Pilot Linux arm64
permissions:
contents: read
runs-on: ubuntu-24.04-arm
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Install git-crypt
run: sudo apt-get update && sudo apt-get install -y git-crypt
- name: Unlock repository
env:
GIT_CRYPT_KEY: ${{ secrets.GIT_CRYPT_KEY }}
run: bash .github/workflows/scripts/setup-git-crypt.sh
- name: Generate version
id: version
run: |
COMMIT_SHA="${{ github.event.pull_request.head.sha || github.sha }}"
VERSION="dev-$(echo $COMMIT_SHA | cut -c1-7)-$(date +%Y%m%d)"
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
- name: Build binary
run: |
docker run --rm \
-v ${{ github.workspace }}:/workspace \
-w /workspace \
python:3.12-slim-bullseye \
bash -c "
apt-get update && apt-get install -y binutils build-essential && \
pip install . && \
python -m launcher.build --release --version ${{ steps.version.outputs.VERSION }} && \
ls -la launcher/dist/
"
- name: Upload artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: pilot-linux-arm64
path: |
launcher/dist/pilot-linux-arm64.so
launcher/dist/pilot
retention-days: 1
build-pilot-darwin-arm64:
name: Build Pilot Darwin arm64
permissions:
contents: read
runs-on: macos-14
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Install git-crypt
run: brew install git-crypt
- name: Unlock repository
env:
GIT_CRYPT_KEY: ${{ secrets.GIT_CRYPT_KEY }}
run: bash .github/workflows/scripts/setup-git-crypt.sh
- name: Set up Python 3.12
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: "3.12"
- name: Cache pip dependencies
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5
with:
path: ~/Library/Caches/pip
key: ${{ runner.os }}-pip-pyinstaller
restore-keys: ${{ runner.os }}-pip-
- name: Generate version
id: version
run: |
COMMIT_SHA="${{ github.event.pull_request.head.sha || github.sha }}"
VERSION="dev-$(echo $COMMIT_SHA | cut -c1-7)-$(date +%Y%m%d)"
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
- name: Build binary
run: |
pip install .
python -m launcher.build --release --version ${{ steps.version.outputs.VERSION }}
ls -la launcher/dist/
- name: Upload artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: pilot-darwin-arm64
path: launcher/dist/pilot-darwin-arm64.so
retention-days: 1
publish-prerelease:
name: Publish Pre-release
permissions:
contents: write
runs-on: ubuntu-latest
needs:
- security-scan
- python-tests
- console-tests
- console-build
- build-pilot-arm64
- build-pilot-darwin-arm64
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Generate version
id: version
run: |
COMMIT_SHA="${{ github.event.pull_request.head.sha || github.sha }}"
VERSION="dev-$(echo $COMMIT_SHA | cut -c1-7)-$(date +%Y%m%d)"
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
echo "COMMIT_SHA=$COMMIT_SHA" >> "$GITHUB_OUTPUT"
echo "Generated version: $VERSION (from commit $COMMIT_SHA)"
- name: Download all artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
path: artifacts
- name: List artifacts
run: |
echo "Downloaded artifacts:"
find artifacts -type f -ls
- name: Generate tree.json manifest
run: |
echo "Generating tree.json from repository files..."
git ls-tree -r HEAD | python3 -c "
import sys, json
items = []
for line in sys.stdin:
parts = line.strip().split('\t', 1)
if len(parts) == 2:
meta, path = parts
fields = meta.split()
if len(fields) == 3:
items.append({'path': path, 'type': 'blob', 'sha': fields[2]})
json.dump({'tree': items}, sys.stdout, separators=(', ', ': '))
" > tree.json
echo "Validating tree.json..."
python3 -c "import json; data=json.load(open('tree.json')); assert 'tree' in data and len(data['tree']) > 0, 'Invalid tree.json'"
echo "tree.json generated successfully with $(python3 -c "import json; print(len(json.load(open('tree.json'))['tree']))") files"
- name: Create pre-release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ steps.version.outputs.VERSION }}"
PR_NUM="${{ github.event.pull_request.number }}"
if [ -n "$PR_NUM" ]; then
NOTES="Pre-release build from PR #${PR_NUM}
**Commit:** ${{ steps.version.outputs.COMMIT_SHA }}
**Branch:** ${{ github.head_ref }}
This is a development pre-release for testing. Not for production use."
else
NOTES="Pre-release build (manual trigger)
**Commit:** ${{ steps.version.outputs.COMMIT_SHA }}
This is a development pre-release for testing. Not for production use."
fi
git tag "$VERSION"
git push origin "$VERSION"
gh release create "$VERSION" \
--title "Dev Pre-release $VERSION" \
--notes "$NOTES" \
--prerelease \
artifacts/pilot-linux-arm64/pilot-linux-arm64.so \
artifacts/pilot-linux-arm64/pilot \
artifacts/pilot-darwin-arm64/pilot-darwin-arm64.so \
tree.json
echo "Pre-release $VERSION created successfully"
- name: Cleanup old pre-releases
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Cleaning up old dev pre-releases (keeping only the latest)..."
gh api repos/${{ github.repository }}/releases \
--jq '[.[] | select(.prerelease and (.tag_name | startswith("dev-")))] | sort_by(.created_at) | reverse | .[1:] | .[].tag_name' \
| while read -r tag; do
if [ -n "$tag" ]; then
echo "Deleting old pre-release: $tag"
gh release delete "$tag" --yes --cleanup-tag || true
fi
done
echo "Cleanup complete"
# Deploy website preview in parallel with other jobs (no approval needed)
deploy-website-preview:
name: Deploy Website (Preview)
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Install git-crypt
run: sudo apt-get update && sudo apt-get install -y git-crypt
- name: Unlock repository
env:
GIT_CRYPT_KEY: ${{ secrets.GIT_CRYPT_KEY }}
run: bash .github/workflows/scripts/setup-git-crypt.sh
- name: Setup Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6
with:
node-version: "22"
- name: Install Vercel CLI
run: npm install -g vercel
- name: Deploy to Vercel (Preview)
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_ORG_ID: team_jAsHrk71vRyWK6bCTYGJyp0q
VERCEL_PROJECT_ID: prj_TXccrJI83HyNvQUZxqStUFgus9NB
run: |
DEPLOY_URL=$(vercel deploy --token=$VERCEL_TOKEN)
echo "Preview deployed to: $DEPLOY_URL"