add rspec and rubocop binstubs, and lint the project (#21)

This commit is contained in:
Andrew Mason 2019-10-28 20:43:08 -04:00 committed by GitHub
parent b796f9a6dd
commit ff8ddd9bd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 209 additions and 7 deletions

26
.github/workflows/rubocop.yml vendored Normal file
View File

@ -0,0 +1,26 @@
name: Rubocop
on:
pull_request:
branches:
- '*'
push:
branches:
- master
jobs:
rubocop:
name: Ruocop Action
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up Ruby 2.6
uses: actions/setup-ruby@v1
with:
ruby-version: 2.6.x
- name: Bundle
run: |
gem install bundler
bundle install --jobs 4 --retry 3
- name: Run Rubocop
run: bin/rubocop

26
.github/workflows/test.yml vendored Normal file
View File

@ -0,0 +1,26 @@
name: Test
on:
pull_request:
branches:
- '*'
push:
branches:
- master
jobs:
test:
name: Rspec Test Action
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up Ruby 2.6
uses: actions/setup-ruby@v1
with:
ruby-version: 2.6.x
- name: Bundle
run: |
gem install bundler
bundle install --jobs 4 --retry 3
- name: Run Rspec
run: bin/rspec

11
.rubocop.yml Normal file
View File

@ -0,0 +1,11 @@
Layout/IndentFirstHashElement:
EnforcedStyle: consistent
Metrics/MethodLength:
Max: 16
Style/Documentation:
Enabled: false
Metrics/LineLength:
Max: 120

14
Gemfile Normal file
View File

@ -0,0 +1,14 @@
# frozen_string_literal: true
source 'https://rubygems.org'
group :development do
gem 'rubocop', '~> 0.76.0'
end
group :test do
gem 'json', '~> 2.2'
gem 'pry', '~> 0.12.2'
gem 'rspec', '~> 3.9.0'
gem 'webmock', '~> 3.7', '>= 3.7.6'
end

62
Gemfile.lock Normal file
View File

@ -0,0 +1,62 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
ast (2.4.0)
coderay (1.1.2)
crack (0.4.3)
safe_yaml (~> 1.0.0)
diff-lcs (1.3)
hashdiff (1.0.0)
jaro_winkler (1.5.3)
json (2.2.0)
method_source (0.9.2)
parallel (1.18.0)
parser (2.6.5.0)
ast (~> 2.4.0)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
public_suffix (4.0.1)
rainbow (3.0.0)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-core (3.9.0)
rspec-support (~> 3.9.0)
rspec-expectations (3.9.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-mocks (3.9.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.0)
rubocop (0.76.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.6)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 1.7)
ruby-progressbar (1.10.1)
safe_yaml (1.0.5)
unicode-display_width (1.6.0)
webmock (3.7.6)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
PLATFORMS
ruby
DEPENDENCIES
json (~> 2.2)
pry (~> 0.12.2)
rspec (~> 3.9.0)
rubocop (~> 0.76.0)
webmock (~> 3.7, >= 3.7.6)
BUNDLED WITH
2.0.2

29
bin/rspec Executable file
View File

@ -0,0 +1,29 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
#
# This file was generated by Bundler.
#
# The application 'rspec' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
Pathname.new(__FILE__).realpath)
bundle_binstub = File.expand_path('bundle', __dir__)
if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end
require 'rubygems'
require 'bundler/setup'
load Gem.bin_path('rspec-core', 'rspec')

29
bin/rubocop Executable file
View File

@ -0,0 +1,29 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
#
# This file was generated by Bundler.
#
# The application 'rubocop' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
Pathname.new(__FILE__).realpath)
bundle_binstub = File.expand_path('bundle', __dir__)
if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end
require 'rubygems'
require 'bundler/setup'
load Gem.bin_path('rubocop', 'rubocop')

View File

@ -54,5 +54,4 @@ class GithubCheckRunService
}
}
end
end

View File

@ -30,13 +30,13 @@ class ReportAdapter
return annotation_list if count == 48
location = offense['location']
annotation_list.push({
annotation_list.push(
'path' => file['path'],
'start_line' => location['start_line'],
'end_line' => location['last_line'],
'annotation_level' => annotation_level(offense['severity']),
'message' => offense['message']
})
)
end
end
end

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require './spec/spec_helper'
describe GithubCheckRunService do

View File

@ -1,9 +1,11 @@
# frozen_string_literal: true
require './spec/spec_helper'
describe ReportAdapter do
let(:rubocop_report) {
let(:rubocop_report) do
JSON(File.read('./spec/fixtures/report.json'))
}
end
let(:adapter) { ReportAdapter }
@ -19,12 +21,12 @@ describe ReportAdapter do
it '.annotations' do
result = adapter.annotations(rubocop_report)
expect(result.first).to eq({
expect(result.first).to eq(
'path' => 'Gemfile',
'start_line' => 1,
'end_line' => 1,
'annotation_level' => 'failure',
'message' => 'Missing magic comment `# frozen_string_literal: true`.'
})
)
end
end

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'webmock/rspec'
require 'json'
require 'pry'