Permalink
Fetching contributors…
Cannot retrieve contributors at this time
280 lines (233 sloc) 8.54 KB
#!/usr/bin/env rake
require_relative 'lib/concurrent/version'
require_relative 'lib/concurrent/utility/engine'
core_gemspec = Gem::Specification.load File.join(__dir__, 'concurrent-ruby.gemspec')
ext_gemspec = Gem::Specification.load File.join(__dir__, 'concurrent-ruby-ext.gemspec')
edge_gemspec = Gem::Specification.load File.join(__dir__, 'concurrent-ruby-edge.gemspec')
require 'rake/javaextensiontask'
Rake::JavaExtensionTask.new('concurrent_ruby', core_gemspec) do |ext|
ext.ext_dir = 'ext/concurrent-ruby'
ext.lib_dir = 'lib/concurrent'
end
unless Concurrent.on_jruby?
require 'rake/extensiontask'
Rake::ExtensionTask.new('concurrent_ruby_ext', ext_gemspec) do |ext|
ext.ext_dir = 'ext/concurrent-ruby-ext'
ext.lib_dir = 'lib/concurrent'
ext.source_pattern = '*.{c,h}'
ext.cross_compile = true
ext.cross_platform = ['x86-mingw32', 'x64-mingw32']
end
end
require 'rake_compiler_dock'
namespace :repackage do
desc '* with Windows fat distributions'
task :all do
Dir.chdir(__dir__) do
sh 'bundle package'
# needed only if the jar is built outside of docker
Rake::Task['lib/concurrent/concurrent_ruby.jar'].invoke
RakeCompilerDock.exec 'support/cross_building.sh'
end
end
end
require 'rubygems'
require 'rubygems/package_task'
Gem::PackageTask.new(core_gemspec) {} if core_gemspec
Gem::PackageTask.new(ext_gemspec) {} if ext_gemspec && !Concurrent.on_jruby?
Gem::PackageTask.new(edge_gemspec) {} if edge_gemspec
CLEAN.include('lib/concurrent/2.*', 'lib/concurrent/*.jar')
begin
require 'rspec'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
options = %w[ --color
--backtrace
--seed 1
--format documentation
--tag ~notravis ]
namespace :spec do
desc '* Configured for ci'
RSpec::Core::RakeTask.new(:ci) do |t|
t.rspec_opts = [*options].join(' ')
end
desc '* test packaged and installed gems instead of local files'
task :installed do
Dir.chdir(__dir__) do
sh 'gem install pkg/concurrent-ruby-1.1.0.pre1.gem'
sh 'gem install pkg/concurrent-ruby-ext-1.1.0.pre1.gem' if Concurrent.on_cruby?
sh 'gem install pkg/concurrent-ruby-edge-0.4.0.pre1.gem'
ENV['NO_PATH'] = 'true'
sh 'bundle update'
sh 'bundle exec rake spec:ci'
end
end
end
desc 'executed in CI'
task :ci => [:compile, 'spec:ci']
task :default => [:clobber, :compile, :spec]
rescue LoadError => e
puts 'RSpec is not installed, skipping test task definitions: ' + e.message
end
current_yard_version_name = Concurrent::VERSION.split('.')[0..2].join('.')
begin
require 'yard'
require 'md_ruby_eval'
require_relative 'support/yard_full_types'
common_yard_options = ['--no-yardopts',
'--no-document',
'--no-private',
'--embed-mixins',
'--markup', 'markdown',
'--title', 'Concurrent Ruby',
'--template', 'default',
'--template-path', 'yard-template',
'--default-return', 'undocumented']
desc 'Generate YARD Documentation (signpost, master)'
task :yard => ['yard:signpost', 'yard:master']
namespace :yard do
desc '* eval markdown files'
task :eval_md do
Dir.chdir File.join(__dir__, 'docs-source') do
sh 'bundle exec md-ruby-eval --auto'
end
end
task :update_readme do
Dir.chdir __dir__ do
content = File.read(File.join('README.md')).
gsub(/\[([\w ]+)\]\(http:\/\/ruby-concurrency\.github\.io\/concurrent-ruby\/master\/.*\)/) do |_|
case $1
when 'LockFreeLinkedSet'
"{Concurrent::Edge::#{$1} #{$1}}"
when '.dataflow'
'{Concurrent.dataflow Concurrent.dataflow}'
when 'thread pool'
'{file:thread_pools.md thread pool}'
else
"{Concurrent::#{$1} #{$1}}"
end
end
File.write 'tmp/README.md', content
end
end
define_yard_task = -> name do
desc "* of #{name} into subdir #{name}"
YARD::Rake::YardocTask.new(name) do |yard|
yard.options.push(
'--output-dir', "docs/#{name}",
'--main', 'tmp/README.md',
*common_yard_options)
yard.files = ['./lib/**/*.rb',
'./lib-edge/**/*.rb',
'./ext/concurrent_ruby_ext/**/*.c',
'-',
'docs-source/thread_pools.md',
'docs-source/promises.out.md',
'LICENSE.md',
'CHANGELOG.md']
end
Rake::Task[name].prerequisites.push 'yard:eval_md', 'yard:update_readme'
end
define_yard_task.call current_yard_version_name
define_yard_task.call 'master'
desc "* signpost for versions"
YARD::Rake::YardocTask.new(:signpost) do |yard|
yard.options.push(
'--output-dir', 'docs',
'--main', 'docs-source/signpost.md',
*common_yard_options)
yard.files = ['no-lib']
end
define_uptodate_task = -> name do
namespace name do
desc "** ensure that #{name} generated documentation is matching the source code"
task :uptodate do
Dir.chdir(__dir__) do
begin
FileUtils.cp_r 'docs', 'docs-copy', verbose: true
Rake::Task["yard:#{name}"].invoke
sh 'diff -r docs/ docs-copy/'
ensure
FileUtils.rm_rf 'docs-copy', verbose: true
end
end
end
end
end
define_uptodate_task.call current_yard_version_name
define_uptodate_task.call 'master'
end
rescue LoadError => e
puts 'YARD is not installed, skipping documentation task definitions: ' + e.message
end
desc 'build, test, and publish the gem'
task :release => ['release:checks', 'release:build', 'release:test', 'release:publish']
namespace :release do
# Depends on environment of @pitr-ch
mri_version = '2.5.1'
jruby_version = 'jruby-9.1.17.0'
task :checks => "yard:#{current_yard_version_name}:uptodate" do
Dir.chdir(__dir__) do
begin
STDOUT.puts "Is this a final release build? (Do git checks?) (y/n)"
input = STDIN.gets.strip.downcase
end until %w(y n).include?(input)
if input == 'y'
sh 'test -z "$(git status --porcelain)"'
sh 'git fetch'
sh 'test $(git show-ref --verify --hash refs/heads/master) = $(git show-ref --verify --hash refs/remotes/github/master)'
end
end
end
desc '* build all *.gem files necessary for release'
task :build => 'repackage:all'
desc '* test actual installed gems instead of cloned repository on MRI and JRuby'
task :test do
Dir.chdir(__dir__) do
old = ENV['RBENV_VERSION']
ENV['RBENV_VERSION'] = mri_version
sh 'rbenv version'
sh 'bundle exec rake spec:installed'
ENV['RBENV_VERSION'] = jruby_version
sh 'rbenv version'
sh 'bundle exec rake spec:installed'
puts 'Windows build is untested'
ENV['RBENV_VERSION'] = old
end
end
desc '* do all nested steps'
task :publish => ['publish:ask', 'publish:tag', 'publish:rubygems', 'publish:post_steps']
namespace :publish do
task :ask do
begin
STDOUT.puts "Do you want to publish? (y/n)"
input = STDIN.gets.strip.downcase
end until %w(y n).include?(input)
raise 'reconsidered' if input == 'n'
end
desc '** tag HEAD with current version and push to github'
task :tag do
Dir.chdir(__dir__) do
sh "git tag v#{Concurrent::VERSION}"
sh "git tag edge-v#{Concurrent::EDGE_VERSION}"
sh "git push github v#{Concurrent::VERSION} edge-v#{Concurrent::EDGE_VERSION}"
end
end
desc '** push all *.gem files to rubygems'
task :rubygems do
Dir.chdir(__dir__) do
sh "gem push pkg/concurrent-ruby-#{Concurrent::VERSION}.gem"
sh "gem push pkg/concurrent-ruby-edge-#{Concurrent::EDGE_VERSION}.gem"
sh "gem push pkg/concurrent-ruby-ext-#{Concurrent::VERSION}.gem"
sh "gem push pkg/concurrent-ruby-ext-#{Concurrent::VERSION}-x64-mingw32.gem"
sh "gem push pkg/concurrent-ruby-ext-#{Concurrent::VERSION}-x86-mingw32.gem"
end
end
desc '** print post release steps'
task :post_steps do
puts 'Manually: create a release on GitHub with relevant changelog part'
puts 'Manually: send email same as release with relevant changelog part'
puts 'Manually: tweet'
end
end
end