Repository navigation
Add a Sorbet type check to CI - #573
stefan-burke wants to merge 1 commit into
Conversation
The repo has never typechecked: srb tc reports 919 errors in typed:true/strict files, so a bare gate would be permanently red. bin/check-sorbet-errors compares the reported count against sorbet/error-count-baseline and fails when a change adds net errors - the gradual-adoption gate Sorbet's docs recommend. Lower the baseline as debt is paid down. - Reuse the setup-environment composite action, and keep the workflow named 'Sorbet Type Check' so bin/get-sorbet-results finds it again - Generate Tapioca DSL RBIs in CI against a scratch test database (DATABASE_URL sidesteps both the stale dev database and the per-process test database); the per-model RBIs for columns, associations, enums and scopes resolve the largest error bucket - Scope the generated RBIs: Tapioca also emits files for Rails framework classes and gem engines (pg_query, solid_queue, mission_control, ...) whose constants cannot resolve without gem RBIs, so those directories stay ignored - Ignore the nix devshell's in-repo GEM_HOME (.gems) and the chobble-forms submodule tree (/gems/) so local and CI counts agree - Declare the missing pieces in sorbet/rbi/manual: I18n (the gem ships no RBI), Object#present?/blank?, String/NilClass#presence, Inspection#id, and the Rails internals the generated DSL files reference - Document the flow in CLAUDE.md
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reachedNext included review available in 4 minutes. View limit detailsLimit details: You’ve used the included review currently available. Your 110 included PR review attempts over the past 7 days set your current allowance at 1 review per hour. Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Team Run ID: 📒 Files selected for processing (11)
Comment |
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v7 | ||
|
|
||
| - name: Setup environment | ||
| uses: ./.github/actions/setup-environment | ||
|
|
||
| # Tapioca's DSL RBIs describe model columns, associations and scopes. | ||
| # They are gitignored, so generate them against a scratch test database | ||
| # before typechecking. | ||
| - name: Prepare scratch database | ||
| env: | ||
| RAILS_ENV: test | ||
| DATABASE_URL: sqlite3:tmp/tapioca-scratch.sqlite3 | ||
| run: bundle exec rails db:prepare | ||
|
|
||
| - name: Generate Tapioca DSL RBIs | ||
| env: | ||
| RAILS_ENV: test | ||
| DATABASE_URL: sqlite3:tmp/tapioca-scratch.sqlite3 | ||
| run: bundle exec tapioca dsl | ||
|
|
||
| - name: Run Sorbet | ||
| run: bin/check-sorbet-errors |
What this does
The repo has never typechecked:
srb tcreports 919 errors intyped: true/strictfiles, so a bare gate would be permanently red. This adds the gradual-adoption gate Sorbet's docs recommend —bin/check-sorbet-errorscompares the reported count against the committedsorbet/error-count-baselineand fails only when a change adds net errors. Lower the baseline as debt is paid down.It reuses the existing
setup-environmentcomposite action, and the workflow is namedSorbet Type Check— the namebin/get-sorbet-resultsalready looks for.How the count got down from 1410
Measured on the CI checkout. (The very first local number, 1272, was inflated by the
gems/chobble-formssubmodule, which CI does not fetch — hence the--ignore=/gems/and--ignore=/.gems/entries insorbet/configso local and CI agree.)DATABASE_URLand runstapioca dsl; the per-model RBIs for columns, associations, enums and scopes resolve the largest error bucket. Tapioca also emits RBIs for Rails framework classes and gem engines (pg_query,solid_queue,mission_control, …) whose constants cannot resolve without gem RBIs, so those directories stay ignored while the app's own model RBIs are checked.I18n(the i18n gem ships none — 199 errors were just unresolvedI18n),Object#present?/blank?,String/NilClass#presence,Inspection#id, and the Rails internals the generated DSL files reference (ActiveRecord::Relation,ActiveStorage::Attached::One,Boolean, …).Testing
db:prepare→tapioca dsl→srb tc= 919, matching the baseline (deterministic; regenerated twice).sorbet/configare static-only — no runtime code changes;srb tcitself cannot run on this NixOS checkout becausesorbet-staticships a dynamically linked binary (a patched copy was used to measure), which is exactly why the check lives in CI.CLAUDE.mddocuments the local reproduction steps.Notes
sorbet/rbi/dsl/andsorbet/rbi/gems/remain gitignored artifacts, generated in CI. Rails gem RBIs are the known gap:tapioca gemsemits empty RBIs for Rails (lazy-loaded constants), which is why the framework DSL directories stay scoped out for now.