Skip to content

Commit

Permalink
Adding ruby 2.4 support including testing matrix (#9)
Browse files Browse the repository at this point in the history
* Add ruby testing matrix (#8)

* Add ruby 2.4 support (#8)

* Upgrade rubocop to 1.0
  • Loading branch information
StefSchenkelaars authored Oct 22, 2020
1 parent 161e14a commit 51de295
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 33 deletions.
20 changes: 14 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,27 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v1
uses: actions/checkout@v2
- name: rubocop
uses: reviewdog/action-rubocop@v1
with:
github_token: ${{ secrets.github_token }}
reporter: github-check
rspec:
runs-on: ubuntu-latest
strategy:
matrix:
ruby:
- 2.4
- 2.5
- 2.6
- 2.7
name: RSpec tests ruby ${{ matrix.ruby }}
steps:
- name: Check out code
uses: actions/checkout@v1
uses: actions/checkout@v2
- name: Setup caching for ruby gems
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
Expand All @@ -26,7 +34,7 @@ jobs:
- name: Setup Ruby
uses: actions/setup-ruby@v1
with:
ruby-version: 2.7
ruby-version: ${{ matrix.ruby }}
- name: Install gems
run: |
gem install bundler:2.1.4 --no-doc
Expand All @@ -38,9 +46,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v1
uses: actions/checkout@v2
- name: Setup caching for ruby gems
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AllCops:
TargetRubyVersion: 2.7
TargetRubyVersion: 2.4

# A top class comment is not needed for this simple gem
Style/Documentation:
Expand Down
31 changes: 17 additions & 14 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,38 @@ PATH
GEM
remote: https://rubygems.org/
specs:
ast (2.4.0)
diff-lcs (1.3)
jaro_winkler (1.5.4)
parallel (1.19.1)
parser (2.7.1.0)
ast (~> 2.4.0)
ast (2.4.1)
diff-lcs (1.4.4)
parallel (1.19.2)
parser (2.7.2.0)
ast (~> 2.4.1)
rainbow (3.0.0)
regexp_parser (1.8.2)
rexml (3.2.4)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-core (3.9.1)
rspec-support (~> 3.9.1)
rspec-expectations (3.9.1)
rspec-core (3.9.3)
rspec-support (~> 3.9.3)
rspec-expectations (3.9.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-mocks (3.9.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.2)
rubocop (0.81.0)
jaro_winkler (~> 1.5.1)
rspec-support (3.9.3)
rubocop (1.0.0)
parallel (~> 1.10)
parser (>= 2.7.0.1)
parser (>= 2.7.1.5)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8)
rexml
rubocop-ast (>= 0.6.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (1.0.0)
parser (>= 2.7.1.5)
ruby-progressbar (1.10.1)
unicode-display_width (1.7.0)

Expand All @@ -45,7 +48,7 @@ PLATFORMS
DEPENDENCIES
rspec (~> 3.0)
rspec-github!
rubocop (~> 0.81.0)
rubocop (~> 1.0)

BUNDLED WITH
2.1.4
3 changes: 2 additions & 1 deletion lib/rspec/github/notification_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def annotation
end

def path
File.realpath(raw_path).delete_prefix("#{workspace}#{File::SEPARATOR}")
# TODO: use `delete_prefix` when dropping ruby 2.4 support
File.realpath(raw_path).sub(/\A#{workspace}#{File::SEPARATOR}/, '')
end

private
Expand Down
4 changes: 2 additions & 2 deletions rspec-github.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
spec.description = 'Formatter for RSpec to show errors in GitHub action annotations'
spec.homepage = 'https://drieam.github.io/rspec-github'
spec.license = 'MIT'
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
spec.required_ruby_version = Gem::Requirement.new('>= 2.4.0')

spec.metadata['allowed_push_host'] = 'https://rubygems.org'
spec.metadata['homepage_uri'] = spec.homepage
Expand All @@ -23,5 +23,5 @@ Gem::Specification.new do |spec|

spec.add_runtime_dependency 'rspec-core', '~> 3.0'
spec.add_development_dependency 'rspec', '~> 3.0'
spec.add_development_dependency 'rubocop', '~> 0.81.0'
spec.add_development_dependency 'rubocop', '~> 1.0'
end
20 changes: 11 additions & 9 deletions spec/rspec/github/formatter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,20 @@

context 'relative_path to GITHUB_WORKSPACE' do
around do |example|
saved_github_workspace = ENV['GITHUB_WORKSPACE']
ENV['GITHUB_WORKSPACE'] = tmpdir
begin
saved_github_workspace = ENV['GITHUB_WORKSPACE']
ENV['GITHUB_WORKSPACE'] = tmpdir

FileUtils.mkpath File.dirname(absolute_path)
FileUtils.touch absolute_path
FileUtils.mkpath File.dirname(absolute_path)
FileUtils.touch absolute_path

Dir.chdir tmpdir do
example.run
Dir.chdir tmpdir do
example.run
end
ensure
FileUtils.rm_r tmpdir
ENV['GITHUB_WORKSPACE'] = saved_github_workspace
end
ensure
FileUtils.rm_r tmpdir
ENV['GITHUB_WORKSPACE'] = saved_github_workspace
end

let(:tmpdir) { Dir.mktmpdir }
Expand Down

0 comments on commit 51de295

Please sign in to comment.