Skip to content

Commit 76dfe56

Browse files
committed
Set up Storybook tests for CI
Add vitest configuration with projects for unit and storybook tests: - Create ui/vitest.config.ts with unit and storybook test projects - Add ui-tests-storybook.yml workflow for running Storybook tests in CI - Update ui-tests.yml to explicitly run unit tests only - Add test:unit and test:storybook scripts to package.json - Upgrade vitest to 4.0.15 and add @vitest/browser-playwright Ref tensorzero#1602
1 parent e175c6a commit 76dfe56

File tree

7 files changed

+340
-34
lines changed

7 files changed

+340
-34
lines changed

.github/workflows/general.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,14 @@ jobs:
10301030
is_merge_group: ${{ github.event_name == 'merge_group' }}
10311031
needs: [build-gateway-container, build-mock-inference-container]
10321032

1033+
ui-storybook-tests:
1034+
permissions:
1035+
contents: read
1036+
actions: read
1037+
uses: ./.github/workflows/ui-tests-storybook.yml
1038+
with:
1039+
is_merge_group: ${{ github.event_name == 'merge_group' }}
1040+
10331041
ui-tests-e2e:
10341042
permissions:
10351043
contents: read
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: UI Storybook Tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
is_merge_group:
7+
required: true
8+
type: boolean
9+
10+
permissions:
11+
contents: read
12+
actions: read
13+
14+
jobs:
15+
ui-storybook-tests:
16+
runs-on: ubuntu-latest
17+
if: github.repository == 'tensorzero/tensorzero'
18+
19+
steps:
20+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
21+
22+
- name: Setup Node
23+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
24+
with:
25+
node-version: "24.11.0"
26+
27+
- name: Setup `pnpm`
28+
run: |
29+
for attempt in 1 2 3; do
30+
if npm install -g pnpm@latest; then
31+
break
32+
fi
33+
if [ $attempt -eq 3 ]; then
34+
echo "Failed to install pnpm after 3 attempts"
35+
exit 1
36+
fi
37+
sleep $((10 * attempt))
38+
done
39+
shell: bash
40+
41+
- name: Install `pnpm` dependencies
42+
run: pnpm install --frozen-lockfile
43+
44+
- name: Install Playwright browsers
45+
working-directory: ui
46+
run: pnpm exec playwright install chromium
47+
48+
- name: Run Storybook tests
49+
run: pnpm ui:test:storybook --run

.github/workflows/ui-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,15 @@ jobs:
9898
TENSORZERO_CLICKHOUSE_VERSION=${{ matrix.clickhouse_version }} docker compose -f fixtures/docker-compose.yml up clickhouse fixtures mock-inference-provider -d
9999
docker compose -f fixtures/docker-compose.yml wait fixtures
100100
101-
- name: Run `pnpm test`
101+
- name: Run `pnpm test:unit`
102102
env:
103103
OPENAI_API_KEY: not_used
104104
FIREWORKS_API_KEY: not_used
105105
TENSORZERO_UI_CONFIG_PATH: fixtures/config/tensorzero.toml
106106
TENSORZERO_CLICKHOUSE_URL: http://chuser:chpassword@localhost:8123/tensorzero_ui_fixtures
107107
TENSORZERO_POSTGRES_URL: postgres://postgres:postgres@localhost:5432/tensorzero_ui_fixtures
108108
TENSORZERO_GATEWAY_URL: http://localhost:3000
109-
run: pnpm ui:test
109+
run: pnpm ui:test:unit
110110

111111
- name: Run `pnpm test` for tensorzero-node
112112
working-directory: internal/tensorzero-node

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
"ui:dev": "pnpm --filter=tensorzero-ui dev",
88
"ui:storybook": "pnpm --filter=tensorzero-ui storybook",
99
"ui:test": "pnpm --filter=tensorzero-ui test",
10+
"ui:test:unit": "pnpm --filter=tensorzero-ui test:unit",
11+
"ui:test:storybook": "pnpm --filter=tensorzero-ui test:storybook",
1012
"ui:test:e2e": "pnpm --filter=tensorzero-ui test-e2e",
1113
"ui:test:e2e-base-path": "pnpm --filter=tensorzero-ui test-e2e-base-path",
1214
"tensorzero-node:test": "cd internal/tensorzero-node && pnpm test",

0 commit comments

Comments
 (0)