Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,20 @@ These requirements are non-negotiable. CI will fail if not followed.

---

## 🚀 COMMIT AND PUSH BY DEFAULT

**When confident in your changes, commit and push without asking for permission.**

- After completing a task successfully, commit and push immediately
- Run relevant tests locally first to verify changes work
- Don't wait for explicit user approval if you've tested and are confident
- **ALWAYS monitor CI after pushing** - check status and address any failures proactively
- Keep monitoring until CI passes or issues are resolved

This saves time and keeps the workflow moving efficiently.

---

## 🚨 AVOIDING CI FAILURE CYCLES

**CRITICAL**: Large-scale changes (directory structure, configs, workflows) require comprehensive local testing BEFORE pushing.
Expand Down
4 changes: 3 additions & 1 deletion react_on_rails/lib/react_on_rails/git_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
module ReactOnRails
module GitUtils
def self.uncommitted_changes?(message_handler, git_installed: true)
return false if ENV["COVERAGE"] == "true"
# Skip check in CI environments - CI often makes temporary modifications
# (e.g., script/convert for minimum version testing) before running generators
return false if ENV["CI"] == "true" || ENV["COVERAGE"] == "true"

status = `git status --porcelain`
return false if git_installed && status&.empty?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Top level component for simple client side only rendering
import React from 'react';
import { renderToString } from 'react-dom/server';
import { Helmet, HelmetProvider } from '@dr.pogodin/react-helmet';
import HelloWorld from './HelloWorld';
import { HelmetProvider } from '@dr.pogodin/react-helmet';
import ReactHelmet from '../components/ReactHelmet';

/*
* Export a function that takes the props and returns an object with { renderedHtml }
Expand All @@ -22,21 +22,15 @@ export default (props, _railsContext) => {

const componentHtml = renderToString(
<HelmetProvider context={helmetContext}>
<div>
<Helmet>
<title>Custom page title</title>
</Helmet>
Props: {JSON.stringify(props)}
<HelloWorld {...props} />
</div>
<ReactHelmet {...props} />
</HelmetProvider>,
);

const { helmet } = helmetContext;

const renderedHtml = {
componentHtml,
title: helmet ? helmet.title.toString() : '',
title: helmet?.title?.toString() || '',
};

// Note that this function returns an Object for server rendering.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default (props) => {

const renderedHtml = {
componentHtml,
title: helmet ? helmet.title.toString() : '',
title: helmet?.title?.toString() || '',
};
return { renderedHtml };
};
4 changes: 2 additions & 2 deletions react_on_rails/spec/dummy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
"node-libs-browser": "^2.2.1",
"null-loader": "^4.0.0",
"prop-types": "^15.7.2",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"@dr.pogodin/react-helmet": "^3.0.4",
"react": "19.0.0",
"react-dom": "19.0.0",
"react-on-rails": "link:.yalc/react-on-rails",
"react-redux": "^9.2.0",
"react-router-dom": "^6.0.0",
Expand Down
44 changes: 44 additions & 0 deletions react_on_rails/spec/react_on_rails/git_utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ module ReactOnRails
context "with uncommitted git changes" do
let(:message_handler) { instance_double("MessageHandler") } # rubocop:disable RSpec/VerifiedDoubleReference

around do |example|
# Temporarily unset CI env var to test actual uncommitted changes behavior
original_ci = ENV.fetch("CI", nil)
ENV.delete("CI")
example.run
ENV["CI"] = original_ci if original_ci
end

it "returns true" do
allow(described_class).to receive(:`).with("git status --porcelain").and_return("M file/path")
expect(message_handler).to receive(:add_error)
Expand All @@ -22,9 +30,37 @@ module ReactOnRails
end
end

context "when CI environment variable is set" do
let(:message_handler) { instance_double("MessageHandler") } # rubocop:disable RSpec/VerifiedDoubleReference

around do |example|
original_ci = ENV.fetch("CI", nil)
ENV["CI"] = "true"
example.run
ENV["CI"] = original_ci
ENV.delete("CI") unless original_ci
end

it "returns false without checking git status" do
# Should not call git status at all
expect(described_class).not_to receive(:`)
expect(message_handler).not_to receive(:add_error)

expect(described_class.uncommitted_changes?(message_handler, git_installed: true)).to be(false)
end
end

context "with clean git status" do
let(:message_handler) { instance_double("MessageHandler") } # rubocop:disable RSpec/VerifiedDoubleReference

around do |example|
# Temporarily unset CI env var to test actual clean git behavior
original_ci = ENV.fetch("CI", nil)
ENV.delete("CI")
example.run
ENV["CI"] = original_ci if original_ci
end

it "returns false" do
allow(described_class).to receive(:`).with("git status --porcelain").and_return("")
expect(message_handler).not_to receive(:add_error)
Expand All @@ -36,6 +72,14 @@ module ReactOnRails
context "with git not installed" do
let(:message_handler) { instance_double("MessageHandler") } # rubocop:disable RSpec/VerifiedDoubleReference

around do |example|
# Temporarily unset CI env var to test actual git not installed behavior
original_ci = ENV.fetch("CI", nil)
ENV.delete("CI")
example.run
ENV["CI"] = original_ci if original_ci
end

it "returns true" do
allow(described_class).to receive(:`).with("git status --porcelain").and_return(nil)
expect(message_handler).to receive(:add_error)
Expand Down
2 changes: 1 addition & 1 deletion react_on_rails_pro/Gemfile.development_dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ruby '3.3.7'

gem "react_on_rails", path: "../"

gem "shakapacker", "9.3.0"
gem "shakapacker", "9.4.0"
gem "bootsnap", require: false
gem "rails", "~> 7.1"
gem "puma", "~> 6"
Expand Down
Loading
Loading