Code quality tools (#270)
This commit is contained in:
parent
c12e07954d
commit
aa8859844f
|
@ -0,0 +1,141 @@
|
|||
# Ruby CircleCI 2.0 configuration file
|
||||
#
|
||||
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
|
||||
#
|
||||
version: 2
|
||||
jobs:
|
||||
"ruby-2.3":
|
||||
docker:
|
||||
- image: hanami/ruby-2.3
|
||||
working_directory: ~/hanami-utils
|
||||
steps:
|
||||
- checkout
|
||||
# Download and cache dependencies
|
||||
- restore_cache:
|
||||
keys:
|
||||
- v1-dependencies-{{ checksum "Gemfile.lock" }}
|
||||
# fallback to using the latest cache if no exact match is found
|
||||
- v1-dependencies-
|
||||
- run:
|
||||
name: install dependencies
|
||||
command: |
|
||||
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
||||
- save_cache:
|
||||
paths:
|
||||
- ./vendor/bundle
|
||||
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
|
||||
# run tests!
|
||||
- run:
|
||||
name: run tests
|
||||
command: |
|
||||
./script/ci
|
||||
"ruby-2.4":
|
||||
docker:
|
||||
- image: hanami/ruby-2.4
|
||||
working_directory: ~/hanami-utils
|
||||
steps:
|
||||
- checkout
|
||||
# Download and cache dependencies
|
||||
- restore_cache:
|
||||
keys:
|
||||
- v1-dependencies-{{ checksum "Gemfile.lock" }}
|
||||
# fallback to using the latest cache if no exact match is found
|
||||
- v1-dependencies-
|
||||
- run:
|
||||
name: install dependencies
|
||||
command: |
|
||||
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
||||
- save_cache:
|
||||
paths:
|
||||
- ./vendor/bundle
|
||||
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
|
||||
# run tests!
|
||||
- run:
|
||||
name: run tests
|
||||
command: |
|
||||
./script/ci
|
||||
"ruby-2.5":
|
||||
docker:
|
||||
- image: hanami/ruby-2.5
|
||||
working_directory: ~/hanami-utils
|
||||
steps:
|
||||
- checkout
|
||||
# Download and cache dependencies
|
||||
- restore_cache:
|
||||
keys:
|
||||
- v1-dependencies-{{ checksum "Gemfile.lock" }}
|
||||
# fallback to using the latest cache if no exact match is found
|
||||
- v1-dependencies-
|
||||
- run:
|
||||
name: install dependencies
|
||||
command: |
|
||||
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
||||
- save_cache:
|
||||
paths:
|
||||
- ./vendor/bundle
|
||||
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
|
||||
# run tests!
|
||||
- run:
|
||||
name: run tests
|
||||
command: |
|
||||
./script/ci
|
||||
"jruby-9.1":
|
||||
docker:
|
||||
- image: hanami/jruby-9.1
|
||||
working_directory: ~/hanami-utils
|
||||
steps:
|
||||
- checkout
|
||||
# Download and cache dependencies
|
||||
- restore_cache:
|
||||
keys:
|
||||
- v1-dependencies-{{ checksum "Gemfile.lock" }}
|
||||
# fallback to using the latest cache if no exact match is found
|
||||
- v1-dependencies-
|
||||
- run:
|
||||
name: install dependencies
|
||||
command: |
|
||||
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
||||
- save_cache:
|
||||
paths:
|
||||
- ./vendor/bundle
|
||||
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
|
||||
# run tests!
|
||||
- run:
|
||||
name: run tests
|
||||
command: |
|
||||
./script/ci
|
||||
"jruby-9.2":
|
||||
docker:
|
||||
- image: hanami/jruby-9.2
|
||||
working_directory: ~/hanami-utils
|
||||
steps:
|
||||
- checkout
|
||||
# Download and cache dependencies
|
||||
- restore_cache:
|
||||
keys:
|
||||
- v1-dependencies-{{ checksum "Gemfile.lock" }}
|
||||
# fallback to using the latest cache if no exact match is found
|
||||
- v1-dependencies-
|
||||
- run:
|
||||
name: install dependencies
|
||||
command: |
|
||||
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
||||
- save_cache:
|
||||
paths:
|
||||
- ./vendor/bundle
|
||||
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
|
||||
# run tests!
|
||||
- run:
|
||||
name: run tests
|
||||
command: |
|
||||
./script/ci
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
build:
|
||||
jobs:
|
||||
- "ruby-2.3"
|
||||
- "ruby-2.4"
|
||||
- "ruby-2.5"
|
||||
- "jruby-9.1"
|
||||
- "jruby-9.2"
|
12
.travis.yml
12
.travis.yml
|
@ -1,13 +1,15 @@
|
|||
language: ruby
|
||||
sudo: false
|
||||
cache: bundler
|
||||
script: 'script/ci'
|
||||
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:
|
||||
|
|
4
Gemfile
4
Gemfile
|
@ -1,7 +1,7 @@
|
|||
source 'http://rubygems.org'
|
||||
gemspec
|
||||
|
||||
unless ENV['TRAVIS']
|
||||
unless ENV['CI']
|
||||
gem 'byebug', require: false, platforms: :mri
|
||||
gem 'yard', require: false
|
||||
end
|
||||
|
@ -13,4 +13,4 @@ group :validations do
|
|||
gem 'hanami-validations', '~> 1.2', require: false, git: 'https://github.com/hanami/validations.git', branch: 'master'
|
||||
end
|
||||
|
||||
gem 'coveralls', require: false
|
||||
gem 'hanami-devtools', require: false, git: 'https://github.com/hanami/devtools.git'
|
||||
|
|
12
README.md
12
README.md
|
@ -4,12 +4,12 @@ Complete, fast and testable actions for Rack and [Hanami](http://hanamirb.org)
|
|||
|
||||
## Status
|
||||
|
||||
[![Gem Version](https://badge.fury.io/rb/hanami-controller.png)](http://badge.fury.io/rb/hanami-controller)
|
||||
[![Build Status](https://secure.travis-ci.org/hanami/controller.png?branch=master)](http://travis-ci.org/hanami/controller?branch=master)
|
||||
[![Coverage](https://coveralls.io/repos/hanami/controller/badge.png?branch=master)](https://coveralls.io/r/hanami/controller)
|
||||
[![Code Climate](https://codeclimate.com/github/hanami/controller.png)](https://codeclimate.com/github/hanami/controller)
|
||||
[![Dependencies](https://gemnasium.com/hanami/controller.png)](https://gemnasium.com/hanami/controller)
|
||||
[![Inline docs](http://inch-ci.org/github/hanami/controller.png)](http://inch-ci.org/github/hanami/controller)
|
||||
[![Gem Version](https://badge.fury.io/rb/hanami-controller.svg)](https://badge.fury.io/rb/hanami-controller)
|
||||
[![TravisCI](https://travis-ci.org/hanami/controller.svg?branch=master)](https://travis-ci.org/hanami/controller)
|
||||
[![CircleCI](https://circleci.com/gh/hanami/controller/tree/master.svg?style=svg)](https://circleci.com/gh/hanami/controller/tree/master)
|
||||
[![Test Coverage](https://codecov.io/gh/hanami/controller/branch/master/graph/badge.svg)](https://codecov.io/gh/hanami/controller)
|
||||
[![Depfu](https://badges.depfu.com/badges/7cd17419fba78b726be1353118fb01de/overview.svg)](https://depfu.com/github/hanami/controller?project=Bundler)
|
||||
[![Inline Docs](http://inch-ci.org/github/hanami/controller.svg)](http://inch-ci.org/github/hanami/controller)
|
||||
|
||||
## Contact
|
||||
|
||||
|
|
12
Rakefile
12
Rakefile
|
@ -1,12 +1,7 @@
|
|||
require 'rake'
|
||||
require 'bundler/gem_tasks'
|
||||
require 'rspec/core/rake_task'
|
||||
|
||||
require 'rake/testtask'
|
||||
Rake::TestTask.new do |t|
|
||||
t.pattern = 'test/**/*_test.rb'
|
||||
t.libs.push 'test'
|
||||
end
|
||||
require 'hanami/devtools/rake_tasks'
|
||||
|
||||
namespace :spec do
|
||||
RSpec::Core::RakeTask.new(:unit) do |task|
|
||||
|
@ -15,11 +10,6 @@ namespace :spec do
|
|||
|
||||
task.pattern = file_list
|
||||
end
|
||||
|
||||
task :coverage do
|
||||
ENV['COVERAGE'] = 'true'
|
||||
Rake::Task['spec:unit'].invoke
|
||||
end
|
||||
end
|
||||
|
||||
task default: 'spec:unit'
|
||||
|
|
36
script/ci
36
script/ci
|
@ -2,8 +2,24 @@
|
|||
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() {
|
||||
|
@ -40,22 +56,32 @@ run_integration_tests() {
|
|||
|
||||
run_isolation_test() {
|
||||
local test=$1
|
||||
local hash="$(shasum "$test" | cut -b 1-40)"
|
||||
|
||||
printf "\n\n\nRunning: $test\n"
|
||||
ruby $test --options spec/isolation/.rspec
|
||||
CI=true SIMPLECOV_COMMAND_NAME=$hash ruby $test --options spec/isolation/.rspec
|
||||
}
|
||||
|
||||
run_test() {
|
||||
local test=$1
|
||||
local hash="$(shasum "$test" | cut -b 1-40)"
|
||||
|
||||
printf "\n\n\nRunning: $test\n"
|
||||
COVERAGE=true bundle exec rspec $test
|
||||
CI=true SIMPLECOV_COMMAND_NAME=$hash bundle exec rspec $test
|
||||
}
|
||||
|
||||
upload_code_coverage() {
|
||||
bundle exec rake codecov:upload
|
||||
}
|
||||
|
||||
main() {
|
||||
run_unit_tests &&
|
||||
prepare_build &&
|
||||
print_ruby_version &&
|
||||
run_code_quality_checks &&
|
||||
run_unit_tests &&
|
||||
run_isolation_tests &&
|
||||
run_integration_tests
|
||||
run_integration_tests &&
|
||||
upload_code_coverage
|
||||
}
|
||||
|
||||
main
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
if ENV['COVERALL']
|
||||
require 'coveralls'
|
||||
Coveralls.wear!
|
||||
end
|
||||
|
||||
require 'hanami/utils'
|
||||
$LOAD_PATH.unshift 'lib'
|
||||
require 'hanami/utils'
|
||||
require 'hanami/devtools/unit'
|
||||
require 'hanami/controller'
|
||||
require 'hanami/action/cookies'
|
||||
require 'hanami/action/session'
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
require 'rubygems'
|
||||
require 'bundler'
|
||||
Bundler.setup(:default, :development)
|
||||
Bundler.setup(:default, :development, :test)
|
||||
|
||||
$LOAD_PATH.unshift 'lib'
|
||||
require 'hanami/controller'
|
||||
require_relative './rspec'
|
||||
require 'hanami/devtools/unit'
|
||||
|
||||
module RSpec
|
||||
module Support
|
||||
|
|
Loading…
Reference in New Issue