-
-
Notifications
You must be signed in to change notification settings - Fork 0
286 lines (243 loc) · 10.3 KB
/
pr-tests.yml
File metadata and controls
286 lines (243 loc) · 10.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
name: PR Test Comparison
on:
pull_request:
branches: [main]
# Cancel in-progress runs for the same PR
concurrency:
group: pr-tests-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
test-main:
name: Test (main)
runs-on: ubuntu-latest
steps:
- name: Checkout main branch
uses: actions/checkout@v4
with:
ref: main
submodules: true
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install uv (Python package manager)
uses: astral-sh/setup-uv@v5
- name: Get latest Sentry SDK versions
id: sentry-versions
run: |
echo "js=$(npm view @sentry/node version)" >> $GITHUB_OUTPUT
echo "python=$(curl -s https://pypi.org/pypi/sentry-sdk/json | python3 -c 'import sys,json; print(json.load(sys.stdin)["info"]["version"])')" >> $GITHUB_OUTPUT
echo "php=$(curl -s https://repo.packagist.org/p2/sentry/sentry-laravel.json | python3 -c 'import sys,json; print(json.load(sys.stdin)["packages"]["sentry/sentry-laravel"][0]["version"])')" >> $GITHUB_OUTPUT
- name: Cache Node test environments
uses: actions/cache@v4
with:
path: runs/node
key: node-envs-main-${{ runner.os }}-sentry-${{ steps.sentry-versions.outputs.js }}-${{ hashFiles('src/runner/templates/**/node/**/config.json') }}
restore-keys: |
node-envs-main-${{ runner.os }}-sentry-${{ steps.sentry-versions.outputs.js }}-
- name: Cache Browser test environments
uses: actions/cache@v4
with:
path: runs/browser
key: browser-envs-main-${{ runner.os }}-sentry-${{ steps.sentry-versions.outputs.js }}-${{ hashFiles('src/runner/templates/**/browser/**/config.json') }}
restore-keys: |
browser-envs-main-${{ runner.os }}-sentry-${{ steps.sentry-versions.outputs.js }}-
- name: Cache Next.js test environments
uses: actions/cache@v4
with:
path: runs/nextjs
key: nextjs-envs-main-${{ runner.os }}-sentry-${{ steps.sentry-versions.outputs.js }}-${{ hashFiles('src/runner/templates/**/nextjs/**/config.json') }}
restore-keys: |
nextjs-envs-main-${{ runner.os }}-sentry-${{ steps.sentry-versions.outputs.js }}-
- name: Cache Python test environments
uses: actions/cache@v4
with:
path: runs/python
key: python-envs-main-${{ runner.os }}-sentry-${{ steps.sentry-versions.outputs.python }}-${{ hashFiles('src/runner/templates/**/python/**/config.json') }}
restore-keys: |
python-envs-main-${{ runner.os }}-sentry-${{ steps.sentry-versions.outputs.python }}-
- name: Cache PHP test environments
uses: actions/cache@v4
with:
path: runs/php
key: php-envs-main-${{ runner.os }}-sentry-${{ steps.sentry-versions.outputs.php }}-${{ hashFiles('src/runner/templates/**/php/**/config.json') }}
restore-keys: |
php-envs-main-${{ runner.os }}-sentry-${{ steps.sentry-versions.outputs.php }}-
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.4"
tools: composer
- name: Install dependencies and build
run: |
npm ci
npm run build
- name: Install Playwright browsers (for browser platform only)
run: npx playwright install --with-deps chromium
- name: Run tests
id: run-tests
continue-on-error: true
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
GOOGLE_GENAI_API_KEY: ${{ secrets.GOOGLE_GENAI_API_KEY }}
CO_API_KEY: ${{ secrets.CO_API_KEY }}
run: npm run test -- -j=12
- name: Upload CTRF report
uses: actions/upload-artifact@v4
with:
name: ctrf-main
path: test-results/ctrf-report-*.json
retention-days: 1
test-pr:
name: Test (PR)
runs-on: ubuntu-latest
steps:
- name: Checkout PR branch
uses: actions/checkout@v4
with:
submodules: true
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install uv (Python package manager)
uses: astral-sh/setup-uv@v5
- name: Get latest Sentry SDK versions
id: sentry-versions
run: |
echo "js=$(npm view @sentry/node version)" >> $GITHUB_OUTPUT
echo "python=$(curl -s https://pypi.org/pypi/sentry-sdk/json | python3 -c 'import sys,json; print(json.load(sys.stdin)["info"]["version"])')" >> $GITHUB_OUTPUT
echo "php=$(curl -s https://repo.packagist.org/p2/sentry/sentry-laravel.json | python3 -c 'import sys,json; print(json.load(sys.stdin)["packages"]["sentry/sentry-laravel"][0]["version"])')" >> $GITHUB_OUTPUT
- name: Cache Node test environments
uses: actions/cache@v4
with:
path: runs/node
key: node-envs-pr-${{ runner.os }}-sentry-${{ steps.sentry-versions.outputs.js }}-${{ hashFiles('src/runner/templates/**/node/**/config.json') }}
restore-keys: |
node-envs-pr-${{ runner.os }}-sentry-${{ steps.sentry-versions.outputs.js }}-
- name: Cache Browser test environments
uses: actions/cache@v4
with:
path: runs/browser
key: browser-envs-pr-${{ runner.os }}-sentry-${{ steps.sentry-versions.outputs.js }}-${{ hashFiles('src/runner/templates/**/browser/**/config.json') }}
restore-keys: |
browser-envs-pr-${{ runner.os }}-sentry-${{ steps.sentry-versions.outputs.js }}-
- name: Cache Next.js test environments
uses: actions/cache@v4
with:
path: runs/nextjs
key: nextjs-envs-pr-${{ runner.os }}-sentry-${{ steps.sentry-versions.outputs.js }}-${{ hashFiles('src/runner/templates/**/nextjs/**/config.json') }}
restore-keys: |
nextjs-envs-pr-${{ runner.os }}-sentry-${{ steps.sentry-versions.outputs.js }}-
- name: Cache Python test environments
uses: actions/cache@v4
with:
path: runs/python
key: python-envs-pr-${{ runner.os }}-sentry-${{ steps.sentry-versions.outputs.python }}-${{ hashFiles('src/runner/templates/**/python/**/config.json') }}
restore-keys: |
python-envs-pr-${{ runner.os }}-sentry-${{ steps.sentry-versions.outputs.python }}-
- name: Cache PHP test environments
uses: actions/cache@v4
with:
path: runs/php
key: php-envs-pr-${{ runner.os }}-sentry-${{ steps.sentry-versions.outputs.php }}-${{ hashFiles('src/runner/templates/**/php/**/config.json') }}
restore-keys: |
php-envs-pr-${{ runner.os }}-sentry-${{ steps.sentry-versions.outputs.php }}-
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.4"
tools: composer
- name: Install dependencies and build
run: |
npm ci
npm run build
- name: Install Playwright browsers (for browser platform only)
run: npx playwright install --with-deps chromium
- name: Run tests
id: run-tests
continue-on-error: true
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
GOOGLE_GENAI_API_KEY: ${{ secrets.GOOGLE_GENAI_API_KEY }}
CO_API_KEY: ${{ secrets.CO_API_KEY }}
run: npm run test -- -j=12
- name: Upload CTRF report
uses: actions/upload-artifact@v4
with:
name: ctrf-pr
path: test-results/ctrf-report-*.json
retention-days: 1
compare-results:
name: Compare Results
needs: [test-main, test-pr]
runs-on: ubuntu-latest
if: always() && needs.test-main.result != 'cancelled' && needs.test-pr.result != 'cancelled'
steps:
- name: Checkout PR branch
uses: actions/checkout@v4
- name: Download main CTRF report
uses: actions/download-artifact@v4
with:
name: ctrf-main
path: ctrf-main
- name: Download PR CTRF report
uses: actions/download-artifact@v4
with:
name: ctrf-pr
path: ctrf-pr
- name: Run comparison
id: compare
run: |
# Find the latest CTRF reports (they have timestamps in filename)
MAIN_REPORT=$(ls -t ctrf-main/ctrf-report-*.json 2>/dev/null | head -1)
PR_REPORT=$(ls -t ctrf-pr/ctrf-report-*.json 2>/dev/null | head -1)
if [ -z "$MAIN_REPORT" ] || [ -z "$PR_REPORT" ]; then
echo "Missing CTRF reports"
echo "Main: $MAIN_REPORT"
echo "PR: $PR_REPORT"
exit 1
fi
node .github/scripts/compare-ctrf.cjs \
"$MAIN_REPORT" \
"$PR_REPORT" \
comparison-output.md
# Check if there are regressions
if grep -q "^HAS_REGRESSIONS=true$" comparison-output.env 2>/dev/null; then
echo "has_regressions=true" >> $GITHUB_OUTPUT
else
echo "has_regressions=false" >> $GITHUB_OUTPUT
fi
- name: Write job summary
run: cat comparison-output.md >> $GITHUB_STEP_SUMMARY
- name: Find existing comment
uses: peter-evans/find-comment@v3
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: "AI SDK Integration Test Results"
- name: Create or update PR comment
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
edit-mode: replace
body-path: comparison-output.md
- name: Fail if regressions
if: steps.compare.outputs.has_regressions == 'true'
run: |
echo "::error::Test regressions detected! Tests that were passing on main are now failing."
exit 1