Skip to content

Commit c850d62

Browse files
committed
ci(workers): move benchmark to separate non-gating job; test only runs it when KIT_BENCH=true\nlogs(app): add [app-log] around app-prompt message flow and run() calls
1 parent 69455e9 commit c850d62

File tree

3 files changed

+73
-9
lines changed

3 files changed

+73
-9
lines changed

.github/workflows/release.yml

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
run: |
6767
pnpm ava:ci
6868
69-
- name: pnpm test
69+
- name: pnpm test (unit/integration, no benchmark)
7070
uses: nick-invision/retry@v3
7171
with:
7272
max_attempts: 1
@@ -76,6 +76,45 @@ jobs:
7676
env:
7777
KIT: ${{ env.kit_path }}
7878

79+
test-windows-worker-bench:
80+
runs-on: windows-latest
81+
needs: [test-windows]
82+
steps:
83+
- name: Inject slug/short variables
84+
uses: rlespinasse/github-slug-action@v4
85+
86+
- name: Set env vars
87+
run: |
88+
echo "wd_path=$PWD" >> $GITHUB_ENV
89+
echo "kit_path=$PWD/.kit" >> $GITHUB_ENV
90+
echo "KIT=$PWD/.kit" >> $GITHUB_ENV
91+
92+
- name: Checkout kit
93+
uses: actions/checkout@master
94+
95+
- uses: pnpm/action-setup@v4
96+
name: Install pnpm
97+
98+
- name: Install Node.js
99+
uses: actions/setup-node@v4
100+
with:
101+
node-version: 22.17.1
102+
cache: "pnpm"
103+
104+
- name: pnpm i
105+
shell: bash
106+
run: |
107+
pnpm i
108+
109+
- name: Run worker benchmark (non-gating)
110+
shell: bash
111+
env:
112+
KIT: ${{ env.kit_path }}
113+
KIT_BENCH: 'true'
114+
run: |
115+
# Run only the worker benchmark test
116+
pnpm exec ava --config ./test/ava.config.mjs src/workers/cache-grouped-scripts-worker.test.ts -m "benchmark - worker CACHE_MAIN_SCRIPTS"
117+
79118
test-mac-and-ubuntu:
80119
strategy:
81120
matrix:

src/run/app-prompt.ts

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,21 @@ try {
101101
}
102102

103103
let messageHandler = (data: MessageData) => {
104+
try {
105+
console.warn('[app-log] app-prompt received message', { channel: data?.channel })
106+
} catch {}
104107
if (data.channel === Channel.HEARTBEAT) {
105108
send(Channel.HEARTBEAT)
106109
}
107110
if (data.channel === Channel.VALUE_SUBMITTED) {
108-
trace.instant({
109-
name: 'app-prompt.ts -> VALUE_SUBMITTED',
110-
args: data
111-
})
111+
try {
112+
trace.instant({
113+
name: 'app-prompt.ts -> VALUE_SUBMITTED',
114+
args: { hasHeaders: !!data?.value?.headers, hasArgs: Array.isArray(data?.value?.args) }
115+
})
116+
} catch (e) {
117+
console.warn('[app-log] trace.instant failed in VALUE_SUBMITTED', (e as any)?.message || e)
118+
}
112119
global.headers = data?.value?.headers || {}
113120
process.off('message', messageHandler)
114121
resolve(data.value)
@@ -117,7 +124,7 @@ try {
117124
process.on('message', messageHandler)
118125
})
119126
} catch (e) {
120-
global.warn(e)
127+
console.warn('[app-log] app-prompt main promise failed', (e as any)?.message || e)
121128
exit()
122129
}
123130
;({ script, args, trigger, choices, name, scriptlet } = result)
@@ -167,11 +174,25 @@ if (choices?.length > 0) {
167174
}
168175
let { runScriptlet } = await import('../main/scriptlet.js')
169176
updateArgs(args)
170-
await runScriptlet(scriptlet, inputs, flag)
177+
try {
178+
console.warn('[app-log] running scriptlet', { name, id: scriptlet?.id })
179+
await runScriptlet(scriptlet, inputs, flag)
180+
console.warn('[app-log] finished scriptlet')
181+
} catch (e) {
182+
console.warn('[app-log] runScriptlet failed', (e as any)?.message || e)
183+
throw e
184+
}
171185
} else {
172186
if (script.includes('.md')) {
173187
log({ script, ugh: '❌' })
174188
exit()
175189
}
176-
await run(script, ...args)
190+
try {
191+
console.warn('[app-log] running script', { script, argsLen: args?.length || 0 })
192+
await run(script, ...args)
193+
console.warn('[app-log] finished script')
194+
} catch (e) {
195+
console.warn('[app-log] run(script) failed', (e as any)?.message || e)
196+
throw e
197+
}
177198
}

src/workers/cache-grouped-scripts-worker.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ test('Worker caches results for identical stamp filePath', async (t) => {
159159
worker.terminate()
160160
})
161161

162-
test('benchmark - worker CACHE_MAIN_SCRIPTS', async (t) => {
162+
const runBench = process.env.KIT_BENCH === 'true'
163+
;(runBench ? test : test.skip)('benchmark - worker CACHE_MAIN_SCRIPTS', async (t) => {
163164
const previousResults = await loadPreviousResults()
164165
const isWindows = process.platform === 'win32'
165166
const runs = isWindows ? 5 : 20
@@ -183,6 +184,9 @@ test('benchmark - worker CACHE_MAIN_SCRIPTS', async (t) => {
183184
})
184185
const end = performance.now()
185186
times.push(end - start)
187+
if (i % Math.max(1, Math.floor(runs / 5)) === 0) {
188+
console.error(`[worker-diag] benchmark progress i=${i} duration=${(end-start).toFixed(1)}ms`)
189+
}
186190
return result
187191
})()
188192
worker.terminate()

0 commit comments

Comments
 (0)