Skip to content

Conversation

@justin808
Copy link
Member

@justin808 justin808 commented Nov 5, 2025

Summary

This PR addresses two critical CI issues:

  1. Fixes generator validation failing in CI - The examples workflow was failing on master with "No React on Rails npm package is installed" error
  2. Adds workflow_dispatch to all CI workflows - Enables manual workflow runs on any branch via GitHub Actions UI

Changes

1. Fix Generator Validation in CI

Problem: The shakapacker_examples.rake task was calling rails generate as a shell command, which spawned a new process without the REACT_ON_RAILS_SKIP_VALIDATION environment variable set. This caused validation to run before the npm package was installed, resulting in CI failures.

Solution: Modified the rake task to prefix generator commands with REACT_ON_RAILS_SKIP_VALIDATION=true, ensuring validation is skipped during the npm package installation phase.

File changed: rakelib/shakapacker_examples.rake

# Set ENV variable to skip validation during generator run since npm package isn't installed yet
generator_commands = example_type.generator_shell_commands.map do |cmd|
  "REACT_ON_RAILS_SKIP_VALIDATION=true #{cmd}"
end
sh_in_dir(example_type.dir, generator_commands)

This complements the existing validation skip logic added in PR #1923, which handled direct generator invocations but not shell command invocations.

2. Add workflow_dispatch to All CI Workflows

Benefit: Developers can now manually trigger any CI workflow on any branch from the GitHub Actions UI, making it easier to:

  • Test changes on feature branches without opening a PR
  • Re-run specific workflows without triggering all CI
  • Debug CI issues more efficiently

Files changed:

  • .github/workflows/main.yml
  • .github/workflows/lint-js-and-ruby.yml
  • .github/workflows/rspec-package-specs.yml
  • .github/workflows/package-js-tests.yml
  • .github/workflows/pro-integration-tests.yml
  • .github/workflows/pro-package-tests.yml
  • .github/workflows/pro-lint.yml

Test Plan

  • Local RuboCop passes
  • Git hooks pass (trailing newlines, prettier, rubocop)
  • CI examples workflow passes on this PR
  • Verify workflow_dispatch appears in GitHub Actions UI for all workflows

Related Issues

  • Fixes CI failures on master (examples workflow)
  • Addresses request to make CI configurable to run on any branch

🤖 Generated with Claude Code


This change is Reviewable

Summary by CodeRabbit

  • Chores
    • Enhanced continuous integration workflows to support manual execution triggers in addition to existing automatic event-based activation.
    • Optimized internal build tooling to improve generator command execution with environment-specific configuration handling.

This commit addresses two critical CI issues:

1. **Fix generator validation failing in CI**:
   - The rake task that generates example apps was calling `rails generate`
     as a shell command, which spawned a new process without the
     REACT_ON_RAILS_SKIP_VALIDATION environment variable set
   - Modified shakapacker_examples.rake to prefix generator commands with
     the ENV variable so validation is skipped during npm package installation
   - This resolves the "No React on Rails npm package is installed" error
     that was breaking the examples workflow on master

2. **Add workflow_dispatch to all CI workflows**:
   - Added workflow_dispatch trigger to enable manual workflow runs on any
     branch via GitHub Actions UI
   - This makes CI testing more flexible and allows developers to test
     changes on feature branches without needing to open a PR
   - Updated workflows: main.yml, lint-js-and-ruby.yml,
     rspec-package-specs.yml, package-js-tests.yml, pro-integration-tests.yml,
     pro-package-tests.yml, pro-lint.yml

The generator validation fix complements the existing skip logic added in
PR #1923 which only handled direct generator invocations, not shell command
invocations.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 5, 2025

Walkthrough

The pull request adds workflow_dispatch triggers to seven GitHub Actions workflow files to enable manual execution, and modifies a Rake task to prefix generator shell commands with the REACT_ON_RAILS_SKIP_VALIDATION environment variable.

Changes

Cohort / File(s) Summary
GitHub Actions Workflow Dispatch Additions
.github/workflows/lint-js-and-ruby.yml, .github/workflows/main.yml, .github/workflows/package-js-tests.yml, .github/workflows/pro-integration-tests.yml, .github/workflows/pro-lint.yml, .github/workflows/pro-package-tests.yml, .github/workflows/rspec-package-specs.yml
Adds workflow_dispatch trigger to enable manual triggering of workflows via GitHub Actions UI, while maintaining existing push and pull_request event triggers. No changes to job logic or step execution.
Rake Task Environment Variable Handling
rakelib/shakapacker_examples.rake
Transforms generator shell commands to prefix each with REACT_ON_RAILS_SKIP_VALIDATION=true, ensuring validation is skipped in isolated command environments. Updates command array passing to use a generated generator_commands array passed to sh_in_dir.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Workflow dispatch additions are repetitive configuration changes with minimal risk
  • Rake file modification involves environment variable scoping; verify that command prefixing achieves intended validation-skipping behavior without side effects

Possibly related PRs

Suggested labels

bug

Suggested reviewers

  • Judahmeek
  • alexeyr-ci2
  • AbanoubGhadban

Poem

🐰 Workflows now dance at the flip of a switch,
Manual triggers make pipelines rich,
Validation skipped with env vars so keen,
The smoothest CI you've ever seen! ✨

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately reflects both main changes: fixing CI generator validation failures and adding workflow_dispatch triggers to enable manual workflow runs.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch justin808/next2

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb16495 and 5d89c48.

📒 Files selected for processing (8)
  • .github/workflows/lint-js-and-ruby.yml (1 hunks)
  • .github/workflows/main.yml (1 hunks)
  • .github/workflows/package-js-tests.yml (1 hunks)
  • .github/workflows/pro-integration-tests.yml (1 hunks)
  • .github/workflows/pro-lint.yml (1 hunks)
  • .github/workflows/pro-package-tests.yml (1 hunks)
  • .github/workflows/rspec-package-specs.yml (1 hunks)
  • rakelib/shakapacker_examples.rake (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-04-26T21:55:55.874Z
Learnt from: alexeyr-ci2
Repo: shakacode/react_on_rails PR: 1732
File: spec/dummy/client/app-react16/startup/ReduxSharedStoreApp.client.jsx:40-44
Timestamp: 2025-04-26T21:55:55.874Z
Learning: In the react_on_rails project, files under `app-react16` directories are copied/moved to corresponding `/app` directories during the conversion process (removing the `-react16` suffix), which affects their relative import paths at runtime.

Applied to files:

  • .github/workflows/package-js-tests.yml
  • rakelib/shakapacker_examples.rake
📚 Learning: 2025-02-18T13:08:01.477Z
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1644
File: lib/react_on_rails/helper.rb:190-197
Timestamp: 2025-02-18T13:08:01.477Z
Learning: RSC support validation in React on Rails Pro is handled through a chain of validations:
1. Pro version check in `run_stream_inside_fiber`
2. RSC support check during pack generation via `ReactOnRailsPro.configuration.enable_rsc_support`
3. RSC support validation during component registration
This makes additional validation in the helper methods unnecessary.

Applied to files:

  • rakelib/shakapacker_examples.rake
📚 Learning: 2025-02-12T16:38:06.537Z
Learnt from: Romex91
Repo: shakacode/react_on_rails PR: 1697
File: package-scripts.yml:28-28
Timestamp: 2025-02-12T16:38:06.537Z
Learning: The file `node_package/lib/ReactOnRails.full.js` is autogenerated during the build process and should not be present in the repository.

Applied to files:

  • rakelib/shakapacker_examples.rake
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build
  • GitHub Check: claude-review
🔇 Additional comments (8)
.github/workflows/pro-integration-tests.yml (1)

8-8: LGTM! Manual workflow dispatch enabled.

The addition of workflow_dispatch: correctly enables manual triggering of this workflow from the GitHub Actions UI, which aligns with the PR objectives for easier CI debugging and testing on feature branches.

.github/workflows/pro-package-tests.yml (1)

8-8: LGTM! Manual workflow dispatch enabled.

Consistent with the other workflow updates in this PR. The workflow_dispatch: trigger is correctly placed and will enable manual runs of the Pro package tests workflow.

.github/workflows/pro-lint.yml (1)

8-8: LGTM! Manual workflow dispatch enabled.

The workflow_dispatch: trigger is correctly added, enabling manual execution of the Pro lint workflow.

.github/workflows/rspec-package-specs.yml (1)

18-18: LGTM! Manual workflow dispatch enabled.

The workflow_dispatch: trigger is correctly positioned and will enable manual triggering of the RSpec package tests workflow.

.github/workflows/package-js-tests.yml (1)

18-18: LGTM! Manual workflow dispatch enabled.

The workflow_dispatch: trigger is correctly added to enable manual runs of the JS unit tests workflow.

.github/workflows/lint-js-and-ruby.yml (1)

14-14: LGTM! Manual workflow dispatch enabled.

The workflow_dispatch: trigger is correctly added, enabling manual execution of the lint workflow for debugging and testing purposes.

.github/workflows/main.yml (1)

14-14: LGTM! Manual workflow dispatch enabled.

The workflow_dispatch: trigger is correctly added to the main test workflow, which is particularly valuable for manual CI runs and debugging.

rakelib/shakapacker_examples.rake (1)

40-55: Excellent fix with thorough documentation!

This change correctly addresses the CI validation failure by prefixing generator shell commands with REACT_ON_RAILS_SKIP_VALIDATION=true. The implementation is sound:

  • The environment variable is properly scoped to each shell command execution
  • The comments thoroughly explain the rationale and contrast with the Ruby process approach
  • The map operation cleanly transforms the commands without side effects
  • The POSIX shell syntax ENV_VAR=value command is correct and portable

This approach is simpler and safer than modifying the Ruby process environment, as each spawned shell gets its own environment without requiring cleanup.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@claude
Copy link

claude bot commented Nov 5, 2025

Code Review

I've reviewed this PR and here's my comprehensive feedback:

Overall Assessment

Approve with minor suggestions

This PR addresses two distinct but valuable improvements to the CI infrastructure. The changes are well-implemented and align with the repository's coding standards.


Part 1: Fix Generator Validation in CI

Code Quality & Best Practices ✅

Strengths:

  • Excellent fix: The solution correctly addresses the shell command invocation issue that PR Fix generator validation by using environment variable #1923 didn't cover
  • Consistent with existing pattern: Follows the same ENV variable approach already used in install_generator.rb:56
  • Clear documentation: The inline comment explains why the ENV variable is needed
  • Proper Ruby idiom: Uses .map to transform the array functionally

Implementation (rakelib/shakapacker_examples.rake:40-44):

# Set ENV variable to skip validation during generator run since npm package isn't installed yet
generator_commands = example_type.generator_shell_commands.map do |cmd|
  "REACT_ON_RAILS_SKIP_VALIDATION=true \#{cmd}"
end
sh_in_dir(example_type.dir, generator_commands)

Potential Issues ⚠️

Minor concern - ENV variable scope:
While the current implementation works, the ENV variable is set in the shell command string itself, meaning:

  1. Each command spawns a new shell process with the ENV variable
  2. The ENV variable doesn't persist between commands in the array
  3. This is actually the correct behavior for this use case

However, consider documenting this subtle difference from the generator approach:

  • Generator: Sets ENV in Ruby process, persists across all invoked generators, requires cleanup
  • Rake task: Sets ENV per-command in shell, automatically scoped, no cleanup needed

Performance Considerations ⚡

Positive impact:

  • Prevents validation from running unnecessarily during setup
  • No performance overhead - just string interpolation

Security Concerns 🔒

Low risk:

  • ENV variable is only used to skip validation, not to inject commands
  • If generator_shell_commands were to contain user input, there could be command injection risks, but reviewing example_type.rb:69-73, the commands are hardcoded
  • Consider: If this pattern is ever used with dynamic input, proper shell escaping would be needed

Test Coverage 📋

Missing:

  • No explicit test coverage for the rake task behavior
  • However, the CI workflow itself serves as an integration test

Suggestion:
Consider adding a comment in the test plan or documentation that CI serves as the integration test for this fix.


Part 2: Add workflow_dispatch to Workflows

Code Quality & Best Practices ✅

Strengths:

  • Developer experience improvement: Huge QoL improvement for debugging CI issues
  • Consistent application: Applied to all 7 workflows systematically
  • Zero behavioral impact: Only adds manual trigger capability, doesn't change automatic triggers
  • Standard GitHub Actions practice: workflow_dispatch is a well-established GitHub feature

Implementation Review ✅

All workflow files correctly updated:

  • .github/workflows/main.yml
  • .github/workflows/lint-js-and-ruby.yml
  • .github/workflows/rspec-package-specs.yml
  • .github/workflows/package-js-tests.yml
  • .github/workflows/pro-integration-tests.yml
  • .github/workflows/pro-package-tests.yml
  • .github/workflows/pro-lint.yml

Format is correct:

on:
  push:
    branches: ['master']
  pull_request:
  workflow_dispatch:  # ✅ Correctly placed

Potential Issues ✅

None identified - this is a straightforward addition with no downsides.

Performance Considerations ⚡

Neutral:

  • No performance impact on automatic runs
  • Manual runs have same performance as PR-triggered runs

Security Concerns 🔒

Low risk:

  • workflow_dispatch respects repository permissions
  • Only users with write access can trigger workflows manually
  • This is standard practice in GitHub Actions

Additional Suggestions

1. Consider ENV Variable Cleanup (Optional)

While not necessary for the rake task implementation, if you ever need the ENV variable to persist across multiple sh_in_dir calls, consider the generator pattern with cleanup:

# Not needed now, but documented for future reference
begin
  ENV["REACT_ON_RAILS_SKIP_VALIDATION"] = "true"
  sh_in_dir(example_type.dir, commands1)
  sh_in_dir(example_type.dir, commands2)
ensure
  ENV.delete("REACT_ON_RAILS_SKIP_VALIDATION")
end

2. Documentation Enhancement

Consider adding a note to the CI documentation or README about the new workflow_dispatch capability:

  • How to use it (GitHub Actions UI → Run workflow)
  • When it's useful (testing branches, debugging CI issues)
  • That it requires write access

3. Test Plan Item

Update the test plan to explicitly mention that this fix is being tested by CI itself:

  • CI examples workflow passes on this PR ← This validates the fix

Compliance with CLAUDE.md ✅

  • ✅ Code follows RuboCop standards (git hooks will verify)
  • ✅ Files end with newlines (will be verified by hooks)
  • ✅ Changes align with repository conventions
  • ✅ PR description follows the format guidelines
  • ✅ Appropriate for CHANGELOG.md (this is a bug fix)

Final Recommendation

✅ LGTM - Approve and Merge

This is a well-crafted PR that:

  1. Fixes a real CI issue with an elegant solution
  2. Improves developer experience with workflow_dispatch
  3. Follows repository standards
  4. Includes clear documentation

The changes are low-risk, well-tested (by CI itself), and provide immediate value. Great work!


Minor follow-ups (can be done in future PRs if desired):

  • Document the workflow_dispatch feature for other contributors
  • Consider adding explicit test coverage for the rake task behavior (though CI serves this purpose)

Generated with Claude Code

Added comprehensive comment explaining why we prefix shell commands with
the ENV variable rather than setting it in the Ruby process:

1. Each shell command spawns a new process with its own environment
2. ENV variable is automatically scoped to each command (no cleanup needed)
3. Simpler and safer than the generator approach which requires explicit
   ENV cleanup

This addresses potential confusion about ENV variable scope differences
between the rake task approach and the generator approach in
lib/generators/react_on_rails/install_generator.rb.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@claude
Copy link

claude bot commented Nov 5, 2025

Code Review - PR #1928

Overall Assessment

This PR makes two distinct improvements: fixing a critical CI validation issue and adding workflow_dispatch to CI workflows. The changes are well-documented and follow the project's coding standards.


Part 1: Fix Generator Validation Issue ✅

File: rakelib/shakapacker_examples.rake

Strengths

  1. Correct Problem Diagnosis: The issue was properly identified - shell commands spawn new processes without inheriting the ENV variable
  2. Appropriate Solution: Prefixing commands with the ENV variable is the correct approach for shell invocations
  3. Excellent Documentation: The inline comments (lines 41-51) clearly explain why the validation needs to be skipped, why this approach differs from the generator approach, and the scoping benefits
  4. Consistency with Existing Pattern: Aligns with the validation skip logic in lib/generators/react_on_rails/install_generator.rb and lib/react_on_rails/engine.rb
  5. Clean Implementation: Using .map to transform the commands array is idiomatic Ruby

Code Quality

The implementation is clean and maintainable. The use of string interpolation to prefix each command ensures the ENV variable is properly scoped to each shell process.

Potential Considerations

  1. Cross-platform compatibility: This approach works on Linux/macOS but might have issues on Windows. However, the codebase appears to be POSIX-focused, so this is acceptable.
  2. Security consideration: The commands come from example_type.generator_shell_commands, which generates hardcoded commands. No user input is involved, so no injection risk.
  3. Testing: While there are no direct tests for rake tasks, the existing test coverage in spec/react_on_rails/engine_spec.rb validates that the ENV variable works correctly.

Part 2: Add workflow_dispatch ✅

Files: All .github/workflows/*.yml files

Strengths

  1. Consistent Implementation: Applied uniformly across all 7 workflow files
  2. Proper Placement: Added after the existing triggers, maintaining YAML structure
  3. No Breaking Changes: This is purely additive - doesn't modify existing behavior
  4. Developer Experience: Significantly improves testing capabilities for developers

Security Considerations

No security concerns identified

  1. workflow_dispatch respects GitHub's permission model - only users with write access can trigger workflows
  2. No new secrets or sensitive data exposed
  3. ENV variable manipulation is safe (no user input, scoped to build process)

Performance Considerations

Neutral to slightly positive impact

  1. The rake task change has no runtime overhead - it's just a string prefix
  2. workflow_dispatch adds no automatic triggers - only enables manual runs
  3. The fix should actually improve CI reliability by preventing validation failures

Test Coverage

Current State: Adequate

  • ✅ ENV variable validation logic has comprehensive test coverage (engine_spec.rb:16-78)
  • ✅ The rake task will be validated by CI on this PR
  • ⚠️ No unit tests for rake tasks themselves (but this is typical for rake tasks that orchestrate shell commands)

CLAUDE.md Compliance Check

Fully compliant with repository guidelines

  • Ruby code follows RuboCop standards
  • Proper documentation/comments included
  • Uses proper Ruby idioms (map, string interpolation)
  • YAML syntax is valid

Recommendation

✅ APPROVE - Ready to merge

This PR:

  1. Solves a real CI issue with a proper, well-documented fix
  2. Adds useful functionality (workflow_dispatch) with zero risk
  3. Maintains code quality and follows project conventions
  4. Has appropriate documentation
  5. Will be validated by CI before merge

The changes are low-risk, high-value improvements. Once CI passes, this can be merged with confidence.

Great work on identifying and fixing these issues! 🎉


Review generated using project standards from CLAUDE.md

@coderabbitai coderabbitai bot added the bug label Nov 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants