diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..22835e8 --- /dev/null +++ b/.circleci/config.yml @@ -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" diff --git a/.jrubyrc b/.jrubyrc new file mode 100644 index 0000000..ec033ee --- /dev/null +++ b/.jrubyrc @@ -0,0 +1 @@ +debug.fullTrace=true diff --git a/.travis.yml b/.travis.yml index 5218a51..ea2a5bf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,22 @@ language: ruby sudo: false cache: bundler +before_script: + - gem update --system script: ./script/ci rvm: - - 2.3.5 - - 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: allow_failures: - rvm: ruby-head - rvm: jruby-head + - rvm: jruby-9.1.9.0 notifications: webhooks: diff --git a/Gemfile b/Gemfile index 86de0fe..e82b58c 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source "http://rubygems.org" gemspec -unless ENV["TRAVIS"] +unless ENV["CI"] gem "byebug", require: false, platforms: :mri gem "yard", require: false end @@ -12,4 +12,3 @@ gem "hanami-utils", "~> 2.0.alpha", require: false, git: "https://github.com/han gem "hanami-devtools", require: false, git: "https://github.com/hanami/devtools.git" gem "i18n", "~> 0.9", require: false -gem "coveralls", require: false diff --git a/README.md b/README.md index 4e12a77..6635444 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,11 @@ Validations mixin for Ruby objects ## Status -[![Gem Version](http://img.shields.io/gem/v/hanami-validations.svg)](https://badge.fury.io/rb/hanami-validations) -[![Build Status](http://img.shields.io/travis/hanami/validations/master.svg)](https://travis-ci.org/hanami/validations?branch=master) -[![Coverage](http://img.shields.io/coveralls/hanami/validations/master.svg)](https://coveralls.io/r/hanami/validations) -[![Code Climate](http://img.shields.io/codeclimate/github/hanami/validations.svg)](https://codeclimate.com/github/hanami/validations) -[![Dependencies](http://img.shields.io/gemnasium/hanami/validations.svg)](https://gemnasium.com/hanami/validations) +[![Gem Version](https://badge.fury.io/rb/hanami-validations.svg)](https://badge.fury.io/rb/hanami-validations) +[![TravisCI](https://travis-ci.org/hanami/validations.svg?branch=master)](https://travis-ci.org/hanami/validations) +[![CircleCI](https://circleci.com/gh/hanami/validations/tree/master.svg?style=svg)](https://circleci.com/gh/hanami/validations/tree/master) +[![Test Coverage](https://codecov.io/gh/hanami/validations/branch/master/graph/badge.svg)](https://codecov.io/gh/hanami/validations) +[![Depfu](https://badges.depfu.com/badges/a8545fb67cf32a2c75b6227bc0821027/overview.svg)](https://depfu.com/github/hanami/validations?project=Bundler) [![Inline Docs](http://inch-ci.org/github/hanami/validations.svg)](http://inch-ci.org/github/hanami/validations) ## Contact diff --git a/Rakefile b/Rakefile index 2db546a..395223e 100644 --- a/Rakefile +++ b/Rakefile @@ -3,12 +3,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| @@ -17,11 +12,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" diff --git a/script/ci b/script/ci index c495767..84a16a1 100755 --- a/script/ci +++ b/script/ci @@ -2,12 +2,23 @@ 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 . } run_unit_tests() { - bundle exec rake spec:coverage + bundle exec rake spec:unit } run_isolation_tests() { @@ -42,10 +53,17 @@ run_test() { COVERAGE=true bundle exec rspec $test } +upload_code_coverage() { + bundle exec rake codecov:upload +} + main() { - run_code_quality_checks && + prepare_build && + print_ruby_version && + run_code_quality_checks && run_unit_tests && - run_isolation_tests + run_isolation_tests && + upload_code_coverage } main diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 52813f6..0afc0b1 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,36 +1,8 @@ # frozen_string_literal: true -if ENV["COVERALL"] - require "coveralls" - Coveralls.wear! -end - -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 - $LOAD_PATH.unshift "lib" require "hanami/utils" +require "hanami/devtools/unit" require "hanami/validations" require "hanami/validations/form" diff --git a/spec/support/rspec.rb b/spec/support/rspec.rb new file mode 100644 index 0000000..bcdd2b0 --- /dev/null +++ b/spec/support/rspec.rb @@ -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