Skip to content

Commit d521bda

Browse files
committed
ci: clear the dev cache by absolute path, always run session cleanup, floor shard weights, log through @sim/logger
1 parent cdb34e8 commit d521bda

3 files changed

Lines changed: 20 additions & 8 deletions

File tree

‎.github/workflows/checks.yml‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,15 +328,19 @@ jobs:
328328
cache_broken() {
329329
grep -qiE 'cache corruption|turbopack.*panic|panicked' "$next_log" 2>/dev/null
330330
}
331-
# The cache directory is a mount point: empty it rather than remove it.
331+
# The cache directory is a mount point: empty it rather than remove it. Absolute, because
332+
# the EXIT trap runs after the step has moved into apps/desktop.
332333
clear_cache() {
333-
find apps/sim/.next/dev -mindepth 1 -maxdepth 1 -exec rm -rf {} +
334+
find "$GITHUB_WORKSPACE/apps/sim/.next/dev" -mindepth 1 -maxdepth 1 -exec rm -rf {} +
334335
}
335336
# SIGINT first: `next dev` SIGKILLs its server 100ms after SIGTERM, which discards a cache
336337
# write in flight. stop-session.sh then removes anything still running.
338+
# SIGINT is best-effort; the cleanup always runs, since workers and the detached telemetry
339+
# flush can outlive a server that has already exited.
337340
stop_sim() {
338-
kill -INT "$server_pid" 2>/dev/null || return 0
339-
for _ in $(seq 1 30); do kill -0 "$server_pid" 2>/dev/null || break; sleep 1; done
341+
if kill -INT "$server_pid" 2>/dev/null; then
342+
for _ in $(seq 1 30); do kill -0 "$server_pid" 2>/dev/null || break; sleep 1; done
343+
fi
340344
bash "$GITHUB_WORKSPACE/.github/scripts/stop-session.sh" "$server_pid" "$server_tag"
341345
}
342346
(cd apps/realtime && PORT=3023 SIM_DB_ROLE=realtime ALLOWED_ORIGINS="$NEXT_PUBLIC_APP_URL" \

‎scripts/update-integration-durations.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
*/
1515
import { readdir, readFile, writeFile } from 'node:fs/promises'
1616
import path from 'node:path'
17+
import { createLogger } from '@sim/logger'
1718

1819
interface JsonReport {
1920
testResults: { name: string; startTime: number; endTime: number }[]
2021
}
2122

23+
const logger = createLogger('UpdateIntegrationDurations')
2224
const REPORT_NAME = 'integration.json'
2325
const ROOT = path.resolve(import.meta.dir, '..')
2426
const OUTPUT = path.join(ROOT, 'vitest.integration-durations.json')
@@ -38,7 +40,7 @@ function repoPath(absolute: string): string | null {
3840

3941
const source = process.argv[2]
4042
if (!source) {
41-
console.error('Usage: bun run scripts/update-integration-durations.ts <downloaded-reports-dir>')
43+
logger.error('Usage: bun run scripts/update-integration-durations.ts <downloaded-reports-dir>')
4244
process.exit(1)
4345
}
4446

@@ -62,7 +64,7 @@ for (const reportPath of reports) {
6264
}
6365

6466
if (samples.size === 0) {
65-
console.error(`No ${REPORT_NAME} reports with test results under ${source}`)
67+
logger.error(`No ${REPORT_NAME} reports with test results under ${source}`)
6668
process.exit(1)
6769
}
6870

@@ -74,4 +76,4 @@ const durations = Object.fromEntries(
7476
})
7577
)
7678
await writeFile(OUTPUT, `${JSON.stringify(durations, null, 2)}\n`)
77-
console.log(`Wrote ${samples.size} file weights from ${reports.length} reports to ${OUTPUT}`)
79+
logger.info(`Wrote ${samples.size} file weights from ${reports.length} reports to ${OUTPUT}`)

‎vitest.shared.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ export default defineConfig({
2727

2828
/** Seconds a file of unknown duration is assumed to take: about the median measured file. */
2929
const UNKNOWN_FILE_SECONDS = 6
30+
/** Floor for any file: one that skips every test in CI still pays its import and collection. */
31+
const MIN_FILE_SECONDS = 1
3032
const DURATIONS_FILE = 'vitest.integration-durations.json'
3133

3234
function findRepoRoot(from: string): string {
@@ -63,7 +65,11 @@ class DurationBalancedSequencer extends BaseSequencer {
6365

6466
const weighted = files.map((spec) => {
6567
const key = path.relative(root, spec.moduleId).split(path.sep).join('/')
66-
return { spec, key, seconds: durations[key] ?? UNKNOWN_FILE_SECONDS }
68+
return {
69+
spec,
70+
key,
71+
seconds: Math.max(durations[key] ?? UNKNOWN_FILE_SECONDS, MIN_FILE_SECONDS),
72+
}
6773
})
6874
weighted.sort((a, b) => b.seconds - a.seconds || (a.key < b.key ? -1 : a.key > b.key ? 1 : 0))
6975

0 commit comments

Comments
 (0)