You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add RBS validation and runtime type checking to CI (#1950)
## Summary
This PR implements comprehensive RBS type checking for both the main gem
and Pro package as a follow-up to #1945.
### Changes
1. **CI Integration**
- Added `rake rbs:validate` to main lint workflow
- Added RBS validation to Pro gem lint workflow
- Added Steep static type checker to CI pipeline
2. **Runtime Type Checking**
- Configured RSpec to run with RBS runtime checking for gem tests
- Tests now run with `RBS_TEST_TARGET='ReactOnRails::*'
RUBYOPT='-rrbs/test/setup'`
- Provides runtime validation of type signatures during test execution
3. **Steep Static Type Checker**
- Added steep gem to development dependencies
- Created Steepfile configuration for static type analysis
- Added `rake rbs:steep` task for running static type checks
- Added `rake rbs:all` task to run both validation and steep checks
4. **Pro Gem RBS Types**
- Created sig/ directory structure for Pro gem
- Added type signatures for:
- ReactOnRailsPro module
- Configuration class with all attributes
- Error, Cache, and Utils modules
- Foundation for expanding type coverage in Pro package
### Implementation Details
This PR follows best practices from Evil Martians' ["Climbing Steep
Hills"](https://evilmartians.com/chronicles/climbing-steep-hills-or-adopting-ruby-types)
article:
- Static validation with `rbs validate`
- Runtime checking with `rbs/test/setup`
- Static analysis with Steep
The combination of these three approaches provides comprehensive type
safety:
- **Validation**: Ensures RBS signatures are syntactically correct and
internally consistent
- **Runtime checking**: Verifies actual method calls match their
signatures during tests
- **Static analysis**: Catches type errors in Ruby code without running
it
### Test Plan
- [x] RBS validation passes locally
- [x] RuboCop passes
- [x] All files properly formatted
- [ ] CI validates RBS signatures
- [ ] CI runs Steep checks
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- Reviewable:start -->
- - -
This change is [<img src="https://reviewable.io/review_button.svg"
height="34" align="absmiddle"
alt="Reviewable"/>](https://reviewable.io/reviews/shakacode/react_on_rails/1950)
<!-- Reviewable:end -->
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Chores**
* CI now validates RBS type signatures during linting; an optional Steep
check is present but disabled by default.
* Development/test dependencies added to support RBS/type-checking
tooling.
* Rake tasks added to run/validate/list RBS checks and to run Steep;
test tasks can enable runtime RBS checks when available.
* Lint config updated to exclude the type-checker config file from
filename checks.
* **Documentation**
* Added comprehensive guidance on RBS/Steep usage, runtime
type-checking, and reproducing CI checks.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
- Run Steep type checker: `bundle exec rake rbs:steep`
51
+
- Run both: `bundle exec rake rbs:all`
52
+
- List RBS files: `bundle exec rake rbs:list`
48
53
-**⚠️ MANDATORY BEFORE GIT PUSH**: `bundle exec rubocop` and fix ALL violations + ensure trailing newlines
49
54
- Never run `npm` commands, only equivalent Yarn Classic ones
50
55
@@ -117,6 +122,60 @@ This script:
117
122
- 🔄 **Deduplicates** - removes duplicate specs
118
123
- 📁 **Auto-detects directory** - runs from spec/dummy when needed
119
124
125
+
## RBS Type Checking
126
+
127
+
React on Rails uses RBS (Ruby Signature) for static type checking with Steep.
128
+
129
+
### Quick Start
130
+
131
+
-**Validate signatures**: `bundle exec rake rbs:validate` (run by CI)
132
+
-**Run type checker**: `bundle exec rake rbs:steep` (currently disabled in CI due to existing errors)
133
+
-**Runtime checking**: Enabled by default in tests when `rbs` gem is available
134
+
135
+
### Runtime Type Checking
136
+
137
+
Runtime type checking is **ENABLED BY DEFAULT** during test runs for:
138
+
-`rake run_rspec:gem` - Unit tests
139
+
-`rake run_rspec:dummy` - Integration tests
140
+
-`rake run_rspec:dummy_no_turbolinks` - Integration tests without Turbolinks
141
+
142
+
**Performance Impact**: Runtime type checking adds overhead (typically 5-15%) to test execution. This is acceptable during development and CI as it catches type errors in actual execution paths that static analysis might miss.
143
+
144
+
To disable runtime checking (e.g., for faster test iterations during development):
**When to disable**: Consider disabling during rapid test-driven development cycles where you're running tests frequently. Re-enable before committing to catch type violations.
150
+
151
+
### Adding Type Signatures
152
+
153
+
When creating new Ruby files in `lib/react_on_rails/`:
0 commit comments