-
-
Notifications
You must be signed in to change notification settings - Fork 32
435 lines (369 loc) · 14.3 KB
/
build.yml
File metadata and controls
435 lines (369 loc) · 14.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
422
423
424
425
426
427
428
429
430
431
432
433
434
435
name: Build & Test
on:
push:
branches:
- main
- "release/**"
pull_request:
concurrency:
group: ${{ github.ref_name || github.sha }}
cancel-in-progress: true
defaults:
run:
shell: bash
env:
TURBO_TELEMETRY_MESSAGE_DISABLED: 1
permissions:
contents: read
packages: write
checks: write
pull-requests: write # Required for posting/updating PR comments
jobs:
build:
name: Build
runs-on: ubuntu-latest
environment: ${{ github.event_name == 'push' && (github.ref_name == 'main' || startsWith(github.ref_name, 'release/')) && 'Production' || 'Preview' }}
outputs:
playwright-version: ${{ steps.playwright-version.outputs.version }}
steps:
- uses: actions/checkout@v6
- name: Cache turbo build setup
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Set up Node
uses: actions/setup-node@v6
with:
node-version-file: "package.json"
cache: "pnpm"
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent | tr -d '\n\r')" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Setup NPM dependencies
run: pnpm install
- name: Setup Codesign Dependencies
env:
APPLE_CERT_DATA: ${{ secrets.CSC_LINK }}
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
run: |
curl -L 'https://github.com/indygreg/apple-platform-rs/releases/download/apple-codesign%2F0.29.0/apple-codesign-0.29.0-x86_64-unknown-linux-musl.tar.gz' -o 'rcodesign.tar.gz'
echo 'dbe85cedd8ee4217b64e9a0e4c2aef92ab8bcaaa41f20bde99781ff02e600002 rcodesign.tar.gz' | sha256sum -c
tar -xzf rcodesign.tar.gz --strip-components=1
mv rcodesign /usr/local/bin/rcodesign
rm rcodesign.tar.gz
# Export certs
echo "$APPLE_CERT_DATA" | base64 --decode > /tmp/certs.p12
echo 'APPLE_CERT_PATH=/tmp/certs.p12' >> $GITHUB_ENV
echo "$APPLE_API_KEY" | base64 -d > /tmp/apple_key.json
cat /tmp/apple_key.json | jq .private_key -r > /tmp/apple_key.pem
echo "APPLE_API_KEY_ISSUER_ID=$(cat /tmp/apple_key.json | jq .issuer_id -r | tr -d '\n\r')" >> $GITHUB_ENV
echo "APPLE_API_KEY_ID=$(cat /tmp/apple_key.json | jq .key_id -r | tr -d '\n\r')" >> $GITHUB_ENV
echo "APPLE_API_KEY_P8_PATH=/tmp/apple_key.pem" >> $GITHUB_ENV
echo 'APPLE_API_KEY_PATH=/tmp/apple_key.json' >> $GITHUB_ENV
- name: Setup Sentry Environment Variables
env:
MAIN_VITE_SENTRY_ORG: ${{ vars.MAIN_VITE_SENTRY_ORG }}
MAIN_VITE_SENTRY_PROJECT: ${{ vars.MAIN_VITE_SENTRY_PROJECT }} # Electron App
MAIN_VITE_UI_SENTRY_PROJECT: ${{ vars.MAIN_VITE_UI_SENTRY_PROJECT }} # Spotlight UI
MAIN_VITE_SENTRY_AUTH_TOKEN: ${{ secrets.MAIN_VITE_SENTRY_AUTH_TOKEN }}
run: |
echo "MAIN_VITE_SENTRY_ORG=$MAIN_VITE_SENTRY_ORG" >> $GITHUB_ENV
echo "MAIN_VITE_SENTRY_PROJECT=$MAIN_VITE_SENTRY_PROJECT" >> $GITHUB_ENV
echo "MAIN_VITE_UI_SENTRY_PROJECT=$MAIN_VITE_UI_SENTRY_PROJECT" >> $GITHUB_ENV
echo "MAIN_VITE_SENTRY_AUTH_TOKEN=$MAIN_VITE_SENTRY_AUTH_TOKEN" >> $GITHUB_ENV
- name: Build packages
env:
APPLE_CERT_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
APPLE_TEAM_ID: ${{ vars.TEAMID }}
FOSSILIZE_PLATFORMS: linux-x64,linux-arm64,win-x64,darwin-x64,darwin-arm64
FOSSILIZE_SIGN: ${{ github.event_name == 'push' && (github.ref_name == 'main' || startsWith(github.ref_name, 'release/')) && 'y' || 'n' }}
run: pnpm build
- name: Checking npx
run: npx ./packages/spotlight --help
- name: Smoke test
env:
SPOTLIGHT_BINARY: ${{ github.workspace }}/packages/spotlight/dist-bin/spotlight-${{ runner.os }}-${{ runner.arch }}
run: |
# Lowercase the binary name because `runner.os` and `runner.arch` are uppercase :facepalm:
SPOTLIGHT_BINARY=$(echo "$SPOTLIGHT_BINARY" | tr '[:upper:]' '[:lower:]')
[ -f "$SPOTLIGHT_BINARY" ]
$SPOTLIGHT_BINARY &
SPOTLIGHT_PID=$!
curl -sf --retry 3 --retry-all-errors -o /dev/null 'http://localhost:8969/' && echo "Spotlight ran successfully"
kill -2 $SPOTLIGHT_PID
- name: Pack npm package
working-directory: packages/spotlight
run: pnpm pack
- name: Store built packages
uses: actions/upload-artifact@v5
with:
name: built-packages
if-no-files-found: error
include-hidden-files: true
path: |
packages/spotlight/dist/
- name: Store npm package
uses: actions/upload-artifact@v5
with:
name: npm-package
if-no-files-found: error
path: packages/spotlight/*.tgz
- name: Store standalone spotlight binaries
uses: actions/upload-artifact@v5
with:
name: spotlight-binaries
if-no-files-found: error
path: packages/spotlight/dist-bin/spotlight-*
- name: Store Electron build
uses: actions/upload-artifact@v5
with:
name: electron-build
if-no-files-found: error
include-hidden-files: true
path: packages/spotlight/dist-electron/
# This will be used for the base image name in e2e tests below
# which depends on the build job, hence why we do this here
- name: Playwright Version
id: playwright-version
working-directory: packages/spotlight
run: |
# Playwright outputs something like `Version 1.54.2` so we cut the "crap" at the beginning
echo "version=$(pnpm exec playwright --version | cut -c 9-)" >> $GITHUB_OUTPUT
test-unit:
name: Unit Tests
runs-on: ubuntu-latest
strategy:
matrix:
node_version: [20, 22, 24]
steps:
- uses: actions/checkout@v6
- name: Cache turbo build setup
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Set up Node
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node_version }}
cache: "pnpm"
- name: Setup dependencies
run: pnpm install
- name: Run tests
run: pnpm -r test
- name: Publish Test Report
uses: mikepenz/action-junit-report@cf701569b05ccdd861a76b8607a66d76f6fd4857
if: ${{ !cancelled() }}
with:
report_paths: "**/junit.xml"
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: getsentry/codecov-action@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
post-pr-comment: true
test-e2e-cli:
name: E2E CLI Tests
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
node_version: [20, 22, 24]
steps:
- uses: actions/checkout@v6
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Set up Node
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node_version }}
cache: "pnpm"
- name: Setup dependencies
run: pnpm install
- name: Clean dist directory before downloading artifacts
run: rm -rf packages/spotlight/dist/
- name: Download Spotlight build
uses: actions/download-artifact@v5
with:
name: built-packages
path: packages/spotlight/dist/
- name: Run CLI E2E tests
working-directory: packages/spotlight
run: pnpm test:e2e:cli
test-e2e-ui:
name: E2E UI Tests
needs: build
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v${{needs.build.outputs.playwright-version}}-noble
options: --user 1001
steps:
- uses: actions/checkout@v6
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Set up Node
uses: actions/setup-node@v6
with:
node-version: 24
cache: "pnpm"
- name: Setup dependencies
run: pnpm install
- name: Clean dist directories before downloading artifacts
run: |
rm -rf packages/spotlight/dist/
rm -rf packages/spotlight/dist-electron/
- name: Download Spotlight build
uses: actions/download-artifact@v5
with:
name: built-packages
path: packages/spotlight/dist/
- name: Download Electron build
uses: actions/download-artifact@v5
with:
name: electron-build
path: packages/spotlight/dist-electron/
- name: Run UI E2E tests
working-directory: packages/spotlight
run: pnpm test:e2e:ui
- name: Test results
if: always()
uses: actions/upload-artifact@v5
with:
name: test-results-ui
path: packages/spotlight/test-results/**
docker:
name: Docker Image
needs: build
runs-on: ubuntu-latest
if: |
!cancelled()
env:
MULTI_ARCH_BUILD: ${{ ((github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push') && github.actor != 'dependabot[bot]') && 'true' || 'false' }}
steps:
- uses: actions/checkout@v6
- name: Download spotlight binaries
uses: actions/download-artifact@v5
with:
name: spotlight-binaries
path: packages/spotlight/dist-bin/
- name: Rename x64 to amd64
# This is because Node ecosystem uses x64, but Docker uses amd64 :shrug:
run: mv packages/spotlight/dist-bin/spotlight-linux-x64 packages/spotlight/dist-bin/spotlight-linux-amd64
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup QEMU for cross-compilation
uses: docker/setup-qemu-action@v3
- name: Configure Docker Context
uses: docker/setup-buildx-action@v3
- name: Build Docker Image
uses: docker/build-push-action@v5
with:
context: .
cache-from: type=gha,scope=prod
cache-to: type=gha,mode=max,scope=prod
platforms: ${{ env.MULTI_ARCH_BUILD == 'true' && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
push: ${{ env.MULTI_ARCH_BUILD }}
load: ${{ env.MULTI_ARCH_BUILD == 'false' }}
tags: ghcr.io/getsentry/spotlight:${{ github.sha }}
- name: Test Docker Image
run: |
docker run --rm -d -p 8969:8969 ghcr.io/getsentry/spotlight:${{ github.sha }}
curl -sf --retry 3 --retry-all-errors -o /dev/null 'http://localhost:8969/' && echo "Spotlight ran successfully"
electron-mac:
name: Build Electron App (macOS)
needs: build
runs-on: macos-latest
if: github.event_name == 'push' && (github.ref_name == 'main' || startsWith(github.ref_name, 'release/'))
environment: Production
steps:
- name: Checkout Repo
uses: actions/checkout@v6
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Set up Node
uses: actions/setup-node@v6
with:
node-version-file: "package.json"
cache: "pnpm"
- name: Setup dependencies
run: pnpm install
- name: Download Electron build
uses: actions/download-artifact@v5
with:
name: electron-build
path: packages/spotlight/dist-electron/
- name: Validate Electron build files
run: |
if [ ! -d "packages/spotlight/dist-electron/main" ] || [ ! -d "packages/spotlight/dist-electron/renderer" ]; then
echo "Error: Expected directories not found in artifact"
ls -la packages/spotlight/dist-electron/
exit 1
fi
echo "Electron build files validated successfully"
- name: Setup Apple API Key for Notarization
env:
APPLE_API_KEY_BUNDLE: ${{ secrets.APPLE_API_KEY }}
run: |
echo "$APPLE_API_KEY_BUNDLE" | base64 -d > /tmp/apple_key.json
cat /tmp/apple_key.json | jq .private_key -r > /tmp/apple_key.pem
echo "APPLE_API_ISSUER=$(cat /tmp/apple_key.json | jq .issuer_id -r | tr -d '\n\r')" >> $GITHUB_ENV
echo "APPLE_API_KEY_ID=$(cat /tmp/apple_key.json | jq .key_id -r | tr -d '\n\r')" >> $GITHUB_ENV
echo "APPLE_API_KEY=/tmp/apple_key.pem" >> $GITHUB_ENV
- name: Build and Sign Electron App
env:
MAIN_VITE_SENTRY_ORG: ${{ vars.MAIN_VITE_SENTRY_ORG }}
MAIN_VITE_SENTRY_PROJECT: ${{ vars.MAIN_VITE_SENTRY_PROJECT }}
MAIN_VITE_SENTRY_AUTH_TOKEN: ${{ secrets.MAIN_VITE_SENTRY_AUTH_TOKEN }}
CSC_LINK: ${{ secrets.CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: packages/spotlight
run: pnpm build:mac
- name: Store Electron binaries
uses: actions/upload-artifact@v5
with:
name: electron-binaries
if-no-files-found: error
path: |
packages/spotlight/dist-electron/*.dmg
packages/spotlight/dist-electron/*.zip
packages/spotlight/dist-electron/*.blockmap
packages/spotlight/dist-electron/*.yml
merge-artifacts:
name: Merge Artifacts
needs: [build, electron-mac]
if: always() && needs.build.result == 'success' && needs.electron-mac.result == 'success'
runs-on: ubuntu-latest
steps:
- name: Download release artifacts
uses: actions/download-artifact@v5
with:
pattern: '{npm-package,spotlight-binaries,electron-binaries}'
path: artifacts/
merge-multiple: true
- name: Upload merged artifact
uses: actions/upload-artifact@v5
with:
name: ${{ github.sha }}
path: artifacts/