-
Notifications
You must be signed in to change notification settings - Fork 138
141 lines (120 loc) · 4.35 KB
/
test-with-merge-queue.yml
File metadata and controls
141 lines (120 loc) · 4.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Test with Merge Queue
on:
pull_request:
types: [opened, synchronize, reopened]
merge_group:
types: [checks_requested]
push:
branches: [main]
jobs:
test-all:
runs-on: ubuntu-latest
# Smart concurrency: Cancel PR runs but NEVER cancel merge queue runs
concurrency:
group: ${{
github.event_name == 'pull_request' &&
format('pr-{0}', github.event.pull_request.number) ||
format('merge-queue-{0}', github.sha)
}}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
# Fetch more history for merge queue to properly test against base
fetch-depth: ${{ github.event_name == 'merge_group' && 10 || 1 }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22.x
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.10.0
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
# Create necessary directories for postinstall scripts
- name: Prepare directories
run: |
mkdir -p agents-docs/.source
touch agents-docs/.source/index.ts
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
# Cache build outputs
- name: Setup build cache
uses: actions/cache@v4
with:
path: |
**/dist
**/.next
**/build
**/.turbo
**/node_modules/.vite
**/node_modules/.cache
key: ${{ runner.os }}-build-${{ github.sha }}
restore-keys: |
${{ runner.os }}-build-
- name: Install dependencies
run: pnpm install --frozen-lockfile
# Build with increased concurrency for merge queue
- name: Build packages
run: |
if [ "${{ github.event_name }}" = "merge_group" ]; then
echo "Building for merge queue with maximum concurrency"
pnpm build --concurrency=300%
else
pnpm build --concurrency=200%
fi
env:
TURBO_TELEMETRY_DISABLED: 1
TURBO_CACHE_DIR: .turbo
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
NODE_OPTIONS: --max-old-space-size=4096
# Run tests and typecheck in parallel
- name: Run tests and typecheck in parallel
run: |
echo "Starting parallel test and typecheck..."
# Add timeout for merge queue (stricter)
if [ "${{ github.event_name }}" = "merge_group" ]; then
TIMEOUT_SECONDS=300 # 5 minutes max for merge queue
else
TIMEOUT_SECONDS=600 # 10 minutes for regular PRs
fi
# Start test with timeout
timeout $TIMEOUT_SECONDS pnpm test &
TEST_PID=$!
# Start typecheck with timeout
timeout $TIMEOUT_SECONDS pnpm typecheck &
TYPECHECK_PID=$!
# Wait and collect results
wait $TEST_PID
TEST_EXIT=$?
wait $TYPECHECK_PID
TYPECHECK_EXIT=$?
# Report results
if [ $TEST_EXIT -eq 124 ] || [ $TYPECHECK_EXIT -eq 124 ]; then
echo "❌ Tests or typecheck timed out after $TIMEOUT_SECONDS seconds"
exit 1
fi
if [ $TEST_EXIT -ne 0 ] || [ $TYPECHECK_EXIT -ne 0 ]; then
echo "❌ Tests or typecheck failed"
exit 1
fi
echo "✅ All checks passed successfully!"
env:
TURBO_TELEMETRY_DISABLED: 1
TURBO_CACHE_DIR: .turbo
ENVIRONMENT: test
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY || 'sk-test-key-for-ci-testing' }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY || 'sk-ant-test-key-for-ci-testing' }}
DB_FILE_NAME: test.db
NODE_OPTIONS: --max-old-space-size=4096