Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

strategy:
matrix:
ruby-version: ["3.0", "2.7"]
ruby-version: ["3.2", "3.1", "2.7"]
continue-on-error: true
steps:
- uses: actions/checkout@v2
Expand Down
24 changes: 22 additions & 2 deletions bin/autoproj_bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ module Autoproj
env["RUBYLIB"] = []
env["PATH"] = self.class.sanitize_env(ENV["PATH"] || "")
env["BUNDLE_GEMFILE"] = []

env["BUNDLER_VERSION"] = []
env["BUNDLER_SETUP"] = []
env["BUNDLE_BIN_PATH"] = []
load_config

if config["ruby_executable"] != Gem.ruby
Expand Down Expand Up @@ -264,7 +266,7 @@ module Autoproj
# @param [String] autoproj_version a constraint on the autoproj version
# that should be used
# @return [String]
def default_gemfile_contents(autoproj_version = ">= 2.17.0")
def default_gemfile_contents(autoproj_version = ">= 2.18.0")
["source \"#{gem_source}\"",
"ruby \"#{RUBY_VERSION}\" if respond_to?(:ruby)",
"gem \"autoproj\", \"#{autoproj_version}\""].join("\n")
Expand Down Expand Up @@ -444,6 +446,20 @@ module Autoproj
end
end

def write_bundle_shim(bundle_shim_path)
contents = <<~BUNDLERSHIM
#!#{Gem.ruby}
ENV['BUNDLE_GEMFILE'] ||= '#{autoproj_gemfile_path}'
ENV['GEM_HOME'] = '#{gems_gem_home}'
ENV.delete('GEM_PATH')
Gem.paths = Hash['GEM_HOME' => '#{gems_gem_home}', 'GEM_PATH' => '']
exec "#{File.join(gems_gem_home, 'bin', 'bundle')}", *ARGV
BUNDLERSHIM

File.write(bundle_shim_path, contents)
FileUtils.chmod 0755, bundle_shim_path
end

def install_autoproj(bundler, bundler_version: self.bundler_version)
# Force bundler to update. If the user does not want this, let
# him specify a Gemfile with tighter version constraints
Expand All @@ -463,6 +479,10 @@ module Autoproj
shims_path = File.join(dot_autoproj, "bin")
run_bundler(bundler, "binstubs", "--all", "--force", "--path", shims_path,
bundler_version: bundler_version)

bundle_shim_path = File.join(shims_path, "bundle")
write_bundle_shim(bundle_shim_path) unless File.exist?(bundle_shim_path)

self.class.rewrite_shims(
shims_path, ruby_executable, root_dir,
autoproj_gemfile_path, gems_gem_home
Expand Down
24 changes: 22 additions & 2 deletions bin/autoproj_install
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ module Autoproj
env["RUBYLIB"] = []
env["PATH"] = self.class.sanitize_env(ENV["PATH"] || "")
env["BUNDLE_GEMFILE"] = []

env["BUNDLER_VERSION"] = []
env["BUNDLER_SETUP"] = []
env["BUNDLE_BIN_PATH"] = []
load_config

if config["ruby_executable"] != Gem.ruby
Expand Down Expand Up @@ -264,7 +266,7 @@ module Autoproj
# @param [String] autoproj_version a constraint on the autoproj version
# that should be used
# @return [String]
def default_gemfile_contents(autoproj_version = ">= 2.17.0")
def default_gemfile_contents(autoproj_version = ">= 2.18.0")
["source \"#{gem_source}\"",
"ruby \"#{RUBY_VERSION}\" if respond_to?(:ruby)",
"gem \"autoproj\", \"#{autoproj_version}\""].join("\n")
Expand Down Expand Up @@ -444,6 +446,20 @@ module Autoproj
end
end

def write_bundle_shim(bundle_shim_path)
contents = <<~BUNDLERSHIM
#!#{Gem.ruby}
ENV['BUNDLE_GEMFILE'] ||= '#{autoproj_gemfile_path}'
ENV['GEM_HOME'] = '#{gems_gem_home}'
ENV.delete('GEM_PATH')
Gem.paths = Hash['GEM_HOME' => '#{gems_gem_home}', 'GEM_PATH' => '']
exec "#{File.join(gems_gem_home, 'bin', 'bundle')}", *ARGV
BUNDLERSHIM

File.write(bundle_shim_path, contents)
FileUtils.chmod 0755, bundle_shim_path
end

def install_autoproj(bundler, bundler_version: self.bundler_version)
# Force bundler to update. If the user does not want this, let
# him specify a Gemfile with tighter version constraints
Expand All @@ -463,6 +479,10 @@ module Autoproj
shims_path = File.join(dot_autoproj, "bin")
run_bundler(bundler, "binstubs", "--all", "--force", "--path", shims_path,
bundler_version: bundler_version)

bundle_shim_path = File.join(shims_path, "bundle")
write_bundle_shim(bundle_shim_path) unless File.exist?(bundle_shim_path)

self.class.rewrite_shims(
shims_path, ruby_executable, root_dir,
autoproj_gemfile_path, gems_gem_home
Expand Down
22 changes: 21 additions & 1 deletion lib/autoproj/ops/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ def initialize(root_dir)
env["RUBYLIB"] = []
env["PATH"] = self.class.sanitize_env(ENV["PATH"] || "")
env["BUNDLE_GEMFILE"] = []

env["BUNDLER_VERSION"] = []
env["BUNDLER_SETUP"] = []
env["BUNDLE_BIN_PATH"] = []
load_config

if config["ruby_executable"] != Gem.ruby
Expand Down Expand Up @@ -434,6 +436,20 @@ def install_bundler(gem_program, version: nil, silent: false)
end
end

def write_bundle_shim(bundle_shim_path)
contents = <<~BUNDLERSHIM
#!#{Gem.ruby}
ENV['BUNDLE_GEMFILE'] ||= '#{autoproj_gemfile_path}'
ENV['GEM_HOME'] = '#{gems_gem_home}'
ENV.delete('GEM_PATH')
Gem.paths = Hash['GEM_HOME' => '#{gems_gem_home}', 'GEM_PATH' => '']
exec "#{File.join(gems_gem_home, 'bin', 'bundle')}", *ARGV
BUNDLERSHIM

File.write(bundle_shim_path, contents)
FileUtils.chmod 0755, bundle_shim_path
end

def install_autoproj(bundler, bundler_version: self.bundler_version)
# Force bundler to update. If the user does not want this, let
# him specify a Gemfile with tighter version constraints
Expand All @@ -453,6 +469,10 @@ def install_autoproj(bundler, bundler_version: self.bundler_version)
shims_path = File.join(dot_autoproj, "bin")
run_bundler(bundler, "binstubs", "--all", "--force", "--path", shims_path,
bundler_version: bundler_version)

bundle_shim_path = File.join(shims_path, "bundle")
write_bundle_shim(bundle_shim_path) unless File.exist?(bundle_shim_path)

self.class.rewrite_shims(
shims_path, ruby_executable, root_dir,
autoproj_gemfile_path, gems_gem_home
Expand Down
7 changes: 6 additions & 1 deletion lib/autoproj/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,12 @@ def start_gem_server(path = fixture_gem_home)
"call stop_gem_server before calling start_gem_server again"
end
@gem_server_pid = spawn(
Hash["RUBYOPT" => nil],
Hash[
"RUBYOPT" => nil,
"GEM_HOME" => path,
"BUNDLE_GEMFILE" => nil,
"BUNDLER_SETUP" => nil
],
Gem.ruby, Ops::Install.guess_gem_program, "server",
"--quiet", "--dir", path, out: :close, err: :close
)
Expand Down
23 changes: 23 additions & 0 deletions test/ops/test_install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,29 @@ module Ops
invoke_test_script "install.sh"
end

describe "#find_bundler" do
let(:install) do
version_args = ["--bundler-version", @version] if @version
version_args ||= []
dir, = invoke_test_script "install.sh", *version_args
Install.new(dir)
end

let(:gem_home) { install.gems_gem_home }
let(:gem_program) { Install.guess_gem_program }

it "finds versioned bundler" do
@version = "2.3.6"
assert install.find_bundler(
gem_program, version: @version
)&.start_with?(gem_home)
end

it "finds an unversioned bundler" do
assert install.find_bundler(gem_program)&.start_with?(gem_home)
end
end

it "may install non-interactively" do
invoke_test_script "install.sh",
interactive: false,
Expand Down
6 changes: 4 additions & 2 deletions test/test_workspace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,11 @@ def add_version_control(package_name, type: "local", url: package_name, **vcs)
"install.sh",
"--gems-path=#{gems_path}",
gemfile_source: <<-AUTOPROJ_GEMFILE
source 'http://localhost:8808' do
gem 'autoproj', '>= 2.99.90'
end

source 'https://rubygems.org'
source 'http://localhost:8808'
gem 'autoproj', '>= 2.99.90'
gem 'autobuild', path: '#{autobuild_full_path}'
AUTOPROJ_GEMFILE
)
Expand Down