Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

main.yml 10 KB

You have to be logged in to leave a comment. Sign In
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
  1. name: CI
  2. on:
  3. pull_request:
  4. push:
  5. branches:
  6. - main
  7. workflow_dispatch:
  8. permissions:
  9. contents: read
  10. pull-requests: read
  11. checks: write
  12. concurrency:
  13. group: ${{ github.workflow }}-${{ github.ref }}
  14. cancel-in-progress: ${{ github.event_name == 'pull_request' }}
  15. env:
  16. VITE_TELEMETRY_DISABLED: 1
  17. jobs:
  18. test:
  19. name: Test on Node ${{ matrix.node }} and ${{ matrix.os }}
  20. timeout-minutes: 8
  21. runs-on: ${{ matrix.os }}
  22. strategy:
  23. fail-fast: false
  24. matrix:
  25. node: ['18.x', '20.x', '22.x', '24.x']
  26. os: [ubuntu-latest, windows-latest, macOS-latest]
  27. exclude:
  28. # Remove when https://github.com/nodejs/node/issues/51766 is resolved
  29. - node: '22.x'
  30. os: windows-latest
  31. - node: '24.x'
  32. os: windows-latest
  33. steps:
  34. - name: Checkout repo
  35. uses: actions/checkout@v4
  36. - name: Use Node ${{ matrix.node }}
  37. uses: actions/setup-node@v4
  38. with:
  39. node-version: ${{ matrix.node }}
  40. cache: 'npm'
  41. - name: Use Python 3.13
  42. uses: actions/setup-python@v5
  43. with:
  44. python-version: 3.13
  45. - name: Install Dependencies
  46. run: |
  47. npm ci
  48. - name: Test
  49. run: npm run test -- --ci
  50. build:
  51. name: Build on Node ${{ matrix.node }}
  52. env:
  53. PROMPTFOO_POSTHOG_KEY: ${{ secrets.PROMPTFOO_POSTHOG_KEY }}
  54. timeout-minutes: 5
  55. runs-on: ubuntu-latest
  56. strategy:
  57. matrix:
  58. node: ['18.x', '20.x', '22.x', '24.x']
  59. steps:
  60. - name: Checkout repo
  61. uses: actions/checkout@v4
  62. - name: Use Node ${{ matrix.node }}
  63. uses: actions/setup-node@v4
  64. with:
  65. node-version: ${{ matrix.node }}
  66. cache: 'npm'
  67. - name: Install Dependencies
  68. run: npm ci
  69. - name: Build
  70. run: npm run build
  71. - name: Check Telemetry
  72. run: |
  73. # Skip PostHog key check for forks as they don't have access to secrets
  74. if [[ "${{ github.event_name }}" == "pull_request" ]] && [[ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]]; then
  75. echo "Skipping PostHog key check for fork PR"
  76. elif [[ -z "$PROMPTFOO_POSTHOG_KEY" ]]; then
  77. echo "PostHog key not available (running without secret), skipping check"
  78. else
  79. if ! grep -q "exports\.POSTHOG_KEY = 'phc_" dist/src/generated-constants.js; then
  80. echo "Error: PostHog key not properly replaced in generated-constants.js"
  81. echo "Content of generated-constants.js:"
  82. cat dist/src/generated-constants.js
  83. exit 1
  84. fi
  85. echo "PostHog key replacement verified successfully"
  86. fi
  87. style-check:
  88. name: Style Check
  89. timeout-minutes: 5
  90. runs-on: ubuntu-latest
  91. steps:
  92. - name: Checkout repo
  93. uses: actions/checkout@v4
  94. - name: Use Node
  95. uses: actions/setup-node@v4
  96. with:
  97. node-version-file: '.nvmrc'
  98. cache: 'npm'
  99. - name: Install Dependencies
  100. run: |
  101. npm ci
  102. - name: Lint Project
  103. run: |
  104. npm run lint
  105. - name: Lint UI
  106. working-directory: src/app
  107. run: |
  108. npm run lint
  109. - name: Run Style Check
  110. run: |
  111. npm run format:check
  112. - name: Check Dependency Versions
  113. run: |
  114. npx check-dependency-version-consistency
  115. - name: Check for circular dependencies
  116. run: |
  117. # shellcheck disable=SC2046
  118. npx madge $(git ls-files '*.ts') --circular
  119. shell-format:
  120. name: Shell Format Check
  121. timeout-minutes: 5
  122. runs-on: ubuntu-latest
  123. steps:
  124. - uses: actions/checkout@v4
  125. - uses: luizm/action-sh-checker@17bd25a6ee188d2b91f677060038f4ba37ba14b2
  126. env:
  127. SHFMT_OPTS: '-i 2' # 2 space indent
  128. with:
  129. sh_checker_shellcheck_disable: true
  130. assets:
  131. name: Generate Assets
  132. timeout-minutes: 5
  133. runs-on: ubuntu-latest
  134. steps:
  135. - name: Checkout repo
  136. uses: actions/checkout@v4
  137. - name: Use Node
  138. uses: actions/setup-node@v4
  139. with:
  140. node-version-file: '.nvmrc'
  141. cache: 'npm'
  142. - name: Install Dependencies
  143. run: npm install
  144. - name: Generate JSON Schema
  145. run: npm run jsonSchema:generate
  146. - name: Check for changes
  147. run: |
  148. if [[ -n $(git status --porcelain) ]]; then
  149. echo "Changes detected after generating assets:"
  150. git status --porcelain
  151. exit 1
  152. else
  153. echo "No changes detected."
  154. fi
  155. python:
  156. name: Check Python
  157. timeout-minutes: 5
  158. runs-on: ubuntu-latest
  159. strategy:
  160. matrix:
  161. python-version: [3.9, 3.13]
  162. steps:
  163. - name: Checkout repo
  164. uses: actions/checkout@v4
  165. - name: Use Python ${{ matrix.python-version }}
  166. uses: actions/setup-python@v5
  167. with:
  168. python-version: ${{ matrix.python-version }}
  169. - name: Install Dependencies
  170. run: |
  171. pip install ruff
  172. - name: Check Formatting
  173. run: |
  174. ruff check --select I --fix
  175. ruff format
  176. git diff --exit-code || (echo "Files were modified by ruff. Please commit these changes." && exit 1)
  177. - name: Run Tests
  178. run: |
  179. python -m unittest discover -s src/python -p '*_test.py'
  180. docs:
  181. name: Build Docs
  182. timeout-minutes: 5
  183. runs-on: ubuntu-latest
  184. steps:
  185. - name: Checkout repo
  186. uses: actions/checkout@v4
  187. - name: Use Node
  188. uses: actions/setup-node@v4
  189. with:
  190. node-version-file: '.nvmrc'
  191. cache: 'npm'
  192. - name: Install Dependencies
  193. working-directory: site
  194. run: npm install
  195. - name: Type Check
  196. working-directory: site
  197. run: npm run typecheck
  198. - name: Build Documentation
  199. working-directory: site
  200. run: npm run build
  201. webui:
  202. name: webui tests
  203. timeout-minutes: 5
  204. runs-on: ubuntu-latest
  205. steps:
  206. - name: Checkout repo
  207. uses: actions/checkout@v4
  208. - name: Use Node
  209. uses: actions/setup-node@v4
  210. with:
  211. node-version-file: '.nvmrc'
  212. cache: 'npm'
  213. - name: Install Dependencies
  214. run: npm ci
  215. - name: Run App Tests
  216. run: npm run test:app
  217. integration-tests:
  218. name: Run Integration Tests
  219. runs-on: ubuntu-latest
  220. timeout-minutes: 5
  221. steps:
  222. - name: Checkout repo
  223. uses: actions/checkout@v4
  224. - name: Use Node
  225. uses: actions/setup-node@v4
  226. with:
  227. node-version-file: '.nvmrc'
  228. cache: 'npm'
  229. - name: Use Python 3.13
  230. uses: actions/setup-python@v5
  231. with:
  232. python-version: 3.13
  233. - name: Install Dependencies
  234. run: |
  235. npm ci
  236. - name: Run Integration Tests
  237. run: npm run test:integration -- --ci --coverage --maxWorkers=2
  238. share-test:
  239. name: Share Test
  240. if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
  241. runs-on: ubuntu-latest
  242. permissions:
  243. contents: read
  244. steps:
  245. - name: Checkout repo
  246. uses: actions/checkout@v4
  247. - name: Install Dependencies
  248. run: npm ci
  249. - name: Run local server
  250. run: |
  251. npm run build
  252. PROMPTFOO_CONFIG_DIR=~/tmp LOG_LEVEL=DEBUG API_PORT=8500 node dist/src/server/index.js &
  253. - name: run promptfoo eval
  254. id: eval
  255. run: |
  256. PROMPTFOO_REMOTE_API_BASE_URL=http://localhost:8500 PROMPTFOO_SHARING_APP_BASE_URL=http://localhost:8500 node dist/src/main.js eval -c .github/assets/promptfooconfig.yaml --share
  257. env:
  258. PROMPTFOO_DISABLE_TELEMETRY: 1
  259. - name: Test that the eval results are uploaded
  260. run: |
  261. response=$(curl -s http://localhost:8500/api/results)
  262. echo "Response: $response"
  263. # Use jq to extract the array length
  264. count=$(echo "$response" | jq '.data | length')
  265. echo "Array Length: $count"
  266. # Check if the count is exactly 1
  267. if [ "$count" -ne 1 ]; then
  268. echo "Error: Expected 1 entry, but got $count"
  269. exit 1
  270. fi
  271. - name: Share to cloud
  272. if: env.PROMPTFOO_STAGING_API_KEY != ''
  273. env:
  274. PROMPTFOO_STAGING_API_KEY: ${{ secrets.PROMPTFOO_STAGING_API_KEY }}
  275. run: |
  276. node dist/src/main.js auth login -k ${{ secrets.PROMPTFOO_STAGING_API_KEY }} -h https://api.promptfoo-staging.app
  277. node dist/src/main.js eval -c .github/assets/promptfooconfig.yaml --share
  278. redteam:
  279. name: Redteam
  280. runs-on: ubuntu-latest
  281. steps:
  282. - name: Checkout repo
  283. uses: actions/checkout@v4
  284. - name: Install Dependencies
  285. run: npm ci
  286. - name: Run Redteam
  287. run: |
  288. npm run test:redteam:integration
  289. redteam-custom-enterprise-server:
  290. name: Redteam Custom Enterprise Server
  291. if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
  292. runs-on: ubuntu-latest
  293. permissions:
  294. contents: read
  295. steps:
  296. - name: Checkout repo
  297. uses: actions/checkout@v4
  298. - name: Install Dependencies
  299. run: npm ci
  300. # Need to build first so we can login
  301. - name: Build
  302. run: |
  303. npm run build
  304. - name: Login
  305. if: env.PROMPTFOO_INTEGRATION_TEST_API_KEY != ''
  306. env:
  307. PROMPTFOO_INTEGRATION_TEST_API_KEY: ${{ secrets.PROMPTFOO_INTEGRATION_TEST_API_KEY }}
  308. run: |
  309. npm run bin auth login -- -k ${{ secrets.PROMPTFOO_INTEGRATION_TEST_API_KEY }} -h ${{ secrets.PROMPTFOO_INTEGRATION_TEST_API_HOST }}
  310. - name: Run Redteam
  311. run: |
  312. npm run test:redteam:integration
  313. actionlint:
  314. name: GitHub Actions Lint
  315. runs-on: ubuntu-latest
  316. timeout-minutes: 5
  317. permissions:
  318. contents: read
  319. steps:
  320. - name: Checkout repo
  321. uses: actions/checkout@v4
  322. - name: Run actionlint
  323. id: actionlint
  324. uses: raven-actions/actionlint@v2
  325. golang:
  326. name: Go Tests
  327. runs-on: ubuntu-latest
  328. timeout-minutes: 5
  329. steps:
  330. - name: Checkout repo
  331. uses: actions/checkout@v4
  332. - name: Set up Go
  333. uses: actions/setup-go@v5
  334. with:
  335. go-version: '1.23.6'
  336. check-latest: true
  337. - name: Run wrapper tests
  338. working-directory: src/golang
  339. run: |
  340. go test -v wrapper.go wrapper_test.go
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...