From 5c3abaa1eb6a947acb1845c6389bc3ad05064660 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Wed, 5 Nov 2025 09:44:20 -1000 Subject: [PATCH 1/2] Fix CI failures on master and add workflow_dispatch to all workflows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .github/workflows/lint-js-and-ruby.yml | 1 + .github/workflows/main.yml | 1 + .github/workflows/package-js-tests.yml | 1 + .github/workflows/pro-integration-tests.yml | 1 + .github/workflows/pro-lint.yml | 1 + .github/workflows/pro-package-tests.yml | 1 + .github/workflows/rspec-package-specs.yml | 1 + rakelib/shakapacker_examples.rake | 6 +++++- 8 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint-js-and-ruby.yml b/.github/workflows/lint-js-and-ruby.yml index 5c345d172d..8067b07885 100644 --- a/.github/workflows/lint-js-and-ruby.yml +++ b/.github/workflows/lint-js-and-ruby.yml @@ -11,6 +11,7 @@ on: paths-ignore: - '**.md' - 'docs/**' + workflow_dispatch: jobs: detect-changes: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 874439614b..3be04b11b1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,6 +11,7 @@ on: paths-ignore: - '**.md' - 'docs/**' + workflow_dispatch: jobs: detect-changes: diff --git a/.github/workflows/package-js-tests.yml b/.github/workflows/package-js-tests.yml index 1411f29a4f..02be726a48 100644 --- a/.github/workflows/package-js-tests.yml +++ b/.github/workflows/package-js-tests.yml @@ -15,6 +15,7 @@ on: - 'docs/**' - 'lib/**' - 'spec/react_on_rails/**' + workflow_dispatch: jobs: detect-changes: diff --git a/.github/workflows/pro-integration-tests.yml b/.github/workflows/pro-integration-tests.yml index 78b9917253..96913b31d7 100644 --- a/.github/workflows/pro-integration-tests.yml +++ b/.github/workflows/pro-integration-tests.yml @@ -5,6 +5,7 @@ on: branches: - 'master' pull_request: + workflow_dispatch: defaults: run: diff --git a/.github/workflows/pro-lint.yml b/.github/workflows/pro-lint.yml index fa7d85adc9..a790cf3f84 100644 --- a/.github/workflows/pro-lint.yml +++ b/.github/workflows/pro-lint.yml @@ -5,6 +5,7 @@ on: branches: - 'master' pull_request: + workflow_dispatch: defaults: run: diff --git a/.github/workflows/pro-package-tests.yml b/.github/workflows/pro-package-tests.yml index e69993ea1e..db92de6f2a 100644 --- a/.github/workflows/pro-package-tests.yml +++ b/.github/workflows/pro-package-tests.yml @@ -5,6 +5,7 @@ on: branches: - 'master' pull_request: + workflow_dispatch: defaults: run: diff --git a/.github/workflows/rspec-package-specs.yml b/.github/workflows/rspec-package-specs.yml index 6787ec323b..cb1c062661 100644 --- a/.github/workflows/rspec-package-specs.yml +++ b/.github/workflows/rspec-package-specs.yml @@ -15,6 +15,7 @@ on: - 'docs/**' - 'packages/react-on-rails/src/**' - 'node_package/src/**' + workflow_dispatch: jobs: detect-changes: diff --git a/rakelib/shakapacker_examples.rake b/rakelib/shakapacker_examples.rake index c17f2f8e0a..877ae86196 100644 --- a/rakelib/shakapacker_examples.rake +++ b/rakelib/shakapacker_examples.rake @@ -37,7 +37,11 @@ namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength sh_in_dir(example_type.dir, "echo \"gem 'shakapacker', '>= 8.2.0'\" >> #{example_type.gemfile}") bundle_install_in(example_type.dir) sh_in_dir(example_type.dir, "rake shakapacker:install") - sh_in_dir(example_type.dir, example_type.generator_shell_commands) + # 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) sh_in_dir(example_type.dir, "yarn") end end From 5d89c488950e519be4287fd736606d9d8bc38a5e Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Wed, 5 Nov 2025 10:27:36 -1000 Subject: [PATCH 2/2] Add documentation clarifying ENV variable scope in rake task MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- rakelib/shakapacker_examples.rake | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/rakelib/shakapacker_examples.rake b/rakelib/shakapacker_examples.rake index 877ae86196..47b56fc583 100644 --- a/rakelib/shakapacker_examples.rake +++ b/rakelib/shakapacker_examples.rake @@ -37,7 +37,18 @@ namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength sh_in_dir(example_type.dir, "echo \"gem 'shakapacker', '>= 8.2.0'\" >> #{example_type.gemfile}") bundle_install_in(example_type.dir) sh_in_dir(example_type.dir, "rake shakapacker:install") - # Set ENV variable to skip validation during generator run since npm package isn't installed yet + + # Skip validation during generator run since npm package isn't installed yet + # + # ENV Variable Scope: We prefix each shell command with the ENV variable rather than + # setting it in the Ruby process for these reasons: + # + # 1. Each command spawns a new shell process with its own environment + # 2. The ENV variable is automatically scoped to each command (no cleanup needed) + # 3. This differs from the generator approach in lib/generators/react_on_rails/install_generator.rb + # which sets ENV in the Ruby process and requires explicit cleanup + # + # This approach is simpler and safer for rake tasks that invoke shell commands. generator_commands = example_type.generator_shell_commands.map do |cmd| "REACT_ON_RAILS_SKIP_VALIDATION=true #{cmd}" end