-
-
Notifications
You must be signed in to change notification settings - Fork 638
Fix CI change detection for generator files #2189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The ci-changes-detector script was failing to properly detect changes to generator files because: 1. The "Ruby source code" pattern (react_on_rails/lib/**/*.rb) matched generator files before the "Generators" pattern could match them 2. Generator spec files (react_on_rails/spec/react_on_rails/generators/*) were not included in the Generators pattern at all This fix: - Moves the Generators pattern BEFORE Ruby source code so it catches generator files first (bash case statements use first-match-wins) - Adds generator spec paths to the Generators pattern - Adds clarifying comments about pattern ordering Now when generator files or generator specs change, the `run_generators` flag is properly set to true, triggering the appropriate CI workflows. Fixes #2187 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Warning Rate limit exceeded@justin808 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 14 minutes and 18 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Code Review - PR #2189: Fix CI change detection for generator files✅ SummaryThis PR fixes a critical bug where CI wasn't running generator tests when generator files changed. The solution is elegant and correct: reordering case statement patterns to ensure generator files are matched before the broader Ruby source code pattern. 🎯 CorrectnessProblem identification: Excellent
Solution: Correct
Pattern matching validation:
📝 Code QualityStrengths:
Best practices:
🧪 TestingTest plan validation:
Testing recommendation: # Generator source → GENERATORS_CHANGED
react_on_rails/lib/generators/react_on_rails/generator_helper.rb
# Generator spec → GENERATORS_CHANGED
react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb
# Non-generator Ruby → RUBY_CHANGED
react_on_rails/lib/react_on_rails/configuration.rbHowever, the logic is straightforward enough that manual testing is sufficient. 🔒 Security & PerformanceSecurity: ✅ No security concerns
Performance: ✅ No performance impact
🎨 Potential Improvements (Optional)1. Pattern duplication in comments (line 90 comment) Consider clarifying: # Ruby gem-specific specs (MUST be after Generators since this catches ALL specs including generator specs)2. Pro generators (optional future work) ✅ Final VerdictLGTM with high confidence. This is a well-executed bug fix that:
Recommendation: Approve and merge. The fix is correct and complete. 📚 Related
🤖 Generated by Claude Code |
Code ReviewSummaryThis PR fixes a critical bug in CI change detection where generator files weren't triggering generator tests. The fix is correct and well-implemented. ✅ ✅ What This PR Does Right
🔍 Code Quality AnalysisPattern Matching Logic: # BEFORE (broken):
react_on_rails/lib/**/*.rb # Matches lib/generators/foo.rb first ❌
react_on_rails/lib/generators/* # Never reached for generator files
# AFTER (fixed):
react_on_rails/lib/generators/* # Matches generators first ✅
react_on_rails/lib/**/*.rb # Only matches non-generator lib filesThe fix follows the correct pattern for bash case statements: most specific patterns first, more general patterns later. 🧪 Testing ValidationThe PR description claims local testing was done. To verify the fix works, these commands should confirm proper detection: # Test 1: Generator file should trigger run_generators=true
echo 'react_on_rails/lib/generators/react_on_rails/generator_helper.rb' | \
./script/ci-changes-detector origin/master
# Test 2: Generator spec should trigger run_generators=true
echo 'react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb' | \
./script/ci-changes-detector origin/master
# Test 3: Regular Ruby file should NOT trigger run_generators (only run_ruby_tests)
echo 'react_on_rails/lib/react_on_rails/helper.rb' | \
./script/ci-changes-detector origin/masterRecommendation: Consider adding these as automated tests in a future PR to prevent regression. 🎯 Adherence to CLAUDE.md Guidelines
🚨 Potential Concerns (Minor)
📊 Impact AssessmentRisk Level: 🟢 Low Risk
Blast Radius: 🟡 Medium Impact
✅ Final VerdictLGTM - Approved 👍 This is a clean, well-documented fix for a real bug. The approach is correct, the implementation is sound, and the PR description is excellent. Recommendation: Merge once CI passes. 🔮 Future Enhancements (Optional, Out of Scope)For future consideration:
Great work tracking down this subtle pattern-matching bug! 🎉 |
- Remove outdated TODO comment about duplicating to pro (Pro has no generators) - Clarify RSpec pattern comment to explain it catches ALL specs 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Generator unit tests (spec/react_on_rails/generators/*_spec.rb) are run by gem-tests.yml, which checks run_ruby_tests. Previously, generator file changes only set run_generators (used by examples.yml) but not run_ruby_tests, so generator specs wouldn't run. Now GENERATORS_CHANGED also triggers RUN_RUBY_TESTS=true. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The variable name RUBY_CHANGED was ambiguous since generators are also Ruby files. Renaming to RUBY_CORE_CHANGED makes it clear this refers to non-generator lib files (react_on_rails/lib/**/*.rb excluding react_on_rails/lib/generators/). This clarifies the logic in the condition: if RUBY_CORE_CHANGED || RSPEC_CHANGED || GENERATORS_CHANGED Each flag now clearly represents a distinct category of Ruby code. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Code Review: Fix CI change detection for generator filesSummaryThis PR correctly fixes a critical bug in the CI change detection logic where generator file changes weren't triggering the appropriate test suite. The solution is sound and well-implemented. ✅ Strengths
🔍 Areas for Improvement1. CRITICAL: Missing Test CoverageThis script is critical CI infrastructure that determines which test suites run. However, it has zero test coverage. According to CLAUDE.md:
Recommendation: Add a test suite for this script: # spec/script/ci_changes_detector_spec.sh or similar
# Test cases:
# 1. Generator file changes → run_generators=true
# 2. Generator spec changes → run_generators=true
# 3. Non-generator lib file changes → run_ruby_tests=true, run_generators=false
# 4. Multiple file types → correct flags setThis would prevent future regressions and give confidence that the fix actually works. 2. Manual Testing ValidationThe PR description mentions local testing, but doesn't show the actual commands/output. For a CI infrastructure change, I'd expect to see: # Test 1: Generator file triggers run_generators
echo "lib/generators/react_on_rails/generator_helper.rb" | ./script/ci-changes-detector
# Expected: run_generators=true
# Test 2: Non-generator lib file doesn't trigger run_generators
echo "lib/react_on_rails/configuration.rb" | ./script/ci-changes-detector
# Expected: run_generators=false, run_ruby_tests=trueRecommendation: Document the actual test commands and outputs in the PR description or as a comment. 3. Pattern SpecificityThe current pattern matching is somewhat fragile: # Line 79: Very broad glob patterns
react_on_rails/lib/generators/*|react_on_rails/lib/generators/**/*This works, but bash case patterns don't support negative lookaheads. If someone added a file like Recommendation: Consider documenting the expected directory structure or adding a comment about the pattern assumptions. 4. Potential Edge Case: Mixed ChangesWhen a PR changes both generator files AND non-generator lib files, both 🎯 Validation ChecklistBefore merging, please verify:
🔒 Security & Performance
📝 DocumentationThe inline comments are excellent and explain the reasoning behind the pattern ordering. Consider adding a brief note to the project's CI documentation about how this detection works. ✅ VerdictLGTM with minor recommendations. The core fix is correct and solves the reported issue. The main improvement would be adding automated tests for this critical CI infrastructure to prevent future regressions. The refactoring from Related: This fix should be backported to any long-lived release branches if applicable, as generator test coverage is important for release quality. |
Summary
react_on_rails/spec/react_on_rails/generators/*) to the Generators patternProblem
The
ci-changes-detectorscript was not properly detecting changes to generator files because:react_on_rails/lib/**/*.rb) matched generator files before the "Generators" pattern could match themAs a result, when files like
lib/generators/react_on_rails/generator_helper.rbchanged, therun_generatorsflag remainedfalse.Solution
Test plan
run_generators=truerun_ruby_tests=truerun_generators=trueFixes #2187
🤖 Generated with Claude Code