Skip to content

Commit 47af687

Browse files
Claudehotlong
andauthored
fix: resolve CI build and test errors
- Improve directory cleanup in build-schemas.ts with more robust retry logic - Add missing vitest.config.ts to plugin-hono-server package Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/b438a7ad-7484-4318-8da2-d6d61a73f8d4 Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 8fdf669 commit 47af687

2 files changed

Lines changed: 41 additions & 3 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
import { defineConfig } from 'vitest/config';
4+
5+
export default defineConfig({
6+
test: {
7+
globals: true,
8+
environment: 'node',
9+
},
10+
});

packages/spec/scripts/build-schemas.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,38 @@ function writeFileWithRetry(filePath: string, content: string, retries = MAX_RET
8080
// Clean output directory ensures no stale files remain
8181
if (fs.existsSync(OUT_DIR)) {
8282
console.log(`Cleaning output directory: ${OUT_DIR}`);
83-
fs.rmSync(OUT_DIR, { recursive: true, force: true, maxRetries: MAX_RETRIES, retryDelay: RETRY_DELAY_BASE_MS });
84-
83+
84+
// Use a more robust cleanup with multiple retries and longer delays
85+
// to handle filesystem race conditions in CI environments
86+
let cleanupSuccess = false;
87+
for (let attempt = 0; attempt < MAX_RETRIES * 2; attempt++) {
88+
try {
89+
// Try removing with native Node.js rmSync
90+
if (fs.existsSync(OUT_DIR)) {
91+
fs.rmSync(OUT_DIR, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 });
92+
}
93+
94+
// Verify the directory is actually gone
95+
if (!fs.existsSync(OUT_DIR)) {
96+
cleanupSuccess = true;
97+
break;
98+
}
99+
100+
// If still exists, wait before retrying
101+
sleepSync(100 * (attempt + 1));
102+
} catch (error) {
103+
// If this is the last attempt, log but continue (we'll try to work with what's there)
104+
if (attempt === (MAX_RETRIES * 2 - 1)) {
105+
console.warn(`Warning: Failed to fully clean directory after ${attempt + 1} attempts:`, error);
106+
// Try to continue anyway - ensureDir will create missing parts
107+
break;
108+
}
109+
// Wait before retry with exponential backoff
110+
sleepSync(100 * (attempt + 1));
111+
}
112+
}
113+
85114
// Wait a bit to ensure file system has synced
86-
// This prevents ENOENT errors on some file systems, particularly in CI environments
87115
sleepSync(FS_SYNC_DELAY_MS);
88116
}
89117

0 commit comments

Comments
 (0)