Skip to content

Commit 61f1f4d

Browse files
justin808claude
andauthored
Fix CI change detection for generator files (#2189)
## Summary - Fixes CI not running generator tests when generator files change - Moves the Generators pattern before Ruby source code in the case statement (bash uses first-match-wins) - Adds generator spec paths (`react_on_rails/spec/react_on_rails/generators/*`) to the Generators pattern ## Problem The `ci-changes-detector` script was not properly detecting 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 were not included in the Generators pattern As a result, when files like `lib/generators/react_on_rails/generator_helper.rb` changed, the `run_generators` flag remained `false`. ## Solution 1. Reorder case patterns so Generators comes before Ruby source code 2. Add generator spec paths to the Generators pattern ## Test plan - [x] Tested locally that generator files now trigger `run_generators=true` - [x] Tested that non-generator Ruby files still correctly trigger `run_ruby_tests=true` - [x] Tested that generator spec files trigger `run_generators=true` Fixes #2187 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 1eb5b3f commit 61f1f4d

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

script/ci-changes-detector

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ fi
5555
DOCS_ONLY=true
5656
LINT_CONFIG_CHANGED=false
5757
PRO_LINT_CONFIG_CHANGED=false
58-
RUBY_CHANGED=false
58+
RUBY_CORE_CHANGED=false
5959
RSPEC_CHANGED=false
6060
SPEC_DUMMY_CHANGED=false
6161
JS_CHANGED=false
62-
GENERATORS_CHANGED=false # needs to be duplicated to pro
63-
PRO_RUBY_CHANGED=false
62+
GENERATORS_CHANGED=false
63+
PRO_RUBY_CORE_CHANGED=false
6464
PRO_RSPEC_CHANGED=false
6565
PRO_JS_CHANGED=false
6666
PRO_DUMMY_CHANGED=false
@@ -75,22 +75,22 @@ while IFS= read -r file; do
7575
# Don't change DOCS_ONLY flag, just continue
7676
;;
7777

78-
# Ruby source code
79-
react_on_rails/lib/*.rb|react_on_rails/lib/**/*.rb|Gemfile|Gemfile.lock|rakelib/run_rspec.rake|rakelib/node_package.rake|rakelib/dummy_apps.rake)
78+
# Generators (MUST be before Ruby source code to avoid being caught by lib/**/*.rb)
79+
react_on_rails/lib/generators/*|react_on_rails/lib/generators/**/*|react_on_rails/spec/react_on_rails/generators/*|react_on_rails/spec/react_on_rails/generators/**/*|rakelib/example_type.rb|rakelib/examples_config.yml|rakelib/shakapacker_examples.rake|.github/workflows/examples.yml)
8080
DOCS_ONLY=false
81-
RUBY_CHANGED=true
81+
GENERATORS_CHANGED=true
8282
;;
8383

84-
# Ruby gem-specific specs
85-
react_on_rails/spec/react_on_rails/*|react_on_rails/spec/react_on_rails/**/*|.github/workflows/gem-tests.yml)
84+
# Ruby core source code (non-generator lib files)
85+
react_on_rails/lib/*.rb|react_on_rails/lib/**/*.rb|Gemfile|Gemfile.lock|rakelib/run_rspec.rake|rakelib/node_package.rake|rakelib/dummy_apps.rake)
8686
DOCS_ONLY=false
87-
RSPEC_CHANGED=true
87+
RUBY_CORE_CHANGED=true
8888
;;
8989

90-
# Generators
91-
react_on_rails/lib/generators/*|react_on_rails/lib/generators/**/*|rakelib/example_type.rb|rakelib/examples_config.yml|rakelib/shakapacker_examples.rake|.github/workflows/examples.yml)
90+
# Ruby gem-specific specs (MUST be after Generators since this pattern catches ALL specs including generator specs)
91+
react_on_rails/spec/react_on_rails/*|react_on_rails/spec/react_on_rails/**/*|.github/workflows/gem-tests.yml)
9292
DOCS_ONLY=false
93-
GENERATORS_CHANGED=true
93+
RSPEC_CHANGED=true
9494
;;
9595

9696
# JavaScript/TypeScript source (including tests, scripts, and package files)
@@ -108,7 +108,7 @@ while IFS= read -r file; do
108108
# React on Rails Pro source code
109109
react_on_rails_pro/lib/*|react_on_rails_pro/lib/**/*)
110110
DOCS_ONLY=false
111-
PRO_RUBY_CHANGED=true
111+
PRO_RUBY_CORE_CHANGED=true
112112
;;
113113

114114
# JavaScript/TypeScript Pro source (including tests, scripts, and package files)
@@ -151,11 +151,11 @@ while IFS= read -r file; do
151151
# Changes to CI infrastructure should trigger tests to validate the changes work
152152
script/*|script/**/*|bin/*|bin/**/*|.github/workflows/*|.github/actions/*|.github/actions/**/*|lefthook.yml)
153153
DOCS_ONLY=false
154-
RUBY_CHANGED=true # Trigger all tests for CI infrastructure changes
154+
RUBY_CORE_CHANGED=true # Trigger all tests for CI infrastructure changes
155155
JS_CHANGED=true
156156
SPEC_DUMMY_CHANGED=true
157157
GENERATORS_CHANGED=true
158-
PRO_RUBY_CHANGED=true
158+
PRO_RUBY_CORE_CHANGED=true
159159
PRO_JS_CHANGED=true
160160
PRO_DUMMY_CHANGED=true
161161
;;
@@ -223,14 +223,14 @@ if [ "$DOCS_ONLY" = true ]; then
223223
fi
224224

225225
echo "Changed file categories:"
226-
[ "$RUBY_CHANGED" = true ] && echo -e "${YELLOW} • Ruby source code${NC}"
226+
[ "$RUBY_CORE_CHANGED" = true ] && echo -e "${YELLOW} • Ruby core source code${NC}"
227227
[ "$JS_CHANGED" = true ] && echo -e "${YELLOW} • JavaScript/TypeScript code${NC}"
228228
[ "$RSPEC_CHANGED" = true ] && echo -e "${YELLOW} • RSpec tests${NC}"
229229
[ "$SPEC_DUMMY_CHANGED" = true ] && echo -e "${YELLOW} • Dummy app${NC}"
230230
[ "$GENERATORS_CHANGED" = true ] && echo -e "${YELLOW} • Generators${NC}"
231231
[ "$PRO_JS_CHANGED" = true ] && echo -e "${YELLOW} • React on Rails Pro JavaScript/TypeScript${NC}"
232232
[ "$PRO_RSPEC_CHANGED" = true ] && echo -e "${YELLOW} • React on Rails Pro RSpec tests${NC}"
233-
[ "$PRO_RUBY_CHANGED" = true ] && echo -e "${YELLOW} • React on Rails Pro Ruby source code${NC}"
233+
[ "$PRO_RUBY_CORE_CHANGED" = true ] && echo -e "${YELLOW} • React on Rails Pro Ruby core source code${NC}"
234234
[ "$PRO_DUMMY_CHANGED" = true ] && echo -e "${YELLOW} • React on Rails Pro Dummy app${NC}"
235235
[ "$PRO_NODE_RENDERER_CHANGED" = true ] && echo -e "${YELLOW} • React on Rails Pro Node Renderer package${NC}"
236236
[ "$LINT_CONFIG_CHANGED" = true ] && echo -e "${YELLOW} • Lint/format configuration${NC}"
@@ -251,39 +251,39 @@ RUN_PRO_TESTS=false
251251
RUN_PRO_DUMMY_TESTS=false
252252
RUN_PRO_NODE_RENDERER_TESTS=false
253253

254-
if [ "$LINT_CONFIG_CHANGED" = true ] || [ "$RUBY_CHANGED" = true ] || [ "$JS_CHANGED" = true ] || [ "$SPEC_DUMMY_CHANGED" = true ]; then
254+
if [ "$LINT_CONFIG_CHANGED" = true ] || [ "$RUBY_CORE_CHANGED" = true ] || [ "$JS_CHANGED" = true ] || [ "$SPEC_DUMMY_CHANGED" = true ]; then
255255
RUN_LINT=true
256256
fi
257257

258-
if [ "$RUBY_CHANGED" = true ] || [ "$RSPEC_CHANGED" = true ]; then
258+
if [ "$RUBY_CORE_CHANGED" = true ] || [ "$RSPEC_CHANGED" = true ] || [ "$GENERATORS_CHANGED" = true ]; then
259259
RUN_RUBY_TESTS=true
260260
fi
261261

262262
if [ "$JS_CHANGED" = true ]; then
263263
RUN_JS_TESTS=true
264264
fi
265265

266-
if [ "$SPEC_DUMMY_CHANGED" = true ] || [ "$RUBY_CHANGED" = true ] || [ "$JS_CHANGED" = true ]; then
266+
if [ "$SPEC_DUMMY_CHANGED" = true ] || [ "$RUBY_CORE_CHANGED" = true ] || [ "$JS_CHANGED" = true ]; then
267267
RUN_DUMMY_TESTS=true
268268
fi
269269

270270
if [ "$GENERATORS_CHANGED" = true ]; then
271271
RUN_GENERATORS=true
272272
fi
273273

274-
if [ "$PRO_LINT_CONFIG_CHANGED" = true ] || [ "$PRO_RUBY_CHANGED" = true ] || [ "$PRO_JS_CHANGED" = true ] || [ "$PRO_DUMMY_CHANGED" = true ] || [ "$RUBY_CHANGED" = true ]; then
274+
if [ "$PRO_LINT_CONFIG_CHANGED" = true ] || [ "$PRO_RUBY_CORE_CHANGED" = true ] || [ "$PRO_JS_CHANGED" = true ] || [ "$PRO_DUMMY_CHANGED" = true ] || [ "$RUBY_CORE_CHANGED" = true ]; then
275275
RUN_PRO_LINT=true
276276
fi
277277

278-
if [ "$PRO_RUBY_CHANGED" = true ] || [ "$PRO_RSPEC_CHANGED" = true ] || [ "$PRO_JS_CHANGED" = true ] || [ "$RUBY_CHANGED" = true ]; then
278+
if [ "$PRO_RUBY_CORE_CHANGED" = true ] || [ "$PRO_RSPEC_CHANGED" = true ] || [ "$PRO_JS_CHANGED" = true ] || [ "$RUBY_CORE_CHANGED" = true ]; then
279279
RUN_PRO_TESTS=true
280280
fi
281281

282-
if [ "$PRO_DUMMY_CHANGED" = true ] || [ "$PRO_RUBY_CHANGED" = true ] || [ "$PRO_JS_CHANGED" = true ] || [ "$RUBY_CHANGED" = true ]; then
282+
if [ "$PRO_DUMMY_CHANGED" = true ] || [ "$PRO_RUBY_CORE_CHANGED" = true ] || [ "$PRO_JS_CHANGED" = true ] || [ "$RUBY_CORE_CHANGED" = true ]; then
283283
RUN_PRO_DUMMY_TESTS=true
284284
fi
285285

286-
if [ "$PRO_NODE_RENDERER_CHANGED" = true ] || [ "$PRO_JS_CHANGED" = true ] || [ "$RUBY_CHANGED" = true ]; then
286+
if [ "$PRO_NODE_RENDERER_CHANGED" = true ] || [ "$PRO_JS_CHANGED" = true ] || [ "$RUBY_CORE_CHANGED" = true ]; then
287287
RUN_PRO_NODE_RENDERER_TESTS=true
288288
fi
289289

0 commit comments

Comments
 (0)