Skip to content

fix: generate Ruby 3.1-compatible empty structs (part 2) - #380

Merged
jterapin merged 2 commits into
mainfrom
ruby-3.1-minimum-part-2
Oct 21, 2026
Merged

jterapin merged 2 commits into
mainfrom
ruby-3.1-minimum-part-2

Conversation

@jterapin

@jterapin jterapin commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Description

Generated structs with no fields fail to load on Ruby 3.1 and 3.2. This affects empty modeled structures and services with no endpoint parameters.

This preparation step keeps all published and generated gem minimums at Ruby 3.3.

Fix

  • Supply the optional Struct class-name placeholder in the type, auth-parameter, and endpoint-parameter templates.
  • Update existing empty-Struct examples and cover empty and populated client/schema types and empty endpoint parameters.
  • Regenerate the affected Weather and Shapes sample files from unchanged models in a separate commit.

Testing

Suites ran on Ruby 4.0.3:

  • Generator unit: 517 examples, 0 failures.
  • Generated endpoint tests: 76 examples, 0 failures.
  • Generated protocol tests: 117 examples, 0 failures.
  • Client: 919 examples, 0 failures, 2 existing pending tests.
  • Schema: 149 examples, 0 failures.
  • CBOR: 269 examples, 0 failures.
  • JSON: 70 examples, 0 failures.
  • XML: 59 examples, 0 failures.
  • Generator RBS: 127 unit, 76 endpoint, and 117 protocol examples, 0 failures.
  • Schema/client RBS: 149 and 867 examples, 0 failures, 2 existing client pending tests.
  • AWS protocols: 1,106 examples, 0 failures, 4 existing pending tests, using local Smithy source through a temporary bundle.
  • RuboCop: 374 files, no offenses. git diff --check passed.
  • Direct generated-type loading checks on Ruby 3.1.7 and 3.2.11 passed for empty and populated client/schema types, empty endpoint parameters, and auth parameters. These are focused compatibility probes, not full older-Ruby suites.

🤖 This PR description was drafted with AI assistance for @jterapin. ✨

@jterapin
jterapin added this pull request to stack #382 October 14, 2026 23:25
@jterapin
jterapin marked this pull request as ready for review October 15, 2026 21:37
@jterapin
jterapin requested review from a team as code owners October 15, 2026 21:37
@jterapin
jterapin requested review from boblodgett and sichanyoo and removed request for boblodgett and sichanyoo October 15, 2026 21:37
Base automatically changed from ruby-3.1-minimum-part-1 to main October 19, 2026 20:52
@jterapin
jterapin force-pushed the ruby-3.1-minimum-part-2 branch from d57a8e0 to 4fbd982 Compare October 19, 2026 20:52
@jterapin
jterapin force-pushed the ruby-3.1-minimum-part-2 branch from 4fbd982 to f6612bc Compare October 21, 2026 14:56
@jterapin
jterapin merged commit f43292c into main Oct 21, 2026
33 checks passed
@jterapin
jterapin deleted the ruby-3.1-minimum-part-2 branch October 21, 2026 16:40
jterapin added a commit that referenced this pull request Oct 21, 2026
> [!NOTE]
> Stacked on
[#380](#380), which
includes the runtime preparation from
[#378](#378). Retarget to
`main` after both parents merge. Local validation is complete; GitHub CI
is pending.

## Context

The gems currently require Ruby 3.3. This lowers the minimum requirement
to Ruby 3.1 for the generator, runtimes, server placeholder, and
generated client/schema gems.

## Description

- Use Rails 7.2 for the generator so its dependency supports Ruby 3.1.
- Lower all seven maintained gem requirements and generated-gem metadata
to Ruby 3.1, including matching assertions and sample gemspecs.
- Add Ruby 3.1, Ruby 3.2, and JRuby 9.4 to both CI matrices, keeping
3.3, 3.4, 4.0, and JRuby 10.0. Exclude the RBS group from spec jobs;
keep RBS and lint on Ruby 4.0.
- Target Ruby 3.1 in RuboCop, remove the argument-forwarding exclusions,
and use `...` forwarding in `PageEnumerator#reduce`.
- Match `Tempfile` before `File` in log formatting so JRuby 9.4 retains
the temporary-file label. Existing logging examples cover both paths.
- Refresh development setup instructions, allow RBS checks on a
compatible local Ruby version, and ignore `.bundle/` so local Bundler
settings stay out of commits.

## Testing

Generator and runtime suites passed in the source checkout on Ruby
3.1.7, 3.2.11, 3.3.11, 3.4.9, 4.0.3, JRuby 9.4.15.0, and JRuby 10.0.7.0.
All suites had zero failures; existing pending tests are included below.

| Suite | Examples | MRI pending | JRuby 9.4/10.0 pending |
| --- | ---: | ---: | ---: |
| Generator unit | 517 | 0 | 2 |
| Generated endpoints | 76 | 0 | 0 |
| Generated protocols | 117 | 0 | 43 |
| Client | 919 | 2 | 86 |
| Schema | 149 | 0 | 0 |
| CBOR | 269 | 0 | 0 |
| JSON | 70 | 0 | 7 |
| XML | 59 | 0 | 0 |

- Fresh Ruby 3.1 bundle resolved Rails 7.2.4 and SimpleCov 0.22.0 with
the RBS group excluded. A subsequent audit parsed all 399 tracked Ruby
and gemspec files and reran every generator/runtime suite with zero
failures.
- Verified `.bundle/config` is ignored and `git diff --check` passes.
- RBS on Ruby 4.0: generator 127 unit, 76 endpoint, and 117 protocol
examples; client 867 examples (2 existing pending); schema 149; CBOR
269; JSON 70; XML 59. Zero failures.
- Ruby 3.1 runtime/generated-package checks passed: empty/populated
types, a stubbed CBOR operation, and client-only loading without the
generator. Clean installed-generator loading still raises `LoadError`
because its existing source-relative CBOR protocol path requires the
repository layout; the packaging fix is deferred with a TODO.
- Server placeholder parsed and loaded on Ruby 3.1. Maintained sample
gemspecs matched actual regeneration from unchanged models.
- Downstream AWS protocols on Ruby 4.0: 1,106 examples, zero failures, 4
existing pending tests, using local Smithy source through a temporary
bundle.
- RuboCop: 374 files, no offenses. Workflow YAML validation and `git
diff --check` passed.
- Forwarding cleanup: client specs (919 examples, 2 existing pending),
client RBS (867 examples, 2 existing pending), and RuboCop passed on
Ruby 4.0.3. All four `reduce` calling forms passed on Ruby 3.1.7, JRuby
9.4.15.0, and JRuby 10.0.7.0.

🤖 This PR description was drafted with AI assistance for @jterapin. ✨
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.

3 participants