forked from subsy/ralph-tui
-
Notifications
You must be signed in to change notification settings - Fork 0
211 lines (163 loc) · 8.98 KB
/
ci.yml
File metadata and controls
211 lines (163 loc) · 8.98 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Clear TypeScript build cache
run: |
rm -rf node_modules/.cache
rm -rf .tsbuildinfo
- name: Install dependencies
run: bun install
- name: Type check
run: bun run typecheck
- name: Lint
run: bun run lint
- name: Build
run: bun run build
test:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install
- name: Run tests with coverage
run: |
set -euo pipefail
mkdir -p coverage-parts
# Run tests in batches to avoid mock.module() conflicts between test files
# Each batch outputs its own lcov file for later merging
echo "=== Running tests/ ===" | tee -a coverage-output.txt
bun test tests/ --coverage --coverage-reporter=text --coverage-reporter=lcov 2>&1 | tee -a coverage-output.txt
cp coverage/lcov.info coverage-parts/tests.lcov
echo "=== Running doctor.test.ts ===" | tee -a coverage-output.txt
bun test src/commands/doctor.test.ts --coverage --coverage-reporter=text --coverage-reporter=lcov 2>&1 | tee -a coverage-output.txt
cp coverage/lcov.info coverage-parts/doctor.lcov
echo "=== Running info.test.ts ===" | tee -a coverage-output.txt
bun test src/commands/info.test.ts --coverage --coverage-reporter=text --coverage-reporter=lcov 2>&1 | tee -a coverage-output.txt
cp coverage/lcov.info coverage-parts/info.lcov
echo "=== Running skills.test.ts ===" | tee -a coverage-output.txt
bun test src/commands/skills.test.ts --coverage --coverage-reporter=text --coverage-reporter=lcov 2>&1 | tee -a coverage-output.txt
cp coverage/lcov.info coverage-parts/skills.lcov
echo "=== Running src/config/ ===" | tee -a coverage-output.txt
bun test src/config/ --coverage --coverage-reporter=text --coverage-reporter=lcov 2>&1 | tee -a coverage-output.txt
cp coverage/lcov.info coverage-parts/config.lcov
echo "=== Running src/engine/ ===" | tee -a coverage-output.txt
bun test src/engine/ --coverage --coverage-reporter=text --coverage-reporter=lcov 2>&1 | tee -a coverage-output.txt
cp coverage/lcov.info coverage-parts/engine.lcov
# Run beads-bv and beads-rust tests in isolation due to ES module mock conflicts
# Both mock node:fs/promises which pollutes other tests when run together
echo "=== Running beads-bv test (isolated) ===" | tee -a coverage-output.txt
bun test src/plugins/trackers/builtin/beads-bv/index.test.ts --coverage --coverage-reporter=text --coverage-reporter=lcov 2>&1 | tee -a coverage-output.txt
cp coverage/lcov.info coverage-parts/beads-bv.lcov
echo "=== Running beads-rust test (isolated) ===" | tee -a coverage-output.txt
bun test src/plugins/trackers/builtin/beads-rust/index.test.ts --coverage --coverage-reporter=text --coverage-reporter=lcov 2>&1 | tee -a coverage-output.txt
cp coverage/lcov.info coverage-parts/beads-rust.lcov
echo "=== Running src/plugins/ (excluding beads-bv and beads-rust) ===" | tee -a coverage-output.txt
bun test src/plugins/agents/ src/plugins/trackers/builtin/beads.test.ts --coverage --coverage-reporter=text --coverage-reporter=lcov 2>&1 | tee -a coverage-output.txt || true
cp coverage/lcov.info coverage-parts/plugins.lcov || true
echo "=== Running src/session/ ===" | tee -a coverage-output.txt
bun test src/session/ --coverage --coverage-reporter=text --coverage-reporter=lcov 2>&1 | tee -a coverage-output.txt
cp coverage/lcov.info coverage-parts/session.lcov
echo "=== Running src/sandbox/ ===" | tee -a coverage-output.txt
bun test src/sandbox/ --coverage --coverage-reporter=text --coverage-reporter=lcov 2>&1 | tee -a coverage-output.txt
cp coverage/lcov.info coverage-parts/sandbox.lcov
# Run wizard.test.ts in isolation because it mocks skill-installer.js
# which leaks into skill-installer.test.ts via bun's process-level mock.module()
echo "=== Running wizard.test.ts (isolated) ===" | tee -a coverage-output.txt
bun test src/setup/wizard.test.ts --coverage --coverage-reporter=text --coverage-reporter=lcov 2>&1 | tee -a coverage-output.txt
cp coverage/lcov.info coverage-parts/wizard.lcov
echo "=== Running src/setup/ (excluding wizard) ===" | tee -a coverage-output.txt
bun test src/setup/skill-installer.test.ts src/setup/migration.test.ts src/setup/prompts.test.ts --coverage --coverage-reporter=text --coverage-reporter=lcov 2>&1 | tee -a coverage-output.txt
cp coverage/lcov.info coverage-parts/setup.lcov
echo "=== Running src/templates/ ===" | tee -a coverage-output.txt
bun test src/templates/ --coverage --coverage-reporter=text --coverage-reporter=lcov 2>&1 | tee -a coverage-output.txt
cp coverage/lcov.info coverage-parts/templates.lcov
echo "=== Running src/tui/ ===" | tee -a coverage-output.txt
bun test src/tui/ --coverage --coverage-reporter=text --coverage-reporter=lcov 2>&1 | tee -a coverage-output.txt
cp coverage/lcov.info coverage-parts/tui.lcov
echo "=== Running src/prd/ ===" | tee -a coverage-output.txt
bun test src/prd/ --coverage --coverage-reporter=text --coverage-reporter=lcov 2>&1 | tee -a coverage-output.txt
cp coverage/lcov.info coverage-parts/prd.lcov
echo "=== Running src/chat/ ===" | tee -a coverage-output.txt
bun test src/chat/ --coverage --coverage-reporter=text --coverage-reporter=lcov 2>&1 | tee -a coverage-output.txt
cp coverage/lcov.info coverage-parts/chat.lcov
echo "=== All test batches completed ===" | tee -a coverage-output.txt
ls -la coverage-parts/
- name: Check coverage threshold
run: |
# Calculate weighted average coverage from all batches
# Each batch reports coverage for files it loads, so we use the largest batch
# (tests/) as the primary indicator since it loads the most code paths
# Get coverage from tests/ batch (870 tests, most comprehensive)
TESTS_COV=$(grep -m1 "^All files" coverage-output.txt | awk '{print $4}' | tr -d '%' || echo "0")
echo "Coverage breakdown by batch:"
grep "^All files" coverage-output.txt | awk '{print " " $4}'
echo ""
echo "Primary coverage (tests/ batch with 870 tests): $TESTS_COV%"
# Check if coverage is below 40%
if [ "$(echo "$TESTS_COV < 40" | bc -l)" -eq 1 ]; then
echo "❌ Coverage $TESTS_COV% is below 40% threshold"
exit 1
fi
echo "✅ Coverage $TESTS_COV% meets 40% threshold"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
# Upload all batch coverage files - Codecov will merge them correctly
files: ./coverage-parts/tests.lcov,./coverage-parts/doctor.lcov,./coverage-parts/info.lcov,./coverage-parts/skills.lcov,./coverage-parts/config.lcov,./coverage-parts/engine.lcov,./coverage-parts/beads-bv.lcov,./coverage-parts/beads-rust.lcov,./coverage-parts/plugins.lcov,./coverage-parts/session.lcov,./coverage-parts/sandbox.lcov,./coverage-parts/wizard.lcov,./coverage-parts/setup.lcov,./coverage-parts/templates.lcov,./coverage-parts/tui.lcov,./coverage-parts/prd.lcov,./coverage-parts/chat.lcov
fail_ci_if_error: false
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# Determine which paths changed
changes:
runs-on: ubuntu-latest
outputs:
website: ${{ steps.filter.outputs.website }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
website:
- 'website/**'
website:
needs: changes
if: ${{ needs.changes.outputs.website == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Clear TypeScript build cache
run: |
cd website
rm -rf node_modules/.cache
rm -rf .tsbuildinfo
- name: Install website dependencies
run: cd website && bun install
- name: Type check website
run: cd website && bun run typecheck
- name: Lint website
run: cd website && bun run lint
- name: Build website
run: cd website && bun run build