Skip to content

Conversation

@cgrindel
Copy link
Member

@cgrindel cgrindel commented Jan 6, 2026

Summary

This PR adds two utilities to help users configure rv-ruby in their MODULE.bazel:

  1. generate_rv_checksums - Automatically fetches and sets rv_version and rv_checksums for a specified rv-ruby release
  2. generate_excluded_gems - Automatically generates the excluded_gems list based on the Ruby version

Changes

Utilities Implementation

  • Add generate_rv_checksums.sh to fetch checksums from rv-ruby GitHub releases
  • Add generate_excluded_gems.sh to fetch default gems from stdgems.org
  • Both utilities use buildozer to update MODULE.bazel files
  • Support for --name, --module-bazel, and --dry-run options

Testing

  • Add unit tests for both utilities (dry-run mode)
  • Add integration tests to verify buildozer updates work correctly
  • Tests verify name filtering to ensure only target toolchains/bundles are updated

Documentation

  • Update README.md rv-ruby section to document the utilities
  • Remove WORKSPACE examples from rv-ruby section (focus on Bzlmod)
  • Add step-by-step configuration instructions

Bug Fixes

  • Use BUILD_WORKSPACE_DIRECTORY for default MODULE.bazel path to support bazel run
  • Move buildifier_prebuilt from dev_dependency to regular dependency

Usage Examples

Generate rv_checksums:

bazel run @rules_ruby//tools/generate_rv_checksums -- 20251225

Generate excluded_gems:

bazel run @rules_ruby//tools/generate_excluded_gems

Testing

All tests pass:

bazel test //tools/...

Notes

  • Utilities work with both default paths and custom MODULE.bazel locations
  • Support for targeting specific toolchains/bundles by name
  • Dry-run mode available for previewing changes

cgrindel and others added 5 commits January 3, 2026 15:22
Add two Bazel-compatible utilities to automate maintenance of
rv-ruby checksums and excluded gems:

1. generate_rv_checksums: Fetches SHA256 checksums from rv-ruby
   GitHub releases and updates ruby.toolchain() in MODULE.bazel
2. generate_excluded_gems: Queries stdgems.org for native gems
   and updates ruby.bundle_fetch() excluded_gems in MODULE.bazel

Both utilities:
- Support --dry-run mode for previewing changes
- Use buildozer for automatic MODULE.bazel updates
- Include comprehensive test coverage
- Use cgrindel_bazel_starlib for consistent error handling

Dependencies added:
- rules_shell for sh_binary and sh_test support
- cgrindel_bazel_starlib for fail/warn/assertions utilities

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
- Add integration test for generate_excluded_gems.sh to verify buildozer
  updates work correctly
- Refactor buildozer command to use array structure and proper list
  operations ('remove' + 'add' instead of 'set')
- Use -types flag with name-based targeting instead of extension syntax
- Fix tab indentation in error messages
- Add test for name filtering to ensure only target bundle is updated

The buildozer command now matches the pattern used in
generate_rv_checksums.sh for consistency.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
- Update both generate_rv_checksums.sh and generate_excluded_gems.sh to
  use BUILD_WORKSPACE_DIRECTORY when available for the default
  MODULE.bazel path
- This fixes the issue where running via `bazel run` couldn't find
  MODULE.bazel because it was looking in the execution directory
  instead of the workspace root
- When BUILD_WORKSPACE_DIRECTORY is not set (direct script execution),
  it falls back to ./MODULE.bazel as before
- Move buildifier_prebuilt from dev_dependency to regular dependency
  since it's required by the generator tools at runtime
- Fix line wrapping in integration test comments

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
- Remove WORKSPACE examples from rv-ruby section (focus on Bzlmod)
- Add "Configure rv-ruby Downloads" section documenting
  generate_rv_checksums utility
- Add "Configure Excluded Gems" section documenting
  generate_excluded_gems utility
- Fix rb_bundle_fetch to ruby.bundle_fetch for Bzlmod syntax
- Add utility options documentation (--name, --module-bazel, --dry-run)
- Improve formatting and organization of rv-ruby configuration steps
- Add note about compilation errors when excluded_gems is not set

The documentation now provides clear, step-by-step instructions for
using the automated utilities instead of manually configuring checksums
and excluded gems.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
@cgrindel cgrindel self-assigned this Jan 6, 2026
cgrindel and others added 5 commits January 6, 2026 15:16
- Remove redundant set -o errexit declarations (handled by runfiles.bash)
- Add shellcheck disable directives for dynamic sourcing in test files
- Remove debug echo statements from integration tests
- Wrap long lines to improve readability
- Fix line continuation for better formatting consistency

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
- Add --max-time 30 to curl commands to prevent indefinite hangs
- Enhance get_minor_version comment to explain Ruby versioning structure
  and why stdgems data is organized by minor version

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Remove all echo statements to STDOUT from test files to keep test
output clean. Tests should only output on failure.

Changes:
- Remove DEBUG echo statements from integration tests
- Remove TEST/PASS progress messages from all tests
- Remove summary "All tests passed!" messages
- Keep echo statements redirected to stderr or files

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
@cgrindel cgrindel requested a review from p0deje January 7, 2026 00:28
@cgrindel cgrindel marked this pull request as ready for review January 7, 2026 00:28
Copy link
Member

@p0deje p0deje left a comment

Choose a reason for hiding this comment

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

I think that's great, thank you for taking the time to implement it. I wonder if it's possible to use these tools to generate all checksums and excluded gems mapping for all current RV Ruby versions, then commit them to rules_ruby itself. This will make the overall user experience much better since they won't need to perform any extra steps (unless they use a version of Ruby that's not supported in rules_ruby yet).

bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "rules_java", version = "7.2.0")
bazel_dep(name = "rules_shell", version = "0.4.1")
bazel_dep(name = "buildifier_prebuilt", version = "8.2.1.1")
Copy link
Member

Choose a reason for hiding this comment

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

Does it have to be a runtime dependency?

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunatley, yes. The tools use buildozer to update the MODULE.bazel.

Copy link
Member

Choose a reason for hiding this comment

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

Got it, thanks for explanation.

# the versions resolved in users repositories.
bazel_dep(name = "bazel_features", version = "1.9.0")
bazel_dep(name = "bazel_skylib", version = "1.3.0")
bazel_dep(name = "cgrindel_bazel_starlib", version = "0.27.0")
Copy link
Member

Choose a reason for hiding this comment

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

Does it have to be a runtime dependency?

Copy link
Member Author

Choose a reason for hiding this comment

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

I used some shell libraries from my repo in the tools. We can copy those utilities somewhere, but then you would need to maintain them here, as well.

Copy link
Member

Choose a reason for hiding this comment

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

It's fine to use the dependency then.

@cgrindel
Copy link
Member Author

cgrindel commented Jan 8, 2026

I think that's great, thank you for taking the time to implement it. I wonder if it's possible to use these tools to generate all checksums and excluded gems mapping for all current RV Ruby versions, then commit them to rules_ruby itself. This will make the overall user experience much better since they won't need to perform any extra steps (unless they use a version of Ruby that's not supported in rules_ruby yet).

We can. However, you will be pinning rules_ruby versions to certain rv-ruby versions. You are correct that the initial experience will be a bit more streamlined. However, we are talking about running two utilities. We could add a wrapper script that runs both utilities under the covers.

It is your call about embedding the rv-ruby version info.

@cgrindel cgrindel merged commit b31b2ea into main Jan 8, 2026
50 checks passed
@cgrindel cgrindel deleted the generate_checksums_and_excluded_gems branch January 8, 2026 17:29
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