Skip to content

Commit 5dc2256

Browse files
committed
fix: Fix parallel execution issues in optimized workflows
- Removed flaky bash parallel execution with & and wait - Added proper sequential execution for test-optimized.yml - Created test-optimized-v2.yml with true parallel jobs (build, test, typecheck) - The v2 approach uses GitHub Actions' native job parallelization The v2 workflow should provide the best performance: - Build job runs first and caches outputs - Test and typecheck jobs run in parallel using the cached build - Expected time: ~2-3 minutes total (build: 1-2m, test/typecheck in parallel: 2-3m)
1 parent cbbc11a commit 5dc2256

2 files changed

Lines changed: 217 additions & 32 deletions

File tree

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
name: Test Optimized v2
2+
3+
on:
4+
push:
5+
branches: ['*']
6+
pull_request:
7+
branches: ['*']
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
# Build once, use in parallel jobs
15+
build:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v5
21+
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: 22.x
26+
27+
- name: Setup pnpm
28+
uses: pnpm/action-setup@v4
29+
with:
30+
version: 10.10.0
31+
run_install: false
32+
33+
- name: Get pnpm store directory
34+
shell: bash
35+
run: |
36+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
37+
38+
# Create necessary directories for postinstall scripts
39+
- name: Prepare directories
40+
run: |
41+
mkdir -p agents-docs/.source
42+
touch agents-docs/.source/index.ts
43+
44+
- name: Setup pnpm cache
45+
uses: actions/cache@v4
46+
with:
47+
path: ${{ env.STORE_PATH }}
48+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
49+
restore-keys: |
50+
${{ runner.os }}-pnpm-store-
51+
52+
# Cache build outputs
53+
- name: Setup build cache
54+
id: build-cache
55+
uses: actions/cache@v4
56+
with:
57+
path: |
58+
**/dist
59+
**/.next
60+
**/build
61+
**/.turbo
62+
**/node_modules/.vite
63+
**/node_modules/.cache
64+
key: ${{ runner.os }}-build-${{ github.sha }}
65+
restore-keys: |
66+
${{ runner.os }}-build-
67+
68+
- name: Install dependencies
69+
run: pnpm install --frozen-lockfile
70+
71+
# Build only if not cached
72+
- name: Build packages
73+
if: steps.build-cache.outputs.cache-hit != 'true'
74+
run: pnpm build --concurrency=200%
75+
env:
76+
TURBO_TELEMETRY_DISABLED: 1
77+
TURBO_CACHE_DIR: .turbo
78+
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
79+
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
80+
NODE_OPTIONS: --max-old-space-size=4096
81+
82+
# Run tests in parallel with typecheck
83+
test:
84+
needs: build
85+
runs-on: ubuntu-latest
86+
87+
steps:
88+
- name: Checkout code
89+
uses: actions/checkout@v5
90+
91+
- name: Setup Node.js
92+
uses: actions/setup-node@v4
93+
with:
94+
node-version: 22.x
95+
96+
- name: Setup pnpm
97+
uses: pnpm/action-setup@v4
98+
with:
99+
version: 10.10.0
100+
run_install: false
101+
102+
- name: Get pnpm store directory
103+
shell: bash
104+
run: |
105+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
106+
107+
- name: Prepare directories
108+
run: |
109+
mkdir -p agents-docs/.source
110+
touch agents-docs/.source/index.ts
111+
112+
- name: Restore pnpm cache
113+
uses: actions/cache@v4
114+
with:
115+
path: ${{ env.STORE_PATH }}
116+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
117+
restore-keys: |
118+
${{ runner.os }}-pnpm-store-
119+
120+
- name: Restore build cache
121+
uses: actions/cache@v4
122+
with:
123+
path: |
124+
**/dist
125+
**/.next
126+
**/build
127+
**/.turbo
128+
**/node_modules/.vite
129+
**/node_modules/.cache
130+
key: ${{ runner.os }}-build-${{ github.sha }}
131+
restore-keys: |
132+
${{ runner.os }}-build-
133+
134+
- name: Install dependencies
135+
run: pnpm install --frozen-lockfile
136+
137+
- name: Run tests
138+
run: pnpm test
139+
env:
140+
TURBO_TELEMETRY_DISABLED: 1
141+
TURBO_CACHE_DIR: .turbo
142+
ENVIRONMENT: test
143+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY || 'sk-test-key-for-ci-testing' }}
144+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY || 'sk-ant-test-key-for-ci-testing' }}
145+
DB_FILE_NAME: test.db
146+
NODE_OPTIONS: --max-old-space-size=4096
147+
148+
typecheck:
149+
needs: build
150+
runs-on: ubuntu-latest
151+
152+
steps:
153+
- name: Checkout code
154+
uses: actions/checkout@v5
155+
156+
- name: Setup Node.js
157+
uses: actions/setup-node@v4
158+
with:
159+
node-version: 22.x
160+
161+
- name: Setup pnpm
162+
uses: pnpm/action-setup@v4
163+
with:
164+
version: 10.10.0
165+
run_install: false
166+
167+
- name: Get pnpm store directory
168+
shell: bash
169+
run: |
170+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
171+
172+
- name: Prepare directories
173+
run: |
174+
mkdir -p agents-docs/.source
175+
touch agents-docs/.source/index.ts
176+
177+
- name: Restore pnpm cache
178+
uses: actions/cache@v4
179+
with:
180+
path: ${{ env.STORE_PATH }}
181+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
182+
restore-keys: |
183+
${{ runner.os }}-pnpm-store-
184+
185+
- name: Restore build cache
186+
uses: actions/cache@v4
187+
with:
188+
path: |
189+
**/dist
190+
**/.next
191+
**/build
192+
**/.turbo
193+
**/node_modules/.vite
194+
**/node_modules/.cache
195+
key: ${{ runner.os }}-build-${{ github.sha }}
196+
restore-keys: |
197+
${{ runner.os }}-build-
198+
199+
- name: Install dependencies
200+
run: pnpm install --frozen-lockfile
201+
202+
- name: Run typecheck
203+
run: pnpm typecheck
204+
env:
205+
TURBO_TELEMETRY_DISABLED: 1
206+
TURBO_CACHE_DIR: .turbo
207+
NODE_OPTIONS: --max-old-space-size=4096

.github/workflows/test-optimized.yml

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -86,38 +86,9 @@ jobs:
8686
TURBO_CACHE_DIR: .turbo
8787
NODE_OPTIONS: --max-old-space-size=4096
8888

89-
# Run test and typecheck in parallel
90-
- name: Run tests and typecheck in parallel
91-
run: |
92-
echo "Starting parallel test and typecheck..."
93-
94-
# Start test in background
95-
pnpm test &
96-
TEST_PID=$!
97-
98-
# Start typecheck in background
99-
pnpm typecheck &
100-
TYPECHECK_PID=$!
101-
102-
# Monitor progress
103-
echo "Test PID: $TEST_PID, Typecheck PID: $TYPECHECK_PID"
104-
105-
# Wait for both to complete and capture exit codes
106-
wait $TEST_PID
107-
TEST_EXIT=$?
108-
echo "Test completed with exit code: $TEST_EXIT"
109-
110-
wait $TYPECHECK_PID
111-
TYPECHECK_EXIT=$?
112-
echo "Typecheck completed with exit code: $TYPECHECK_EXIT"
113-
114-
# Exit with failure if either failed
115-
if [ $TEST_EXIT -ne 0 ] || [ $TYPECHECK_EXIT -ne 0 ]; then
116-
echo "Tests or typecheck failed"
117-
exit 1
118-
fi
119-
120-
echo "All checks passed successfully!"
89+
# Run test and typecheck - Turbo handles parallelization internally
90+
- name: Run tests
91+
run: pnpm test
12192
env:
12293
TURBO_TELEMETRY_DISABLED: 1
12394
TURBO_CACHE_DIR: .turbo
@@ -126,3 +97,10 @@ jobs:
12697
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY || 'sk-ant-test-key-for-ci-testing' }}
12798
DB_FILE_NAME: test.db
12899
NODE_OPTIONS: --max-old-space-size=4096
100+
101+
- name: Run typecheck
102+
run: pnpm typecheck
103+
env:
104+
TURBO_TELEMETRY_DISABLED: 1
105+
TURBO_CACHE_DIR: .turbo
106+
NODE_OPTIONS: --max-old-space-size=4096

0 commit comments

Comments
 (0)