Skip to content

Commit 73739f4

Browse files
committed
fix: enhance README update logic in compare-and-update-readme.ts
- Added checks to prevent README updates when current benchmark results are invalid or missing. - Improved handling of scenarios where benchmarks are skipped, ensuring clear console logs and accurate output flags. - This change enhances the robustness of the README update process by avoiding unnecessary updates when data is not available.
1 parent f12693f commit 73739f4

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

scripts/compare-and-update-readme.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ function shouldUpdateReadme(
126126
current: BenchmarkResults,
127127
previous: BenchmarkResults | null
128128
): boolean {
129+
// Don't update README if we don't have valid current results
130+
if (!current || !current.tools) return false;
129131
// Always update README with latest benchmark results
130132
return true;
131133
}
@@ -135,6 +137,7 @@ function hasSignificantChanges(
135137
previous: BenchmarkResults | null
136138
): boolean {
137139
if (!previous || !previous.tools) return true; // First run, always significant
140+
if (!current || !current.tools) return false; // No current data, no changes
138141

139142
// Check if there's any significant change in any tool
140143
const toolNames: ToolName[] = ['nx', 'turbo', 'lerna', 'lage'];
@@ -160,6 +163,20 @@ function main(): ComparisonOutputs {
160163
process.exit(1);
161164
}
162165

166+
// Check if current results are empty (benchmark was skipped)
167+
const hasCurrentData = currentResults && currentResults.tools;
168+
169+
if (!hasCurrentData) {
170+
console.log('No benchmark data available (benchmark was skipped)');
171+
console.log('README not updated');
172+
process.stdout.write('readme-updated=false\n');
173+
process.stdout.write('performance-regression=false\n');
174+
return {
175+
readmeUpdated: false,
176+
performanceRegression: false,
177+
};
178+
}
179+
163180
const shouldUpdate = shouldUpdateReadme(currentResults, previousResults);
164181
const significantChanges = hasSignificantChanges(
165182
currentResults,

0 commit comments

Comments
 (0)