Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,20 @@ jobs:
- name: Run tests
run: pnpm test

- name: Upload test results to Trunk
# Run even when tests fail so flaky/failed results are still reported,
# but never let an upload problem fail the job.
if: ${{ !cancelled() }}
continue-on-error: true
uses: trunk-io/analytics-uploader@385f1ccdf345b4532dc4b6c665dd432b702b8e28 # v2.1.2
with:
# Scope to each package root. A bare **/junit.xml glob descends into
# node_modules, where pnpm symlinks workspace packages, and uploads
# every report many times over.
junit-paths: "apps/*/junit.xml,packages/*/junit.xml"
org-slug: posthog-inc
token: ${{ secrets.TRUNK_API_TOKEN }}

integration-test:
needs: changes
# Fail closed: if change detection itself failed, run instead of skipping.
Expand Down Expand Up @@ -143,6 +157,17 @@ jobs:
env:
CI: true

- name: Upload test results to Trunk
# Run even when E2E tests fail so flaky/failed results are still
# reported, but never let an upload problem fail the job.
if: ${{ !cancelled() }}
continue-on-error: true
uses: trunk-io/analytics-uploader@385f1ccdf345b4532dc4b6c665dd432b702b8e28 # v2.1.2
with:
junit-paths: "apps/code/tests/e2e/junit.xml"
org-slug: posthog-inc
token: ${{ secrets.TRUNK_API_TOKEN }}

- name: Upload Playwright report
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
if: failure()
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ test-results/
*storybook.log
.session-store.json
.playwright-mcp
# Trunk Flaky Tests JUnit reports (one per package, uploaded from CI)
junit.xml

# Downloaded binaries
apps/code/resources/codex-acp/
Expand Down
12 changes: 10 additions & 2 deletions apps/code/tests/e2e/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@ export default defineConfig({
testDir: "./tests",
testMatch: "**/*.spec.ts",
timeout: 60000,
retries: isCI ? 2 : 0,
// No retries: Trunk Flaky Tests needs raw pass/fail results to detect flakes.
retries: 0,
// Must run serially - Electron app has single instance lock
workers: 1,
reporter: isCI ? [["github"], ["html", { open: "never" }]] : [["list"]],
// junit.xml (resolved next to this config) is uploaded to Trunk in CI.
reporter: isCI
? [
["junit", { outputFile: "junit.xml" }],
["github"],
["html", { open: "never" }],
]
: [["junit", { outputFile: "junit.xml" }], ["list"]],
outputDir: "../playwright-results",
use: {
trace: "retain-on-failure",
Expand Down
2 changes: 2 additions & 0 deletions apps/code/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from "node:path";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vitest/config";
import { trunkTestOptions } from "../../vitest.config.base";
import { rendererAliases } from "./vite.shared.mjs";

export default defineConfig({
Expand All @@ -10,6 +11,7 @@ export default defineConfig({
},
test: {
globals: true,
...trunkTestOptions,
environment: "jsdom",
setupFiles: ["./src/shared/test/setup.ts"],
exclude: ["**/node_modules/**", "**/dist/**", "tests/e2e/**"],
Expand Down
2 changes: 2 additions & 0 deletions apps/mobile/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import path from "node:path";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vitest/config";
import { trunkTestOptions } from "../../vitest.config.base";

export default defineConfig({
plugins: [react()],
test: {
globals: true,
...trunkTestOptions,
environment: "node",
setupFiles: ["./src/test/setup.ts"],
exclude: ["**/node_modules/**", "**/dist/**"],
Expand Down
2 changes: 2 additions & 0 deletions packages/agent/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { resolve } from "node:path";
import { defineConfig } from "vitest/config";
import { trunkTestOptions } from "../../vitest.config.base";

export default defineConfig({
resolve: {
Expand All @@ -9,6 +10,7 @@ export default defineConfig({
},
test: {
globals: true,
...trunkTestOptions,
environment: "node",
include: ["src/**/*.test.ts"],
exclude: ["**/node_modules/**", "**/dist/**"],
Expand Down
2 changes: 2 additions & 0 deletions packages/electron-trpc/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
import path from "node:path";
import { fileURLToPath } from "node:url";
import { defineConfig } from "vite";
import { trunkTestOptions } from "../../vitest.config.base";

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

export default defineConfig({
test: {
...trunkTestOptions,
coverage: {
all: true,
include: ["src/**/*"],
Expand Down
2 changes: 2 additions & 0 deletions packages/git/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { defineConfig } from "vitest/config";
import { trunkTestOptions } from "../../vitest.config.base";

export default defineConfig({
test: {
globals: true,
...trunkTestOptions,
environment: "node",
include: ["src/**/*.test.ts"],
exclude: ["**/node_modules/**", "**/.git/**"],
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { defineConfig } from "vitest/config";
import { trunkTestOptions } from "../../vitest.config.base";

export default defineConfig({
test: {
globals: true,
...trunkTestOptions,
environment: "node",
include: ["src/**/*.test.ts"],
exclude: ["**/node_modules/**", "**/dist/**"],
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { fileURLToPath } from "node:url";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vitest/config";
import { trunkTestOptions } from "../../vitest.config.base";

export default defineConfig({
plugins: [react()],
Expand All @@ -20,6 +21,7 @@ export default defineConfig({
},
test: {
globals: true,
...trunkTestOptions,
environment: "jsdom",
setupFiles: ["./src/test/setup.ts"],
include: ["src/**/*.test.ts", "src/**/*.test.tsx"],
Expand Down
2 changes: 2 additions & 0 deletions packages/workspace-server/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { defineConfig } from "vitest/config";
import { trunkTestOptions } from "../../vitest.config.base";

export default defineConfig({
test: {
globals: true,
...trunkTestOptions,
environment: "node",
include: ["src/**/*.test.ts"],
exclude: ["**/node_modules/**", "**/dist/**"],
Expand Down
18 changes: 18 additions & 0 deletions vitest.config.base.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Shared Vitest test options for Trunk Flaky Tests uploads. Imported and spread
// into each package's `test` block so the junit reporter and retry policy stay
// defined in one place. See the upload steps in .github/workflows/test.yml.
//
// `outputFile` is relative, so each config writes ./junit.xml next to itself;
// CI globs apps/*/junit.xml and packages/*/junit.xml. The explicit type keeps
// the reporter tuple assignable across the Vitest 2.x and 4.x versions in use.
export const trunkTestOptions: {
retry: number;
reporters: (string | [string, Record<string, unknown>])[];
} = {
// Disable retries so flaky-test detection sees raw pass/fail results.
retry: 0,
reporters: [
"default",
["junit", { outputFile: "./junit.xml", addFileAttribute: true }],
],
};
Loading