Skip to content

Commit

Permalink
use Bundler for dependency management and Rake gem tasks
Browse files Browse the repository at this point in the history
Back in 2016, we chose not to use Bundler in Ruby/OpenSSL development
because Bundler depended on openssl and could not be used for testing
openssl itself - "bundle exec rake test" would end up with loading two
different versions of openssl at the same time.

This has been resolved long time ago. We can now safely use it for
development dependency management and for Rake tasks.
  • Loading branch information
rhenium committed Jun 25, 2021
1 parent 69786e3 commit 47283d9
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 30 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
ruby-version: ${{ matrix.ruby }}

- name: depends
run: rake install_dependencies
run: bundle install

- name: compile
run: rake compile -- --enable-debug
Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
mingw: _upgrade_ openssl

- name: depends
run: rake install_dependencies
run: bundle install

# pkg-config is disabled because it can pick up the different OpenSSL installation
# SSL_DIR is set as needed by MSP-Greg/setup-ruby-pkgs
Expand Down Expand Up @@ -110,7 +110,7 @@ jobs:
ruby-version: ${{ matrix.ruby }}

- name: depends
run: rake install_dependencies
run: bundle install

- name: compile
run: rake compile -- --enable-debug --with-openssl-dir=$HOME/.openssl/${{ matrix.openssl }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/.bundle
/Gemfile.lock
/doc/
/pkg/
/tmp/
Expand Down
8 changes: 8 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
source "https://rubygems.org"

gemspec

gem "rake"
gem "rake-compiler"
gem "test-unit", "~> 3.0"
gem "rdoc"
24 changes: 2 additions & 22 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
require 'rake'
require 'rake/testtask'
require 'rdoc/task'
require 'bundler/gem_tasks'

begin
require 'rake/extensiontask'
Rake::ExtensionTask.new('openssl')
rescue LoadError
warn "rake-compiler not installed. Run 'rake install_dependencies' to " \
warn "rake-compiler not installed. Run 'bundle install' to " \
"install testing dependency gems."
end

Expand All @@ -26,26 +26,6 @@ task :debug do
ruby "-I./lib -ropenssl -ve'puts OpenSSL::OPENSSL_VERSION, OpenSSL::OPENSSL_LIBRARY_VERSION'"
end

task :install_dependencies do
if ENV["USE_HTTP_RUBYGEMS_ORG"] == "1"
Gem.sources.replace([Gem::Source.new("http://rubygems.org")])
end

Gem.configuration.verbose = false
gemspec = Gem::Specification.load('openssl.gemspec')

gemspec.development_dependencies.each do |dep|
print "Installing #{dep.name} (#{dep.requirement}) ... "
installed = dep.matching_specs
if installed.empty?
installed = Gem.install(dep.name, dep.requirement)
puts "#{installed[0].version}"
else
puts "(found #{installed[0].version})"
end
end
end

namespace :sync do
task :from_ruby do
sh "./tool/sync-with-trunk"
Expand Down
5 changes: 0 additions & 5 deletions openssl.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,5 @@ Gem::Specification.new do |spec|

spec.required_ruby_version = ">= 2.3.0"

spec.add_development_dependency "rake"
spec.add_development_dependency "rake-compiler"
spec.add_development_dependency "test-unit", "~> 3.0"
spec.add_development_dependency "rdoc"

spec.metadata["msys2_mingw_dependencies"] = "openssl"
end

0 comments on commit 47283d9

Please sign in to comment.