Skip to content

Build the bundled highline from its upstream git tag - #242

Merged
silug merged 2 commits into
simp:masterfrom
silug:highline-from-git
Nov 23, 2026
Merged

silug merged 2 commits into
simp:masterfrom
silug:highline-from-git

Conversation

@silug

@silug silug commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Closes #241.

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. 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_version is the only place the version is set.
  • rake pkg:gem depends on a new checkout_highline task. It clones https://github.com/JEG2/highline into src/gems/highline (ignored by git, removed by rake clean) and checks out v<highline_version>. The gem is then built from that checkout, as it was from ext/gems/highline.
  • The Gemfile tests against that same highline version from rubygems.org instead of :path => 'ext/gems/highline'.
  • %install no longer changes into ext/gems/highline or runs bundle install there. The gem was already installed from %{SOURCE11} with --local.
  • Renovate tracks %global highline_version with the github-tags datasource (JEG2/highline, v prefix).
  • The rubocop exclusion and the coverage filter move from ext/ to src/.

The shipped RPM doesn't change: it still bundles highline 2.0.3.

Testing

  • rake pkg:gem builds simp-cli-8.0.0.gem and highline-2.0.3.gem.
    • The highline gem has the same 60-file list as the published highline-2.0.3.gem on rubygems.org.
    • Compared with a gem built from ext/gems/highline, it adds doc/.cvsignore. That file is upstream's; the copy had left out doc/.
  • rake pkg:single in ghcr.io/simp/simp-el9-build, the way release_rpms builds, produces rubygem-simp-cli, -doc, -highline-2.0.3 and 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.
  • Renovate 44.228.0 dry run on the spec file: it finds highline 2.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 on reline. %install runs gem install --local, so the Renovate PR that moves the RPM to 3.x will also need to bundle reline or otherwise provide it. It should also get a manual simp config run 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

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>
Comment thread renovate.json
],
"depNameTemplate": "highline",
"packageNameTemplate": "JEG2/highline",
"datasourceTemplate": "github-tags",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment thread Rakefile Outdated
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}")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Opened as simp/pkg-r10k#65, covering both packages.

Comment thread Rakefile Outdated
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'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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).

Comment thread Rakefile Outdated
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'))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment thread Rakefile Outdated
# 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]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment thread Rakefile Outdated
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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment thread Gemfile Outdated
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]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment thread Rakefile Outdated
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'))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment thread .rubocop.yml
- "**/Vagrantfile"
- "**/Guardfile"
- ext/**/*
- src/**/*

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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>
@silug
silug merged commit c7cebae into simp:master Nov 23, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this from New to Done in Org Triage Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Replace the vendored copy of highline with a versioned fetch

2 participants