Skip to content

Add gem build, install, and sanity test to the CI build #509

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 11, 2021
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
Add gem build, install, and sanity test to CI build
Signed-off-by: James Couball <jcouball@yahoo.com>
  • Loading branch information
jcouball committed Jan 10, 2021
commit 2575405ebe1938ce32867b39f521aaf36d9f2674
3 changes: 3 additions & 0 deletions .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ jobs:

- name: Run Build
run: bundle exec rake default

- name: Test Gem
run: bundle exec rake test:gem
14 changes: 8 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
Expand Down
38 changes: 38 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'bundler/gem_tasks'
require 'English'

require "#{File.expand_path(File.dirname(__FILE__))}/lib/git/version"

Expand Down Expand Up @@ -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