Test against all supported Ruby versions and pin actions to SHAs - #22
Open
tas50 wants to merge 1 commit into
Open
Test against all supported Ruby versions and pin actions to SHAs#22tas50 wants to merge 1 commit into
tas50 wants to merge 1 commit into
Conversation
The gemspec declares `required_ruby_version = ">= 3.1"`, but unit tests only
ran on 3.1 and 3.4, leaving 3.2, 3.3, and 4.0 untested. Expand the matrix to
cover every released Ruby the gemspec permits.
Adding 4.0 immediately surfaced a real bug: the suite does not load at all on
Ruby 4.0.
LoadError: cannot load such file -- logger
./lib/chef-winrm-fs.rb:19:in '<top (required)>'
lib/chef-winrm-fs.rb requires "logger" directly, but logger stopped being a
default gem in Ruby 4.0 and was never declared in the gemspec. Until now it
resolved only because the interpreter happened to ship it. This affects anyone
installing the gem on 4.0, not just CI. Declaring it as a runtime dependency
is the same fix already applied here for csv and benchmark when those left the
default set in Ruby 3.4.
Also:
- Fix the push trigger. It fired on `master`, but the default branch is
`main`, so unit tests had never run on a merge to the default branch.
lint.yml already had this right.
- Pin every action to an immutable commit SHA with the version in a
trailing comment. Tags like `@v1` are mutable and can be repointed at
arbitrary code by anyone who can push to the action's repo. Dependabot
already watches the github-actions ecosystem here, so the pins stay fresh.
- Quote the lint job's Ruby version. Unquoted, YAML reads it as a number.
Verified locally on Ruby 4.0.6: 3 examples, 0 failures, where the suite
previously could not load.
Signed-off-by: Tim Smith <tsmith84@proton.me>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The gemspec declares
required_ruby_version = ">= 3.1", but unit tests only ran on 3.1 and 3.4. Ruby 3.2, 3.3, and 4.0 were declared supported and never tested. This expands the matrix to every released Ruby the gemspec permits, and pins all workflow actions to immutable commit SHAs.Adding Ruby 4.0 found a real bug
The suite does not load at all on Ruby 4.0:
lib/chef-winrm-fs.rb:19requiresloggerdirectly, butloggerstopped being a default gem in Ruby 4.0 and was never declared in the gemspec. Up to now it resolved purely because the interpreter happened to ship it.This is not a CI-only problem. Anyone who installs
chef-winrm-fson Ruby 4.0 hits it on the firstrequire. Bundler has no reason to installlogger, because nothing in the dependency graph asks for it.The fix is one line, and it's the same one already applied in this gemspec for
csvandbenchmarkwhen those left the default gem set in Ruby 3.4:Left unfixed for now: the
logginggem emits a similar warning aboutsyslog, which stopped being a default gem in Ruby 3.4. That one is only a warning —syslogis still a bundled gem, so therequiresucceeds — and it originates in a dependency rather than in this repo's code. Worth watching, but it isn't breaking anything today.Ruby matrix
Still across both
windows-2022andwindows-2025, so this goes from 4 jobs to 10.Action pinning
actions/checkout@v43d3c42e# v7.0.1ruby/setup-ruby@v195ef2b0# v1.321.0r7kamura/rubocop-problem-matchers-action@v159f1a07# v1.2.2A tag is a movable pointer. Anyone who can push to an action's repository can repoint
@v1at new code, and every workflow referencing it picks that up on the next run with no change on our side. A SHA can't be repointed. The version lives in a trailing# vX.Y.Zcomment, which is what Dependabot reads to bump the pin — and this repo already has thegithub-actionsecosystem configured, so the pins won't go stale.ci-main-pull-request-stub-1.0.7.ymlis deliberately left alone. It referenceschef/common-github-actions/.github/workflows/ci-main-pull-request.yml@main— a reusable workflow from an internal repo, not a third-party action. Pinning it would cut this repo off from centrally-managed CI updates.Bug fix picked up along the way
unit.ymlpointed at the wrong branch. It triggered on pushes tomaster, but this repository's default branch ismain. Unit tests had never run on a merge to the default branch — only on PRs.lint.ymlalready had this right.Also quoted the lint job's
ruby-version, which was an unquoted3.1and therefore parsed by YAML as a float.Verification
On Ruby 4.0.6 the suite goes from not loading at all to green:
Both workflow files and
dependabot.ymlparse as valid YAML, and no tag-baseduses:references remain in.github/workflows/. Ruby 3.2 and 3.3 get their first verification from this PR's own CI run.Worth noting separately:
spec/unit/contains a single file,tmp_zip_spec.rb. Three examples is the entire unit suite for this gem. Broadening that is out of scope here, but it's a thin safety net for a matrix this wide.