From 0241e453a30ef6c3341f262fb8ad46da03db74c4 Mon Sep 17 00:00:00 2001 From: Aleksandr Pasevin Date: Thu, 27 Nov 2025 12:17:24 +0200 Subject: [PATCH] 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) --- scripts/update-export-versions.cjs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/scripts/update-export-versions.cjs b/scripts/update-export-versions.cjs index ba272a32..67860b4d 100644 --- a/scripts/update-export-versions.cjs +++ b/scripts/update-export-versions.cjs @@ -77,13 +77,15 @@ const updateVersionsFile = () => { if (versionsUpdated) { fs.writeFileSync(versionsFilePath, fileContent, 'utf8'); console.log('\n🎉 Successfully synchronized versions.ts!'); + + // Only update snapshots when versions actually changed + // This requires packages to be built, so we only do it when necessary + console.log('\n📸 Updating snapshots to match new versions...'); + updateSnapshots(); } else { console.log('\n✅ All versions in versions.ts are already up to date.'); + console.log(' Skipping snapshot update (no version changes detected).'); } - - // Always update snapshots to ensure they match current versions - console.log('\n📸 Ensuring snapshots match current versions...'); - updateSnapshots(); }; const updateSnapshots = () => { @@ -99,9 +101,14 @@ const updateSnapshots = () => { console.log('✅ Snapshots updated successfully!'); } catch (error) { console.error('❌ Failed to update snapshots:', error.message); - console.log( - '⚠️ Please run "pnpm --filter @openzeppelin/ui-builder-app test src/export/__tests__/ -- -u" manually' + console.error( + '⚠️ Snapshot update failed. This will cause CI failures if versions.ts is committed without matching snapshots.' + ); + console.error( + ' To fix manually, run: pnpm --filter @openzeppelin/ui-builder-app test src/export/__tests__/ -- -u' ); + // Exit with error code to prevent committing mismatched versions + process.exit(1); } };