-
-
Notifications
You must be signed in to change notification settings - Fork 19
221 lines (186 loc) · 6.23 KB
/
build.yml
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
name: Build & Test
on:
push:
branches: [main]
pull_request:
concurrency:
group: ${{ github.ref_name || github.sha }}
cancel-in-progress: true
defaults:
run:
shell: bash
env:
BUILD_CACHE_KEY: ${{ github.sha }}
CACHED_BUILD_PATHS: |
${{ github.workspace }}/packages/*/dist
${{ github.workspace }}/packages/*/dist-bin
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
cache: 'pnpm'
- 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.28.0/apple-codesign-0.28.0-x86_64-unknown-linux-musl.tar.gz' | tar -xz --strip-components=1
mv rcodesign /usr/local/bin/rcodesign
# 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
echo 'APPLE_API_KEY_PATH=/tmp/apple_key.json' >> $GITHUB_ENV
- name: Build packages
env:
BUILD_PLATFORMS: 'linux-x64,linux-arm64,win-x64,darwin-x64,darwin-arm64'
APPLE_CERT_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.TEAMID }}
run: pnpm build
- 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: Store Spotlight CJS
uses: actions/upload-artifact@v4
with:
name: spotlight-cjs
if-no-files-found: error
path: |
packages/spotlight/dist/spotlight.cjs
packages/spotlight/dist/overlay/
- name: Store standalone spotlight binaries
uses: actions/upload-artifact@v4
with:
name: spotlight
if-no-files-found: error
path: packages/spotlight/dist-bin/spotlight-*
- name: Update build cache
uses: actions/cache/save@v4
with:
enableCrossOsArchive: true
path: ${{ env.CACHED_BUILD_PATHS }}
key: ${{ env.BUILD_CACHE_KEY }}
test-unit:
name: Unit Tests
runs-on: ubuntu-latest
strategy:
matrix:
node_version: [18, 20, 22]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}
cache: 'pnpm'
- name: Setup dependencies
run: pnpm install
- name: Run tests
run: pnpm test
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: success() || failure()
with:
report_paths: '**/junit.xml'
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
test-e2e:
name: E2E Tests
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
node_version: [18, 20, 22]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}
cache: 'pnpm'
- name: Setup dependencies
run: pnpm install
- name: Restore build cache
uses: actions/cache/restore@v4
with:
enableCrossOsArchive: true
fail-on-cache-miss: true
path: ${{ env.CACHED_BUILD_PATHS }}
key: ${{ env.BUILD_CACHE_KEY }}
- name: Test Demos
run: pnpm test:demos
- name: Run tests
run: pnpm test:e2e
docker:
name: Docker Image
needs: build
runs-on: ubuntu-latest
if: |
!cancelled()
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Restore build cache
uses: actions/cache/restore@v4
with:
enableCrossOsArchive: true
fail-on-cache-miss: true
path: ${{ env.CACHED_BUILD_PATHS }}
key: ${{ env.BUILD_CACHE_KEY }}
- 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: linux/amd64,linux/arm64
push: true
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"