Skip to content

Commit da62caa

Browse files
authored
fix: enhance optimizer bundle generation verification (#1451)
Fixes #1360 The previous CI verification using `git diff` could not detect new untracked files added to the brick. This caused PR #1344 to pass CI with a stale bundle, which was later discovered in PR #1358. Changes: - Replace simple `git diff` with comprehensive two-part verification - Check for both modifications AND untracked/deleted bundle files - Add bundle file path to workflow triggers for direct changes - Improve error messages with clear remediation steps The new verification now catches: - Modified brick files (existing behavior) - New brick files added (NEW - fixes the bug) - Deleted brick files (existing behavior) - Incorrect output paths (NEW) - Direct bundle modifications (improved) This ensures the committed bundle always matches what the current brick source would generate, preventing silent bundle drift.
1 parent a7db1d8 commit da62caa

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

.github/workflows/test_optimizer.yaml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ on:
99
paths:
1010
- .github/workflows/test_optimizer.yaml
1111
- "bricks/test_optimizer/**"
12+
- "lib/src/cli/templates/test_optimizer_bundle.dart"
1213
branches:
1314
- main
1415
pull_request:
1516
paths:
1617
- .github/workflows/test_optimizer.yaml
1718
- "bricks/test_optimizer/**"
19+
- "lib/src/cli/templates/test_optimizer_bundle.dart"
1820
branches:
1921
- main
2022

@@ -40,5 +42,27 @@ jobs:
4042
- name: Run bundle generate
4143
run: tool/generate_test_optimizer_bundle.sh
4244

43-
- name: Check for unbundled changes
44-
run: git diff --exit-code --quiet || { echo "::error::Changes detected on the test_optimizer brick. Please run tool/generate_test_optimizer_bundle.sh to bundle these changes"; exit 1; }
45+
- name: Verify bundle is up to date
46+
run: |
47+
# Check for modifications to the bundle file
48+
if ! git diff --exit-code --quiet lib/src/cli/templates/test_optimizer_bundle.dart; then
49+
echo "::error::test_optimizer_bundle.dart has uncommitted changes after regeneration"
50+
echo "::error::The bundle is out of sync with the brick source in bricks/test_optimizer/"
51+
echo "::error::Please run 'tool/generate_test_optimizer_bundle.sh' and commit the updated bundle"
52+
echo ""
53+
echo "Changes detected:"
54+
git diff lib/src/cli/templates/test_optimizer_bundle.dart
55+
exit 1
56+
fi
57+
58+
# Check for untracked or deleted bundle files
59+
if git status --porcelain lib/src/cli/templates/ | grep -q '^[?!].*test_optimizer_bundle.dart'; then
60+
echo "::error::test_optimizer_bundle.dart has untracked or deleted changes"
61+
echo "::error::The bundle file may be missing or newly created"
62+
echo "::error::Please run 'tool/generate_test_optimizer_bundle.sh' and commit the updated bundle"
63+
echo ""
64+
git status lib/src/cli/templates/
65+
exit 1
66+
fi
67+
68+
echo "✅ Bundle verification passed - bundle is up to date with brick source"

0 commit comments

Comments
 (0)