Skip to content

Commit 0241e45

Browse files
committed
fix(scripts): fail update-export-versions if snapshot update fails
The script was silently swallowing errors when snapshot updates failed, causing versions.ts to be committed without matching snapshots. This led to CI failures in the coverage workflow. Changes: - Exit with code 1 if snapshot update fails - Only update snapshots when versions actually changed (avoids requiring build for check-only workflows)
1 parent fbc8ecd commit 0241e45

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

scripts/update-export-versions.cjs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,15 @@ const updateVersionsFile = () => {
7777
if (versionsUpdated) {
7878
fs.writeFileSync(versionsFilePath, fileContent, 'utf8');
7979
console.log('\n🎉 Successfully synchronized versions.ts!');
80+
81+
// Only update snapshots when versions actually changed
82+
// This requires packages to be built, so we only do it when necessary
83+
console.log('\n📸 Updating snapshots to match new versions...');
84+
updateSnapshots();
8085
} else {
8186
console.log('\n✅ All versions in versions.ts are already up to date.');
87+
console.log(' Skipping snapshot update (no version changes detected).');
8288
}
83-
84-
// Always update snapshots to ensure they match current versions
85-
console.log('\n📸 Ensuring snapshots match current versions...');
86-
updateSnapshots();
8789
};
8890

8991
const updateSnapshots = () => {
@@ -99,9 +101,14 @@ const updateSnapshots = () => {
99101
console.log('✅ Snapshots updated successfully!');
100102
} catch (error) {
101103
console.error('❌ Failed to update snapshots:', error.message);
102-
console.log(
103-
'⚠️ Please run "pnpm --filter @openzeppelin/ui-builder-app test src/export/__tests__/ -- -u" manually'
104+
console.error(
105+
'⚠️ Snapshot update failed. This will cause CI failures if versions.ts is committed without matching snapshots.'
106+
);
107+
console.error(
108+
' To fix manually, run: pnpm --filter @openzeppelin/ui-builder-app test src/export/__tests__/ -- -u'
104109
);
110+
// Exit with error code to prevent committing mismatched versions
111+
process.exit(1);
105112
}
106113
};
107114

0 commit comments

Comments
 (0)