diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index c50680c8..ad2ea03a 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -40,3 +40,6 @@ jobs: - name: Run Build run: bundle exec rake default + + - name: Test Gem + run: bundle exec rake test:gem diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 929b80b2..4f147fe0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -78,12 +78,14 @@ In order to ensure high quality, all pull requests must meet these requirements: ### Unit tests * All changes must be accompanied by new or modified unit tests - * The entire test suite must pass when `bundle exec rake test` is run from the - project's local working copy - -### Continuous Integration - * All tests must pass in the project's [Travis CI](https://travis-ci.org/ruby-git/ruby-git) - build before the pull request will be merged + * The entire test suite must pass when `bundle exec rake default` is run from the + project's local working copy. + +### Continuous integration + * All tests must pass in the project's [GitHub Continuous Integration build](https://github.com/ruby-git/ruby-git/actions?query=workflow%3ACI) + before the pull request will be merged. + * The [Continuous Integration workflow](https://github.com/ruby-git/ruby-git/blob/master/.github/workflows/continuous_integration.yml) + runs both `bundle exec rake default` and `bundle exec rake test:gem` from the project's [Rakefile](https://github.com/ruby-git/ruby-git/blob/master/Rakefile). ### Documentation * New and updated public methods must have [YARD](https://yardoc.org/) diff --git a/Rakefile b/Rakefile index cda2f8cf..730e580a 100644 --- a/Rakefile +++ b/Rakefile @@ -1,4 +1,5 @@ require 'bundler/gem_tasks' +require 'English' require "#{File.expand_path(File.dirname(__FILE__))}/lib/git/version" @@ -41,4 +42,41 @@ unless RUBY_PLATFORM == 'java' # default_tasks << :yardstick end +if RUBY_PLATFORM == 'java' && Gem.win_platform? + # Reimplement the :build and :install task for JRuby on Windows + # There is a bug in JRuby on Windows that makes the `build` task from `bundler/gem_tasks` fail. + # Once https://github.com/jruby/jruby/issues/6516 is fixed, this block can be deleted. + version = Git::VERSION + pkg_name = 'git' + gem_file = "pkg/#{pkg_name}-#{version}.gem" + + Rake::Task[:build].clear + task :build do + FileUtils.mkdir 'pkg' unless File.exist? 'pkg' + `gem build #{pkg_name}.gemspec --output "#{gem_file}" --quiet` + raise 'Gem build failed' unless $CHILD_STATUS.success? + puts "#{pkg_name} #{version} built to #{gem_file}." + end + + Rake::Task[:install].clear + task :install => :build do + `gem install #{gem_file} --quiet` + raise 'Gem install failed' unless $CHILD_STATUS.success? + puts "#{pkg_name} (#{version}) installed." + end + + CLOBBER << gem_file +end + +default_tasks << :build + task default: default_tasks + +desc 'Build and install the git gem and run a sanity check' +task :'test:gem' => :install do + output = `ruby -e "require 'git'; g = Git.open('.'); puts g.log.size"`.chomp + raise 'Gem test failed' unless $CHILD_STATUS.success? + raise 'Expected gem test to return an integer' unless output =~ /^\d+$/ + + puts 'Gem Test Succeeded' +end