Skip to content

Fix CI on Ruby 3.0 and add Ruby 4.0 to the matrix - #411

Merged
numbata merged 12 commits into
masterfrom
fix-json-quirks-mode
Oct 29, 2026
Merged

numbata merged 12 commits into
masterfrom
fix-json-quirks-mode

Conversation

@numbata

@numbata numbata commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

CI on the oldest supported Ruby breaks as soon as anything calls Hash#to_json, because the newest activesupport that installs there is incompatible with the latest json release. This keeps the Ruby 3.0 job green without restricting the json versions the gem allows for users, and adds Ruby 4.0 to the test matrix so the gem is exercised on the current Ruby.

Details

  • activesupport 7.1 (the newest installable on Ruby 3.0) calls JSON.generate(..., quirks_mode: true), which json 3.0 removed, so {a: 1}.to_json raises ArgumentError: unknown keyword: quirks_mode. activesupport 7.2.4 and 8.1.x work with json 3.1, so the Gemfile pin is limited to Ruby 3.0; the gemspec is unchanged.
  • Ruby 4.0 no longer ships ostruct as a default gem, and the specs require it, so it is added to the development group. The library already guards OpenStruct with defined?.
  • The latest RuboCop flags disable/enable pairs around a single statement (Style/DirectiveScope) and fails the rubocop job before rspec runs, so those directives become rubocop:disable-next.
  • git is pinned below 6 because danger 9.6 references Git::Base, which git 6 no longer loads eagerly.
  • The unreleased CHANGELOG heading is now 1.1.1 (Next): danger-changelog only recognizes headings containing (Next) or [Unreleased].
  • Includes the Dependabot bumps of the danger-pr-comment workflows to v0.1.1 (Bump numbata/danger-pr-comment/.github/workflows/danger-run.yml from 0.1.0 to 0.1.1 #409, Bump numbata/danger-pr-comment/.github/workflows/danger-comment.yml from 0.1.0 to 0.1.1 #410).

activesupport 7.1, the newest release installable on Ruby 3.0, passes
`quirks_mode:` to `JSON.generate`, which json 3.1 removed. Any
`Hash#to_json` then raises `ArgumentError: unknown keyword: quirks_mode`.
Newer activesupport releases are not affected, so the pin only applies
to Ruby 3.0 and the library's own json requirements stay open.
CI resolves the latest RuboCop, which now flags disable/enable pairs
around a single statement and fails the rubocop job before rspec runs.
Use rubocop:disable-next instead.
json 3.0 already removed the `quirks_mode:` keyword, so json 3.0.2 still
fails with activesupport 7.1 on Ruby 3.0. Only json 2.x works.
danger 9.6 references Git::Base, which git 6.0 no longer loads eagerly,
so the Danger job fails with an uninitialized constant before running.
@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Danger Report

No issues found.

View run

Absorbs the Dependabot updates for both Danger workflows (#409, #410).
danger-changelog only treats a section as unreleased when its heading
contains "(Next)" or "[Unreleased]"; "Next release" matched neither,
so every new entry was reported as outside the unreleased section.
@numbata numbata changed the title Pin json on Ruby 3.0 and add Ruby 4.0 to CI Fix CI on Ruby 3.0 and add Ruby 4.0 to the matrix Oct 28, 2026
The disable-next directives need RuboCop 1.90, so the Gemfile now says
so. The release docs still described the old "Next Release" heading that
Danger does not recognize; they now use the "(Next)" form. Also makes
the Ruby version check a Gem::Version comparison and notes when the git
pin can go.
ubuntu-latest migrates to Ubuntu 26.04, but there are no prebuilt Ruby
3.0 or 3.1 packages for that image, so those matrix jobs and the rubocop
job (Ruby 3.0) would fail at setup. Pin 24.04 until older Rubies are
dropped or built for 26.04.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Three active RuboCop suppression-placement issues remain, so the verification job will continue to fail until the directives are moved to the offending lines.

3 open issues
What changed in this PR

This pull request fixes CI compatibility for Ruby 3.0, adds Ruby 4.0 coverage, and updates RuboCop, release documentation, changelog guidance, and Danger workflows.

Changes:

  • Adds Ruby-specific dependency constraints, including json, git, and ostruct.
  • Expands the CI matrix through Ruby 4.0 and uses Ubuntu 24.04.
  • Updates RuboCop suppression directives and release/changelog documentation.
  • Bumps reusable Danger workflows to v0.1.1.
File Review summary
spec/​grape_entity/​entity_spec.rb Critical: the rubocop:disable-next directive does not suppress the Lint/EmptyBlock offense; it must move immediately before the expose ... do line. (1 vote)
RELEASING.md Documents the new (Next) changelog heading format.
lib/​grape_entity/​exposure/​nesting_exposure/​nested_exposures.rb Critical: the Style/DocumentDynamicEvalDefinition directive must move immediately before class_eval. (3 votes)
lib/​grape_entity/​entity.rb Critical: the Layout/LineLength directive must move immediately before the long raise ArgumentError line or the expression must be wrapped. (3 votes)
Gemfile Adds Ruby-version-aware dependency constraints and development dependencies.
CONTRIBUTING.md Updates changelog contribution guidance.
CHANGELOG.md Adds the 1.1.1 (Next) unreleased heading and records the changes.
.github/​workflows/​danger.yml Bumps the reusable Danger workflow to v0.1.1.
.github/​workflows/​danger-comment.yml Bumps the reusable Danger comment workflow to v0.1.1.
.github/​workflows/​ci.yml Uses Ubuntu 24.04 and adds Ruby 4.0 to the test matrix.

Review effort: Lite

Comment thread lib/grape_entity/entity.rb Resolved
Comment thread spec/grape_entity/entity_spec.rb Resolved
@numbata
numbata merged commit 3daa3bd into master Oct 29, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants