Code quality tools (#172)
This commit is contained in:
parent
17dc711448
commit
a30c0bda54
|
@ -6,7 +6,7 @@ version: 2
|
|||
jobs:
|
||||
"ruby-2.3":
|
||||
docker:
|
||||
- image: circleci/ruby:2.3.7
|
||||
- image: hanami/ruby-2.3
|
||||
working_directory: ~/hanami-utils
|
||||
steps:
|
||||
- checkout
|
||||
|
@ -31,7 +31,7 @@ jobs:
|
|||
./script/ci
|
||||
"ruby-2.4":
|
||||
docker:
|
||||
- image: circleci/ruby:2.4.4
|
||||
- image: hanami/ruby-2.4
|
||||
working_directory: ~/hanami-utils
|
||||
steps:
|
||||
- checkout
|
||||
|
@ -56,7 +56,7 @@ jobs:
|
|||
./script/ci
|
||||
"ruby-2.5":
|
||||
docker:
|
||||
- image: circleci/ruby:2.5.1
|
||||
- image: hanami/ruby-2.5
|
||||
working_directory: ~/hanami-utils
|
||||
steps:
|
||||
- checkout
|
||||
|
@ -81,7 +81,7 @@ jobs:
|
|||
./script/ci
|
||||
"jruby-9.1":
|
||||
docker:
|
||||
- image: circleci/jruby:9.1.17.0
|
||||
- image: hanami/jruby-9.1
|
||||
working_directory: ~/hanami-utils
|
||||
steps:
|
||||
- checkout
|
||||
|
@ -106,7 +106,7 @@ jobs:
|
|||
./script/ci
|
||||
"jruby-9.2":
|
||||
docker:
|
||||
- image: circleci/jruby:9.2.0.0
|
||||
- image: hanami/jruby-9.2
|
||||
working_directory: ~/hanami-utils
|
||||
steps:
|
||||
- checkout
|
||||
|
|
|
@ -17,4 +17,5 @@ spec/reports
|
|||
test/tmp
|
||||
test/version_tmp
|
||||
tmp
|
||||
bin
|
||||
bin
|
||||
.rubocop-*
|
||||
|
|
10
.travis.yml
10
.travis.yml
|
@ -1,13 +1,15 @@
|
|||
language: ruby
|
||||
sudo: false
|
||||
cache: bundler
|
||||
before_script:
|
||||
- gem update --system
|
||||
script: ./script/ci
|
||||
rvm:
|
||||
- 2.3.6
|
||||
- 2.4.2
|
||||
- 2.5.0
|
||||
- 2.4.4
|
||||
- 2.3.7
|
||||
- 2.5.1
|
||||
- jruby-9.1.9.0
|
||||
- ruby-head
|
||||
- jruby-9.1.13.0
|
||||
- jruby-head
|
||||
|
||||
matrix:
|
||||
|
|
15
Gemfile
15
Gemfile
|
@ -1,10 +1,13 @@
|
|||
source 'https://rubygems.org'
|
||||
# frozen_string_literal: true
|
||||
|
||||
source "https://rubygems.org"
|
||||
gemspec
|
||||
|
||||
unless ENV['TRAVIS']
|
||||
gem 'byebug', require: false, platforms: :mri
|
||||
gem 'yard', require: false
|
||||
unless ENV["CI"]
|
||||
gem "byebug", require: false, platforms: :mri
|
||||
gem "yard", require: false
|
||||
end
|
||||
|
||||
gem 'hanami-utils', '~> 1.2', require: false, git: 'https://github.com/hanami/utils.git', branch: 'master'
|
||||
gem 'coveralls', require: false
|
||||
gem "hanami-utils", "~> 1.2", require: false, git: "https://github.com/hanami/utils.git", branch: "master"
|
||||
|
||||
gem "hanami-devtools", require: false, git: "https://github.com/hanami/devtools.git"
|
||||
|
|
12
README.md
12
README.md
|
@ -4,12 +4,12 @@ Rack compatible, lightweight and fast HTTP Router for Ruby and [Hanami](http://h
|
|||
|
||||
## Status
|
||||
|
||||
[![Gem Version](http://img.shields.io/gem/v/hanami-router.svg)](https://badge.fury.io/rb/hanami-router)
|
||||
[![Build Status](http://img.shields.io/travis/hanami/router/master.svg)](https://travis-ci.org/hanami/router?branch=master)
|
||||
[![Coverage](http://img.shields.io/coveralls/hanami/router/master.svg)](https://coveralls.io/r/hanami/router)
|
||||
[![Code Climate](http://img.shields.io/codeclimate/github/hanami/router.svg)](https://codeclimate.com/github/hanami/router)
|
||||
[![Dependencies](http://img.shields.io/gemnasium/hanami/router.svg)](https://gemnasium.com/hanami/router)
|
||||
[![Inline docs](http://inch-ci.org/github/hanami/router.png)](http://inch-ci.org/github/hanami/router)
|
||||
[![Gem Version](https://badge.fury.io/rb/hanami-router.svg)](https://badge.fury.io/rb/hanami-router)
|
||||
[![TravisCI](https://travis-ci.org/hanami/router.svg?branch=master)](https://travis-ci.org/hanami/router)
|
||||
[![CircleCI](https://circleci.com/gh/hanami/router/tree/master.svg?style=svg)](https://circleci.com/gh/hanami/router/tree/master)
|
||||
[![Test Coverage](https://codecov.io/gh/hanami/router/branch/master/graph/badge.svg)](https://codecov.io/gh/hanami/router)
|
||||
[![Depfu](https://badges.depfu.com/badges/5f6b8e8fa3b0d082539f0b0f84d55960/overview.svg)](https://depfu.com/github/hanami/router?project=Bundler)
|
||||
[![Inline Docs](http://inch-ci.org/github/hanami/router.svg)](http://inch-ci.org/github/hanami/router)
|
||||
|
||||
## Contact
|
||||
|
||||
|
|
22
Rakefile
22
Rakefile
|
@ -1,24 +1,16 @@
|
|||
require 'rake'
|
||||
require 'rake/testtask'
|
||||
require 'bundler/gem_tasks'
|
||||
require 'rspec/core/rake_task'
|
||||
# frozen_string_literal: true
|
||||
|
||||
Rake::TestTask.new do |t|
|
||||
t.pattern = 'test/**/*_test.rb'
|
||||
t.libs.push 'test'
|
||||
end
|
||||
require "rake"
|
||||
require "bundler/gem_tasks"
|
||||
require "rspec/core/rake_task"
|
||||
require "hanami/devtools/rake_tasks"
|
||||
|
||||
namespace :spec do
|
||||
RSpec::Core::RakeTask.new(:unit) do |task|
|
||||
file_list = FileList['spec/**/*_spec.rb']
|
||||
file_list = FileList["spec/**/*_spec.rb"]
|
||||
|
||||
task.pattern = file_list
|
||||
end
|
||||
|
||||
task :coverage do
|
||||
ENV['COVERAGE'] = 'true'
|
||||
Rake::Task['spec:unit'].invoke
|
||||
end
|
||||
end
|
||||
|
||||
task default: 'spec:unit'
|
||||
task default: "spec:unit"
|
||||
|
|
59
script/ci
59
script/ci
|
@ -2,12 +2,67 @@
|
|||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
prepare_build() {
|
||||
if [ -d coverage ]; then
|
||||
rm -rf coverage
|
||||
fi
|
||||
}
|
||||
|
||||
print_ruby_version() {
|
||||
echo "Using $(ruby -v)"
|
||||
echo
|
||||
}
|
||||
|
||||
run_code_quality_checks() {
|
||||
# bundle exec rubocop .
|
||||
true
|
||||
}
|
||||
|
||||
run_unit_tests() {
|
||||
bundle exec rake spec:coverage
|
||||
bundle exec rake spec:unit
|
||||
}
|
||||
|
||||
run_isolation_tests() {
|
||||
local pwd=$PWD
|
||||
local root="$pwd/spec/isolation"
|
||||
|
||||
for test in $(find $root -name '*_spec.rb')
|
||||
do
|
||||
run_isolation_test $test
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
local exit_code=$?
|
||||
echo "Failing test: $test"
|
||||
exit $exit_code
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
upload_code_coverage() {
|
||||
bundle exec rake codecov:upload
|
||||
}
|
||||
|
||||
run_isolation_test() {
|
||||
local test=$1
|
||||
|
||||
printf "\n\n\nRunning: $test\n"
|
||||
ruby $test --options spec/isolation/.rspec
|
||||
}
|
||||
|
||||
run_test() {
|
||||
local test=$1
|
||||
|
||||
printf "\n\n\nRunning: $test\n"
|
||||
CI=true bundle exec rspec $test
|
||||
}
|
||||
|
||||
main() {
|
||||
run_unit_tests
|
||||
prepare_build &&
|
||||
print_ruby_version &&
|
||||
run_code_quality_checks &&
|
||||
run_unit_tests &&
|
||||
run_isolation_tests &&
|
||||
upload_code_coverage
|
||||
}
|
||||
|
||||
main
|
||||
|
|
|
@ -1,38 +1,9 @@
|
|||
if ENV['COVERALL']
|
||||
require 'coveralls'
|
||||
Coveralls.wear!
|
||||
end
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'hanami/utils'
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.expect_with :rspec do |expectations|
|
||||
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
||||
end
|
||||
|
||||
config.mock_with :rspec do |mocks|
|
||||
mocks.verify_partial_doubles = true
|
||||
end
|
||||
|
||||
config.shared_context_metadata_behavior = :apply_to_host_groups
|
||||
|
||||
config.filter_run_when_matching :focus
|
||||
config.disable_monkey_patching!
|
||||
|
||||
config.warnings = true
|
||||
|
||||
config.default_formatter = 'doc' if config.files_to_run.one?
|
||||
|
||||
config.profile_examples = 10
|
||||
|
||||
config.order = :random
|
||||
Kernel.srand config.seed
|
||||
end
|
||||
|
||||
require 'support/generation_test_case'
|
||||
require 'support/recognition_test_case'
|
||||
$:.unshift 'lib'
|
||||
require 'hanami-router'
|
||||
$LOAD_PATH.unshift "lib"
|
||||
require "hanami/utils"
|
||||
require "hanami/devtools/unit"
|
||||
require "hanami/router"
|
||||
|
||||
Rack::MockResponse.class_eval do
|
||||
def equal?(other)
|
||||
|
@ -50,4 +21,4 @@ Hanami::Router.class_eval do
|
|||
end
|
||||
end
|
||||
|
||||
Hanami::Utils.require!("spec/support")
|
||||
Hanami::Utils.require!("spec/support")
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.expect_with :rspec do |expectations|
|
||||
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
||||
end
|
||||
|
||||
config.mock_with :rspec do |mocks|
|
||||
mocks.verify_partial_doubles = true
|
||||
end
|
||||
|
||||
config.shared_context_metadata_behavior = :apply_to_host_groups
|
||||
|
||||
config.filter_run_when_matching :focus
|
||||
config.disable_monkey_patching!
|
||||
|
||||
config.warnings = true
|
||||
|
||||
config.default_formatter = "doc" if config.files_to_run.one?
|
||||
|
||||
config.profile_examples = 10
|
||||
|
||||
config.order = :random
|
||||
Kernel.srand config.seed
|
||||
end
|
Loading…
Reference in New Issue