Repository navigation
Build the bundled highline from its upstream git tag - #242
Conversation
ext/gems/highline was a copy of highline 2.0.3's source, identical to upstream's v2.0.3 tag apart from the missing doc/ and test/ directories. Updating it meant replacing the tree by hand, and Renovate couldn't see it. The RPM spec's `%global highline_version` is now the only place the version is set: - `rake pkg:gem` clones https://github.com/JEG2/highline at `v<highline_version>` into src/gems/highline and builds the gem from it, as pkg-r10k does for its bundled gems. The result has the same file list as the published highline-2.0.3.gem. - The Gemfile tests against that highline version from rubygems.org instead of the copy. - %install no longer changes into the removed directory or runs `bundle install` there. - Renovate tracks the version with the github-tags datasource. Closes simp#241 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| ], | ||
| "depNameTemplate": "highline", | ||
| "packageNameTemplate": "JEG2/highline", | ||
| "datasourceTemplate": "github-tags", |
There was a problem hiding this comment.
Renovate will propose highline 3.x, which simp-cli.gemspec forbids. The gemspec still declares s.add_runtime_dependency 'highline', '>= 2.0.0', '< 3.0' (simp-cli.gemspec:32). Nothing here caps the version, and the PR's own dry run proposes 3.1.2. When that PR bumps %global highline_version to 3.1.2, the Gemfile pins highline 3.1.2 while gemspec requires < 3.0, so bundle install cannot resolve. If the RPM is forced through, simp-cli-highline ships only highline 3.1.2, and simp fails gem activation at runtime because no highline < 3.0 is installed. Add "allowedVersions": "<3" (or a packageRule) until the gemspec and the reline/abbrev bundling are dealt with.
There was a problem hiding this comment.
I'd rather not cap it. Renovate opens 2.x updates (2.1.0 first) separately from the major, so the minor and patch path keeps flowing. A highline 3.x PR is expected to need more than the version bump: widening the gemspec range and bundling reline (see "Follow-up for highline 3.x" in the description). Its PR failing bundle install against < 3.0 is the signal that work is due, and the PR is where it gets done. A red PR can't merge, so nothing ships. An allowedVersions: "<3" cap would hide the update until someone remembered to lift it, which is how the vendored copy stayed at 2.0.3 since 2019.
| sh %(git clone -q #{@highline_repo} "#{dir}") unless File.directory?(File.join(dir, '.git')) | ||
| Dir.chdir(dir) do | ||
| sh 'git fetch -q --tags' | ||
| sh %(git checkout -q "v#{@highline_version}") |
There was a problem hiding this comment.
Nothing verifies the code that goes into the shipped RPM. The gem that becomes rubygem-simp-cli-highline is now built from whatever a third-party repo's v2.0.3 tag points to at build time. Tags are mutable, and nothing checks a commit SHA or checksum. Before this change, the vendored source had been reviewed in this repo's history. A force-pushed or compromised tag would silently change the RPM contents. Consider pinning the expected commit (for example, check git rev-parse HEAD against a recorded SHA), or verifying the published gem's sha256.
There was a problem hiding this comment.
This follows pkg-r10k, which builds its 25 bundled gems the same way: clone the upstream repo, check out the release tag, build. It has no SHA or checksum checks either, so a tag-integrity check is a supply-chain decision for both repos, not just this one. I'd rather handle it once for both (a recorded commit per version, which Renovate can maintain as a digest) than add it here only. I'll open an issue for it. On review: a version change now arrives as a Renovate PR naming the tag, so it gets reviewed here like any other change.
There was a problem hiding this comment.
Opened as simp/pkg-r10k#65, covering both packages.
| FileUtils.mkdir_p File.dirname(dir) | ||
| sh %(git clone -q #{@highline_repo} "#{dir}") unless File.directory?(File.join(dir, '.git')) | ||
| Dir.chdir(dir) do | ||
| sh 'git fetch -q --tags' |
There was a problem hiding this comment.
pkg:gem (and so pkg:rpm and pkg:single) now needs network access on every run. git fetch -q --tags runs unconditionally, even when src/gems/highline is already on the right tag. The first build also needs git and access to github.com. Offline or air-gapped RPM builds, which worked with the vendored ext/ copy, now fail. Skip the fetch when git rev-parse -q --verify refs/tags/v#{@highline_version} already succeeds.
There was a problem hiding this comment.
Release builds already need network access. simp-core's build:auto clones every component with deps:checkout, runs bundle install when a build fails, and pkg-r10k's pkg:gem clones its bundled gems' repos on every build. Offline rebuilds of the RPM itself still work: the SRPM carries the built highline-<version>.gem as Source11, so rpmbuild --rebuild doesn't need the network. Only rake pkg:gem does. Given your next comment, I chose a fresh clone every time over reusing a checkout (614748a).
| task :checkout_highline do | ||
| dir = File.join(@rakefile_dir, 'src', 'gems', 'highline') | ||
| FileUtils.mkdir_p File.dirname(dir) | ||
| sh %(git clone -q #{@highline_repo} "#{dir}") unless File.directory?(File.join(dir, '.git')) |
There was a problem hiding this comment.
An existing checkout is reused without any check. If src/gems/highline already exists, its origin is never checked. Local edits make git checkout fail, and untracked leftovers stay in place. For example, a highline-*.gem left behind by an interrupted earlier build gets swept into dist/ by FileUtils.mv Dir.glob('*.gem'). That leaves two highline gems, and the acceptance install picks one with ls ... | tail -n 1. A git clean -fdx plus git checkout --force (or always a fresh clone) would make the build reproducible.
There was a problem hiding this comment.
Agreed. Fixed in 614748a: checkout_highline now removes src/gems/highline and does a fresh clone every time, so nothing from an earlier checkout (edits, untracked files, a stray highline-*.gem) can reach dist/. Tested by planting a file and a gem in the checkout and rebuilding: both were gone, and dist/ held just the two gems.
| # The RPM's highline subpackage is built from highline's upstream git tag for | ||
| # the version in the RPM spec file, so the spec is the one place to change it. | ||
| @highline_repo = 'https://github.com/JEG2/highline.git' | ||
| @highline_version = File.read(File.join(@rakefile_dir, 'build', "rubygem-#{@package}.spec"))[%r{^%global\s+highline_version\s+(\S+)}, 1] |
There was a problem hiding this comment.
If the regex fails to match, the build fails with a confusing error. If the %global highline_version line is renamed, reformatted (for example, %define), or moved behind a macro, @highline_version is nil. The task then runs git checkout -q "v", which fails with an unrelated-looking git error, and the Gemfile gets gem 'highline', nil. Raise a clear error when the match is nil. The value is also interpolated unescaped into sh strings. Renovate's extract regex limits what it writes, but a hand edit is not limited.
There was a problem hiding this comment.
Fixed in 614748a. The parse is in build/highline_version.rb, which raises Could not find '%global highline_version <version>' in … when the line is missing or reformatted (tested with %define), and rejects any value that isn't a release number (\d+(\.\d+)*). The clone also passes its arguments as a list rather than a shell string.
| Simp::Rake::Beaker.new(File.dirname(__FILE__)) | ||
|
|
||
| # The RPM's highline subpackage is built from highline's upstream git tag for | ||
| # the version in the RPM spec file, so the spec is the one place to change it. |
There was a problem hiding this comment.
Altitude: build from the published gem instead of cloning and rebuilding. The PR notes that the gem built from the tag has the same 60-file list as the published highline-2.0.3.gem. gem fetch highline -v #{@highline_version} (or a download with a recorded sha256) into dist/ would give the same artifact. It would also remove the git build dependency, the src/ tree, and the custom Renovate regex manager, which could use the rubygems datasource instead of github-tags.
There was a problem hiding this comment.
We considered that. The deciding factor was SIMP's existing precedent: pkg-r10k builds every bundled gem from its upstream git tag, and nothing in SIMP fetches gems from rubygems.org for an RPM. Building from the tagged source keeps one approach across both packages, and the artifact is equivalent: the built gem has the same file list as the published highline-2.0.3.gem. If we move to published gems with recorded checksums, that should cover pkg-r10k too, and it fits the same issue as the tag-integrity question above.
| gem 'bundler' | ||
| gem 'highline', :path => 'ext/gems/highline' | ||
| # the highline version the RPM bundles (build/rubygem-simp-cli.spec) | ||
| gem 'highline', File.read(File.join(__dir__, 'build', 'rubygem-simp-cli.spec'))[%r{^%global\s+highline_version\s+(\S+)}, 1] |
There was a problem hiding this comment.
The spec-parsing regex is copied in two files. The same %r{^%global\s+highline_version\s+(\S+)} parse of the spec file is written here and in Rakefile:38, and a third variant lives in renovate.json. If one copy is changed and the other is not, the tested highline and the shipped highline differ silently. Consider one small helper (for example, build/highline_version.rb) that both files require/eval.
There was a problem hiding this comment.
Fixed in 614748a. build/highline_version.rb holds the one parse; the Rakefile and the Gemfile both require_relative it. The Renovate manager has to keep its own regex in renovate.json, since Renovate can't load Ruby. It matches the same line.
| task :checkout_highline do | ||
| dir = File.join(@rakefile_dir, 'src', 'gems', 'highline') | ||
| FileUtils.mkdir_p File.dirname(dir) | ||
| sh %(git clone -q #{@highline_repo} "#{dir}") unless File.directory?(File.join(dir, '.git')) |
There was a problem hiding this comment.
Full clone on every install_gem. pkg:install_gem => [:clean, :gem], and CLEAN now includes src, so every install_gem deletes the checkout and re-clones highline's full history. git clone -q --depth 1 --branch v#{@highline_version} fetches only the tagged tree and makes the separate fetch/checkout unnecessary.
There was a problem hiding this comment.
Fixed in 614748a: git clone --depth 1 --branch v<version>, with no separate fetch or checkout. The highline gemspec builds its file list with git ls-files, which works on the shallow clone, and the gem's file list is unchanged.
| - "**/Vagrantfile" | ||
| - "**/Guardfile" | ||
| - ext/**/* | ||
| - src/**/* |
There was a problem hiding this comment.
Stale ext references. LICENSE:29 still says "Items in the 'ext' directory are external projects and may contain their own licenses". That directory is gone, and highline's COPYING/LICENSE (GPL-2/Ruby) are no longer in the repo, although the SRPM tarball still carries the highline source through src/. Update the LICENSE note to point at src/gems/ (populated at build time).
There was a problem hiding this comment.
Fixed in 614748a: the LICENSE note now says gems under src/gems are checked out from their upstream projects at build time and carry their own licenses.
- Move the parse of `%global highline_version` into build/highline_version.rb, which the Rakefile and the Gemfile share. It raises a clear error when the line is missing or the value isn't a release number, instead of running `git checkout "v"` or `gem 'highline', nil`. - Clone the tag fresh and shallow (`--depth 1 --branch v<version>`) on every build, so edits, untracked files or gems left in an earlier checkout can't reach the RPM. - Pass the git arguments as a list rather than a shell string. - Point the LICENSE note at src/gems instead of the removed ext/. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Closes #241.
ext/gems/highlinewas a copy of highline 2.0.3's source, identical to upstream'sv2.0.3tag apart from the missingdoc/andtest/directories. This replaces it with a build-time checkout of the tag, following pkg-r10k, which builds its bundled gems from their upstream repositories the same way.Changes
build/rubygem-simp-cli.spec's%global highline_versionis the only place the version is set.rake pkg:gemdepends on a newcheckout_highlinetask. It clones https://github.com/JEG2/highline intosrc/gems/highline(ignored by git, removed byrake clean) and checks outv<highline_version>. The gem is then built from that checkout, as it was fromext/gems/highline.:path => 'ext/gems/highline'.%installno longer changes intoext/gems/highlineor runsbundle installthere. The gem was already installed from%{SOURCE11}with--local.%global highline_versionwith thegithub-tagsdatasource (JEG2/highline,vprefix).ext/tosrc/.The shipped RPM doesn't change: it still bundles highline 2.0.3.
Testing
rake pkg:gembuildssimp-cli-8.0.0.gemandhighline-2.0.3.gem.highline-2.0.3.gemon rubygems.org.ext/gems/highline, it addsdoc/.cvsignore. That file is upstream's; the copy had left outdoc/.rake pkg:singleinghcr.io/simp/simp-el9-build, the wayrelease_rpmsbuilds, producesrubygem-simp-cli,-doc,-highline-2.0.3and the SRPM. highline is installed under/usr/share/simp/ruby/gems/highline-2.0.3.rake spec(Ruby 4.0, highline 2.0.3 from rubygems.org): 1557 examples, 0 failures, 9 pending.rubocop: no offenses.highline2.0.3 and proposes 2.1.0 (minor) and 3.1.2 (major).Follow-up for highline 3.x
highline 3.0 adds a runtime dependency on
abbrev, and 3.1 onreline.%installrunsgem install --local, so the Renovate PR that moves the RPM to 3.x will also need to bundlerelineor otherwise provide it. It should also get a manualsimp configrun on an EL host, since the specs don't exercise interactive prompting. The 2.1.0 update has no runtime dependencies.🤖 Generated with Claude Code