Skip to content

Commit 51de295

Browse files
Adding ruby 2.4 support including testing matrix (#9)
* Add ruby testing matrix (#8) * Add ruby 2.4 support (#8) * Upgrade rubocop to 1.0
1 parent 161e14a commit 51de295

File tree

6 files changed

+47
-33
lines changed

6 files changed

+47
-33
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,27 @@ jobs:
55
runs-on: ubuntu-latest
66
steps:
77
- name: Check out code
8-
uses: actions/checkout@v1
8+
uses: actions/checkout@v2
99
- name: rubocop
1010
uses: reviewdog/action-rubocop@v1
1111
with:
1212
github_token: ${{ secrets.github_token }}
1313
reporter: github-check
1414
rspec:
1515
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
ruby:
19+
- 2.4
20+
- 2.5
21+
- 2.6
22+
- 2.7
23+
name: RSpec tests ruby ${{ matrix.ruby }}
1624
steps:
1725
- name: Check out code
18-
uses: actions/checkout@v1
26+
uses: actions/checkout@v2
1927
- name: Setup caching for ruby gems
20-
uses: actions/cache@v1
28+
uses: actions/cache@v2
2129
with:
2230
path: vendor/bundle
2331
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
@@ -26,7 +34,7 @@ jobs:
2634
- name: Setup Ruby
2735
uses: actions/setup-ruby@v1
2836
with:
29-
ruby-version: 2.7
37+
ruby-version: ${{ matrix.ruby }}
3038
- name: Install gems
3139
run: |
3240
gem install bundler:2.1.4 --no-doc
@@ -38,9 +46,9 @@ jobs:
3846
runs-on: ubuntu-latest
3947
steps:
4048
- name: Check out code
41-
uses: actions/checkout@v1
49+
uses: actions/checkout@v2
4250
- name: Setup caching for ruby gems
43-
uses: actions/cache@v1
51+
uses: actions/cache@v2
4452
with:
4553
path: vendor/bundle
4654
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
AllCops:
2-
TargetRubyVersion: 2.7
2+
TargetRubyVersion: 2.4
33

44
# A top class comment is not needed for this simple gem
55
Style/Documentation:

Gemfile.lock

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,38 @@ PATH
77
GEM
88
remote: https://rubygems.org/
99
specs:
10-
ast (2.4.0)
11-
diff-lcs (1.3)
12-
jaro_winkler (1.5.4)
13-
parallel (1.19.1)
14-
parser (2.7.1.0)
15-
ast (~> 2.4.0)
10+
ast (2.4.1)
11+
diff-lcs (1.4.4)
12+
parallel (1.19.2)
13+
parser (2.7.2.0)
14+
ast (~> 2.4.1)
1615
rainbow (3.0.0)
16+
regexp_parser (1.8.2)
1717
rexml (3.2.4)
1818
rspec (3.9.0)
1919
rspec-core (~> 3.9.0)
2020
rspec-expectations (~> 3.9.0)
2121
rspec-mocks (~> 3.9.0)
22-
rspec-core (3.9.1)
23-
rspec-support (~> 3.9.1)
24-
rspec-expectations (3.9.1)
22+
rspec-core (3.9.3)
23+
rspec-support (~> 3.9.3)
24+
rspec-expectations (3.9.2)
2525
diff-lcs (>= 1.2.0, < 2.0)
2626
rspec-support (~> 3.9.0)
2727
rspec-mocks (3.9.1)
2828
diff-lcs (>= 1.2.0, < 2.0)
2929
rspec-support (~> 3.9.0)
30-
rspec-support (3.9.2)
31-
rubocop (0.81.0)
32-
jaro_winkler (~> 1.5.1)
30+
rspec-support (3.9.3)
31+
rubocop (1.0.0)
3332
parallel (~> 1.10)
34-
parser (>= 2.7.0.1)
33+
parser (>= 2.7.1.5)
3534
rainbow (>= 2.2.2, < 4.0)
35+
regexp_parser (>= 1.8)
3636
rexml
37+
rubocop-ast (>= 0.6.0)
3738
ruby-progressbar (~> 1.7)
3839
unicode-display_width (>= 1.4.0, < 2.0)
40+
rubocop-ast (1.0.0)
41+
parser (>= 2.7.1.5)
3942
ruby-progressbar (1.10.1)
4043
unicode-display_width (1.7.0)
4144

@@ -45,7 +48,7 @@ PLATFORMS
4548
DEPENDENCIES
4649
rspec (~> 3.0)
4750
rspec-github!
48-
rubocop (~> 0.81.0)
51+
rubocop (~> 1.0)
4952

5053
BUNDLED WITH
5154
2.1.4

lib/rspec/github/notification_decorator.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ def annotation
2424
end
2525

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

3031
private

rspec-github.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
1212
spec.description = 'Formatter for RSpec to show errors in GitHub action annotations'
1313
spec.homepage = 'https://drieam.github.io/rspec-github'
1414
spec.license = 'MIT'
15-
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
15+
spec.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
1616

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

2424
spec.add_runtime_dependency 'rspec-core', '~> 3.0'
2525
spec.add_development_dependency 'rspec', '~> 3.0'
26-
spec.add_development_dependency 'rubocop', '~> 0.81.0'
26+
spec.add_development_dependency 'rubocop', '~> 1.0'
2727
end

spec/rspec/github/formatter_spec.rb

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,20 @@
6363

6464
context 'relative_path to GITHUB_WORKSPACE' do
6565
around do |example|
66-
saved_github_workspace = ENV['GITHUB_WORKSPACE']
67-
ENV['GITHUB_WORKSPACE'] = tmpdir
66+
begin
67+
saved_github_workspace = ENV['GITHUB_WORKSPACE']
68+
ENV['GITHUB_WORKSPACE'] = tmpdir
6869

69-
FileUtils.mkpath File.dirname(absolute_path)
70-
FileUtils.touch absolute_path
70+
FileUtils.mkpath File.dirname(absolute_path)
71+
FileUtils.touch absolute_path
7172

72-
Dir.chdir tmpdir do
73-
example.run
73+
Dir.chdir tmpdir do
74+
example.run
75+
end
76+
ensure
77+
FileUtils.rm_r tmpdir
78+
ENV['GITHUB_WORKSPACE'] = saved_github_workspace
7479
end
75-
ensure
76-
FileUtils.rm_r tmpdir
77-
ENV['GITHUB_WORKSPACE'] = saved_github_workspace
7880
end
7981

8082
let(:tmpdir) { Dir.mktmpdir }

0 commit comments

Comments
 (0)