Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/api-http.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ jobs:
ruby-version: '3.3'
- run: gem install webrick --no-document
- run: ruby -c services/api/simple_server.rb
- run: ruby scripts/check_gem_package.rb
- run: python3 scripts/check_api_http.py
11 changes: 5 additions & 6 deletions cli/gemhub.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ Gem::Specification.new do |spec|
spec.metadata["source_code_uri"] = "https://github.com/your-org/gemhub"
spec.metadata["changelog_uri"] = "https://github.com/your-org/gemhub/blob/main/CHANGELOG.md"

# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
# Container/source builds may not contain Git or a .git directory. Enumerate
# the package's own source, and include bin/ so gem installation exposes the CLI.
spec.files = Dir.chdir(__dir__) do
`git ls-files -z`.split("\x0").reject do |f|
(File.expand_path(f) == __FILE__) ||
f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile])
end
Dir.glob(["lib/**/*", "bin/*", "README*", "LICENSE*"]).select do |file|
File.file?(file)
end.sort
end
spec.bindir = "bin"
spec.executables = spec.files.grep(%r{\Abin/}) { |f| File.basename(f) }
Expand Down
25 changes: 25 additions & 0 deletions scripts/check_gem_package.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

require "fileutils"
require "tmpdir"
require "rubygems"

root = File.expand_path("..", __dir__)
Dir.mktmpdir("gemhub-source-package") do |directory|
%w[gemhub.gemspec lib bin].each do |entry|
FileUtils.cp_r(File.join(root, "cli", entry), directory)
end
original_path = ENV["PATH"]
begin
ENV["PATH"] = directory # No external Git executable and no repository metadata.
spec = Gem::Specification.load(File.join(directory, "gemhub.gemspec"))
raise "Gemspec cannot load without Git" unless spec
raise "Missing CLI executable" unless spec.executables == ["gemhub"]
raise "Missing packaged executable" unless spec.files.include?("bin/gemhub")
raise "Missing implementation" unless spec.files.include?("lib/gemhub/version.rb")
raise "Unexpected repository files" unless spec.files.all? { |file| File.file?(File.join(directory, file)) }
puts "PASS: source gemspec loads without Git and packages executable plus implementation"
ensure
ENV["PATH"] = original_path
end
end
Loading