Skip to content
This repository was archived by the owner on Aug 6, 2026. It is now read-only.

Commit be89b85

Browse files
gantoineclaude
andauthored
ci(tests): upload Vitest and Playwright JUnit reports to Trunk Flaky Tests (#2941)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 47412d7 commit be89b85

12 files changed

Lines changed: 71 additions & 2 deletions

File tree

.github/workflows/test.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,20 @@ jobs:
7171
- name: Run tests
7272
run: pnpm test
7373

74+
- name: Upload test results to Trunk
75+
# Run even when tests fail so flaky/failed results are still reported,
76+
# but never let an upload problem fail the job.
77+
if: ${{ !cancelled() }}
78+
continue-on-error: true
79+
uses: trunk-io/analytics-uploader@385f1ccdf345b4532dc4b6c665dd432b702b8e28 # v2.1.2
80+
with:
81+
# Scope to each package root. A bare **/junit.xml glob descends into
82+
# node_modules, where pnpm symlinks workspace packages, and uploads
83+
# every report many times over.
84+
junit-paths: "apps/*/junit.xml,packages/*/junit.xml"
85+
org-slug: posthog-inc
86+
token: ${{ secrets.TRUNK_API_TOKEN }}
87+
7488
integration-test:
7589
needs: changes
7690
# Fail closed: if change detection itself failed, run instead of skipping.
@@ -140,6 +154,17 @@ jobs:
140154
env:
141155
CI: true
142156

157+
- name: Upload test results to Trunk
158+
# Run even when E2E tests fail so flaky/failed results are still
159+
# reported, but never let an upload problem fail the job.
160+
if: ${{ !cancelled() }}
161+
continue-on-error: true
162+
uses: trunk-io/analytics-uploader@385f1ccdf345b4532dc4b6c665dd432b702b8e28 # v2.1.2
163+
with:
164+
junit-paths: "apps/code/tests/e2e/junit.xml"
165+
org-slug: posthog-inc
166+
token: ${{ secrets.TRUNK_API_TOKEN }}
167+
143168
- name: Upload Playwright report
144169
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
145170
if: failure()

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ test-results/
5757
*storybook.log
5858
.session-store.json
5959
.playwright-mcp
60+
# Trunk Flaky Tests JUnit reports (one per package, uploaded from CI)
61+
junit.xml
6062

6163
# Downloaded binaries
6264
apps/code/resources/codex-acp/

apps/code/tests/e2e/playwright.config.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,18 @@ export default defineConfig({
99
// configs (playwright.update*.config.ts), never in the general suite.
1010
testIgnore: "**/update*.spec.ts",
1111
timeout: 60000,
12-
retries: isCI ? 2 : 0,
12+
// No retries: Trunk Flaky Tests needs raw pass/fail results to detect flakes.
13+
retries: 0,
1314
// Must run serially - Electron app has single instance lock
1415
workers: 1,
15-
reporter: isCI ? [["github"], ["html", { open: "never" }]] : [["list"]],
16+
// junit.xml (resolved next to this config) is uploaded to Trunk in CI.
17+
reporter: isCI
18+
? [
19+
["junit", { outputFile: "junit.xml" }],
20+
["github"],
21+
["html", { open: "never" }],
22+
]
23+
: [["junit", { outputFile: "junit.xml" }], ["list"]],
1624
outputDir: "../playwright-results",
1725
use: {
1826
trace: "retain-on-failure",

apps/code/vitest.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import path from "node:path";
22
import react from "@vitejs/plugin-react";
33
import { defineConfig } from "vitest/config";
4+
import { trunkTestOptions } from "../../vitest.config.base";
45
import { rendererAliases } from "./vite.shared.mjs";
56

67
export default defineConfig({
@@ -10,6 +11,7 @@ export default defineConfig({
1011
},
1112
test: {
1213
globals: true,
14+
...trunkTestOptions,
1315
environment: "jsdom",
1416
setupFiles: ["./src/shared/test/setup.ts"],
1517
exclude: ["**/node_modules/**", "**/dist/**", "tests/e2e/**"],

apps/mobile/vitest.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import path from "node:path";
22
import react from "@vitejs/plugin-react";
33
import { defineConfig } from "vitest/config";
4+
import { trunkTestOptions } from "../../vitest.config.base";
45

56
export default defineConfig({
67
plugins: [react()],
78
test: {
89
globals: true,
10+
...trunkTestOptions,
911
environment: "node",
1012
setupFiles: ["./src/test/setup.ts"],
1113
exclude: ["**/node_modules/**", "**/dist/**"],

packages/agent/vitest.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { resolve } from "node:path";
22
import { defineConfig } from "vitest/config";
3+
import { trunkTestOptions } from "../../vitest.config.base";
34

45
export default defineConfig({
56
resolve: {
@@ -9,6 +10,7 @@ export default defineConfig({
910
},
1011
test: {
1112
globals: true,
13+
...trunkTestOptions,
1214
environment: "node",
1315
include: ["src/**/*.test.ts"],
1416
exclude: ["**/node_modules/**", "**/dist/**"],

packages/electron-trpc/vitest.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
import path from "node:path";
33
import { fileURLToPath } from "node:url";
44
import { defineConfig } from "vite";
5+
import { trunkTestOptions } from "../../vitest.config.base";
56

67
const __dirname = path.dirname(fileURLToPath(import.meta.url));
78

89
export default defineConfig({
910
test: {
11+
...trunkTestOptions,
1012
coverage: {
1113
all: true,
1214
include: ["src/**/*"],

packages/git/vitest.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { defineConfig } from "vitest/config";
2+
import { trunkTestOptions } from "../../vitest.config.base";
23

34
export default defineConfig({
45
test: {
56
globals: true,
7+
...trunkTestOptions,
68
environment: "node",
79
include: ["src/**/*.test.ts"],
810
exclude: ["**/node_modules/**", "**/.git/**"],

packages/shared/vitest.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { defineConfig } from "vitest/config";
2+
import { trunkTestOptions } from "../../vitest.config.base";
23

34
export default defineConfig({
45
test: {
56
globals: true,
7+
...trunkTestOptions,
68
environment: "node",
79
include: ["src/**/*.test.ts"],
810
exclude: ["**/node_modules/**", "**/dist/**"],

packages/ui/vitest.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { fileURLToPath } from "node:url";
22
import react from "@vitejs/plugin-react";
33
import { defineConfig } from "vitest/config";
4+
import { trunkTestOptions } from "../../vitest.config.base";
45

56
export default defineConfig({
67
plugins: [react()],
@@ -20,6 +21,7 @@ export default defineConfig({
2021
},
2122
test: {
2223
globals: true,
24+
...trunkTestOptions,
2325
environment: "jsdom",
2426
setupFiles: ["./src/test/setup.ts"],
2527
include: ["src/**/*.test.ts", "src/**/*.test.tsx"],

0 commit comments

Comments
 (0)