Skip to content

Commit e4ed0a4

Browse files
committed
fix cache issue
1 parent a223f61 commit e4ed0a4

2 files changed

Lines changed: 63 additions & 26 deletions

File tree

.github/workflows/cypress.yml

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Cypress E2E Tests
22
#
3-
# Single job: builds the Decision Engine, starts all services, runs all specs.
3+
# Single job, three parallel workers (background processes).
4+
# Mirrors `just cypress-parallel` locally — same split, same runner.
5+
#
6+
# Workers:
7+
# worker-1 — general UI specs
8+
# worker-2 — euclid rule-builder specs
9+
# worker-3 — API specs
410
#
511
# Caching layers:
612
# - Docker BuildKit layers → GHA cache, scoped per branch.
@@ -110,43 +116,37 @@ jobs:
110116
BASE_URL: http://localhost:8080
111117
ADMIN_SECRET: test_admin
112118

113-
# ── Start UI dev server ───────────────────────────────────────────────
114-
# Use the Vite dev server, NOT vite build + vite preview.
115-
#
116-
# vite preview has no proxy, so API calls from the browser go directly to
117-
# http://localhost:8080 — a different origin (cross-origin from port 5173).
118-
# The decision engine does not emit CORS headers for localhost:5173, so the
119-
# browser blocks every API call and the app renders blank.
120-
#
121-
# The Vite dev server proxies /decision-engine-api/* → http://localhost:8080
122-
# (same origin, no CORS). It also uses base '/' so routes are at the root —
123-
# no /decision-engine prefix in CYPRESS_UI_BASE_URL needed.
124-
- name: Start UI dev server
125-
run: npx vite --port 5173 &
119+
# ── Build + serve UI ─────────────────────────────────────────────────
120+
# Build first so import/compile errors (e.g. missing React hooks) fail
121+
# fast with a clear message before Cypress even starts.
122+
# vite preview has a proxy configured in vite.config.ts (same routes as
123+
# the dev server), so API calls are forwarded to http://localhost:8080
124+
# without CORS issues.
125+
- name: Build UI
126+
run: npx vite build
127+
working-directory: website
128+
129+
- name: Start UI preview server
130+
run: npx vite preview --port 5173 --host &
126131
working-directory: website
127132

128133
- name: Wait for UI
129134
run: |
130135
timeout 60 bash -c \
131136
'until curl -sf http://localhost:5173; do sleep 2; done'
132137
133-
# ── Run all Cypress specs ─────────────────────────────────────────────
134-
# Includes: all UI tests + all API tests.
135-
# Excludes: cypress/e2e/runtime/ — runtime-smoke.cy.js calls
136-
# waitForRuntimeSurface() which requires the Mintlify docs server.
137-
# Mintlify is only present in the dashboard-* compose profiles,
138-
# not in postgres-local. Add it here if that profile is adopted.
138+
- name: Install just
139+
run: curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to /usr/local/bin
140+
141+
# ── Run all Cypress specs across 3 parallel workers ───────────────────
142+
# Delegates to `just cypress-parallel` — identical to local runs.
139143
- name: Run Cypress
140-
run: |
141-
npx cypress run \
142-
--spec "cypress/e2e/ui/**/*.cy.js,cypress/e2e/api/**/*.cy.js" \
143-
--headless
144+
run: just cypress-parallel
144145
env:
145146
CYPRESS_API_BASE_URL: http://localhost:8080
146147
CYPRESS_UI_BASE_URL: http://localhost:5173
147148
CYPRESS_RUNTIME_MODE: ci
148149

149-
150150
- name: Upload screenshots on failure
151151
uses: actions/upload-artifact@v4
152152
if: failure()

justfile

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ test *FLAGS:
7575
cargo test {{ FLAGS }}
7676
alias t := test
7777

78-
# Run all Cypress E2E tests headlessly (replicates CI behaviour)
78+
# Run all Cypress E2E tests headlessly (replicates CI behaviour — single browser, sequential)
7979
cypress:
8080
npx cypress run --spec "cypress/e2e/ui/**/*.cy.js,cypress/e2e/api/**/*.cy.js" --headless
8181
alias cy := cypress
@@ -84,6 +84,43 @@ alias cy := cypress
8484
cypress-spec spec:
8585
npx cypress run --spec "{{ spec }}" --headless
8686

87+
# Run all Cypress E2E tests across 3 balanced parallel workers.
88+
#
89+
# Split is based on measured spec durations (see worker comments).
90+
# Euclid specs are distributed across all three workers so no single
91+
# worker is left idle while another finishes the euclid suite alone.
92+
#
93+
# Worker 1 ~78s — heavy euclid: builder(1:07) + enum-operators(0:11)
94+
# Worker 2 ~75s — medium euclid: e2e(0:36) + lifecycle(0:39)
95+
# Worker 3 ~86s — fast euclid + general UI + API:
96+
# nested-branches(0:09) + volume-split-priority(0:14) +
97+
# volume-split(0:14) + all general UI(0:35) + all API(0:14)
98+
cypress-parallel:
99+
#!/usr/bin/env bash
100+
set -uo pipefail
101+
102+
npx cypress run --headless \
103+
--spec "cypress/e2e/ui/euclid-rules-builder.cy.js,cypress/e2e/ui/euclid-rules-enum-operators.cy.js" \
104+
2>&1 | sed 's/^/[worker-1] /' &
105+
pid1=$!
106+
107+
npx cypress run --headless \
108+
--spec "cypress/e2e/ui/euclid-rules-e2e.cy.js,cypress/e2e/ui/euclid-rules-lifecycle.cy.js" \
109+
2>&1 | sed 's/^/[worker-2] /' &
110+
pid2=$!
111+
112+
npx cypress run --headless \
113+
--spec "cypress/e2e/ui/euclid-rules-nested-branches.cy.js,cypress/e2e/ui/euclid-rules-volume-split-priority.cy.js,cypress/e2e/ui/euclid-rules-volume-split.cy.js,cypress/e2e/ui/analytics-page.cy.js,cypress/e2e/ui/auth-page.cy.js,cypress/e2e/ui/dashboard-overview.cy.js,cypress/e2e/ui/debit-routing-page.cy.js,cypress/e2e/ui/decision-explorer.cy.js,cypress/e2e/ui/payment-audit.cy.js,cypress/e2e/ui/volume-split-page.cy.js,cypress/e2e/api/**/*.cy.js" \
114+
2>&1 | sed 's/^/[worker-3] /' &
115+
pid3=$!
116+
117+
failed=0
118+
wait "$pid1" || failed=1
119+
wait "$pid2" || failed=1
120+
wait "$pid3" || failed=1
121+
exit "$failed"
122+
alias cyp := cypress-parallel
123+
87124
# Run pre-commit checks
88125
precommit: fmt clippy
89126

0 commit comments

Comments
 (0)