Skip to content

Commit d1b1711

Browse files
authored
Add gem build, install, and sanity test to CI build (ruby-git#509)
Signed-off-by: James Couball <jcouball@yahoo.com>
1 parent 3c66e2b commit d1b1711

File tree

3 files changed

+49
-6
lines changed

3 files changed

+49
-6
lines changed

.github/workflows/continuous_integration.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,6 @@ jobs:
4040

4141
- name: Run Build
4242
run: bundle exec rake default
43+
44+
- name: Test Gem
45+
run: bundle exec rake test:gem

CONTRIBUTING.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,14 @@ In order to ensure high quality, all pull requests must meet these requirements:
7878

7979
### Unit tests
8080
* All changes must be accompanied by new or modified unit tests
81-
* The entire test suite must pass when `bundle exec rake test` is run from the
82-
project's local working copy
83-
84-
### Continuous Integration
85-
* All tests must pass in the project's [Travis CI](https://travis-ci.org/ruby-git/ruby-git)
86-
build before the pull request will be merged
81+
* The entire test suite must pass when `bundle exec rake default` is run from the
82+
project's local working copy.
83+
84+
### Continuous integration
85+
* All tests must pass in the project's [GitHub Continuous Integration build](https://github.com/ruby-git/ruby-git/actions?query=workflow%3ACI)
86+
before the pull request will be merged.
87+
* The [Continuous Integration workflow](https://github.com/ruby-git/ruby-git/blob/master/.github/workflows/continuous_integration.yml)
88+
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).
8789

8890
### Documentation
8991
* New and updated public methods must have [YARD](https://yardoc.org/)

Rakefile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'bundler/gem_tasks'
2+
require 'English'
23

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

@@ -41,4 +42,41 @@ unless RUBY_PLATFORM == 'java'
4142
# default_tasks << :yardstick
4243
end
4344

45+
if RUBY_PLATFORM == 'java' && Gem.win_platform?
46+
# Reimplement the :build and :install task for JRuby on Windows
47+
# There is a bug in JRuby on Windows that makes the `build` task from `bundler/gem_tasks` fail.
48+
# Once https://github.com/jruby/jruby/issues/6516 is fixed, this block can be deleted.
49+
version = Git::VERSION
50+
pkg_name = 'git'
51+
gem_file = "pkg/#{pkg_name}-#{version}.gem"
52+
53+
Rake::Task[:build].clear
54+
task :build do
55+
FileUtils.mkdir 'pkg' unless File.exist? 'pkg'
56+
`gem build #{pkg_name}.gemspec --output "#{gem_file}" --quiet`
57+
raise 'Gem build failed' unless $CHILD_STATUS.success?
58+
puts "#{pkg_name} #{version} built to #{gem_file}."
59+
end
60+
61+
Rake::Task[:install].clear
62+
task :install => :build do
63+
`gem install #{gem_file} --quiet`
64+
raise 'Gem install failed' unless $CHILD_STATUS.success?
65+
puts "#{pkg_name} (#{version}) installed."
66+
end
67+
68+
CLOBBER << gem_file
69+
end
70+
71+
default_tasks << :build
72+
4473
task default: default_tasks
74+
75+
desc 'Build and install the git gem and run a sanity check'
76+
task :'test:gem' => :install do
77+
output = `ruby -e "require 'git'; g = Git.open('.'); puts g.log.size"`.chomp
78+
raise 'Gem test failed' unless $CHILD_STATUS.success?
79+
raise 'Expected gem test to return an integer' unless output =~ /^\d+$/
80+
81+
puts 'Gem Test Succeeded'
82+
end

0 commit comments

Comments
 (0)