Skip to content

Commit

Permalink
Prepare for improving tests (#473)
Browse files Browse the repository at this point in the history
* Mandatory rubocop commit

Use shared gem for rubocop

* Adds some binstubs

* Mandatory rubocop commit

* Prepare to ease testing

* Kill rubocop on codeclimate

* Bump appraisals

* Provide queue
  • Loading branch information
mhenrixon authored Mar 20, 2020
1 parent 40db285 commit 5dbb796
Show file tree
Hide file tree
Showing 182 changed files with 896 additions and 586 deletions.
2 changes: 1 addition & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ plugins:
config:
file: .reek.yml
rubocop:
enabled: true
enabled: false
channel: rubocop-0-76
config:
file: .rubocop.yml
Expand Down
1 change: 1 addition & 0 deletions .reek.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ detectors:
- SidekiqUniqueJobs::BatchDelete#batch_delete
- SidekiqUniqueJobs::Digests#page
- SidekiqUniqueJobs::Digests#page
- SidekiqUniqueJobs::InvalidUniqueArguments#initialize
- SidekiqUniqueJobs::InvalidWorker#initialize
- SidekiqUniqueJobs::Logging#debug_item
- SidekiqUniqueJobs::NotUniqueWorker#initialize
Expand Down
3 changes: 2 additions & 1 deletion .rspec
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
--color
--require spec_helper
--color
--order random
42 changes: 15 additions & 27 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
require:
- rubocop-performance
- rubocop-rspec

inherit_mode:
merge:
- Exclude
inherit_gem:
rubocop-mhenrixon:
- config/default.yml

AllCops:
TargetRubyVersion: 2.5
Include:
- "**/Rakefile"
- "**/Gemfile"
- "*.gemspec"
- "lib/**/*.rb"
- "bin/**/*.rb"
- "spec/**/*.rb"
- "examples/**/*.rb"
Exclude:
- "Gemfile.lock"
- "**/*.erb"
- "gemfiles/**/*"
- "**/*.lua"
- "bin/bench"

Layout/EndAlignment:
Expand All @@ -41,9 +30,6 @@ Metrics/AbcSize:
Metrics/CyclomaticComplexity:
Max: 7

Metrics/LineLength:
Max: 125

Metrics/MethodLength:
Max: 13

Expand Down Expand Up @@ -76,9 +62,6 @@ Naming/MethodParameterName:
AllowedNames:
- ex

RSpec/AlignLeftLetBrace:
Enabled: true

RSpec/DescribeClass:
Exclude:
- spec/sidekiq/api_spec.rb
Expand Down Expand Up @@ -130,12 +113,6 @@ Style/Documentation:
Style/FrozenStringLiteralComment:
Enabled: true

Style/GlobalVars:
Enabled: true

Style/ModuleFunction:
Enabled: false

Style/StringLiterals:
Enabled: true
EnforcedStyle: double_quotes
Expand Down Expand Up @@ -164,3 +141,14 @@ Style/TrailingCommaInArrayLiteral:
Style/TrailingCommaInHashLiteral:
Enabled: true
EnforcedStyleForMultiline: comma

Style/GlobalVars:
Enabled: true

Style/ModuleFunction:
Enabled: false

ThreadSafety/InstanceVariableInClassMethod:
Exclude:
- lib/sidekiq_unique_jobs/web.rb

31 changes: 17 additions & 14 deletions .simplecov
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
require 'simplecov-json'
# frozen_string_literal: true

SimpleCov.command_name 'RSpec'
require "simplecov-material"
require "simplecov-oj"

SimpleCov.command_name "RSpec"
# SimpleCov.refuse_coverage_drop
SimpleCov.formatters = [
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::JSONFormatter,
SimpleCov::Formatter::MaterialFormatter,
SimpleCov::Formatter::OjFormatter,
]

SimpleCov.start do
add_filter '/spec/'
add_filter '/bin/'
add_filter '/gemfiles/'
add_filter '/lib/sidekiq/'
add_filter '/lib/sidekiq_unique_jobs/testing.rb'
add_filter '/lib/sidekiq_unique_jobs/core_ext.rb'
add_filter "/spec/"
add_filter "/bin/"
add_filter "/gemfiles/"
add_filter "/lib/sidekiq/"
add_filter "/lib/sidekiq_unique_jobs/testing.rb"
add_filter "/lib/sidekiq_unique_jobs/core_ext.rb"

add_group 'Locks', 'lib/sidekiq_unique_jobs/lock'
add_group 'Middelware', 'lib/sidekiq_unique_jobs/middleware'
add_group 'Redis', 'lib/sidekiq_unique_jobs/redis'
add_group 'Timeout', 'lib/sidekiq_unique_jobs/timeout'
add_group "Locks", "lib/sidekiq_unique_jobs/lock"
add_group "Middelware", "lib/sidekiq_unique_jobs/middleware"
add_group "Redis", "lib/sidekiq_unique_jobs/redis"
add_group "Timeout", "lib/sidekiq_unique_jobs/timeout"
end
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
- redis-server

before_install:
- gem install bundler -v 2.0.2
- gem update bundler
- >
if [[ "${COV}" = "true" ]]; then
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter;
Expand Down Expand Up @@ -62,7 +62,7 @@ gemfile:
notifications:
email:
recipients:
- mikael@zoolutions.se
- mikael@mhenrixon.com
slack:
rooms:
secure: B05ZUPdHrhxVnz7Mlpd5KhFH2bdE9ykFRgqLFHV3EcdyWKm85PPgbfl4cNPTFXHHhzk/5E9h5hwEXpicJYSsq6lhU8i3WesidrA+GHzrpesowTHpvtJMxIjsE1Tavug0xQs/bca72yN2t51m8UiD1scOSIuvSOCNkuKkn3+rSIo=
Expand Down
32 changes: 16 additions & 16 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
# frozen_string_literal: true

appraise 'sidekiq-develop' do
gem 'sidekiq', git: 'https://github.com/mperham/sidekiq.git'
appraise "sidekiq-develop" do
gem "sidekiq", git: "https://github.com/mperham/sidekiq.git"
end

appraise 'sidekiq-4.0' do
gem 'sidekiq', '~> 4.0.0'
appraise "sidekiq-4.0" do
gem "sidekiq", "~> 4.0.0"
end

appraise 'sidekiq-4.1' do
gem 'sidekiq', '~> 4.1.0'
appraise "sidekiq-4.1" do
gem "sidekiq", "~> 4.1.0"
end

appraise 'sidekiq-4.2' do
gem 'sidekiq', '~> 4.2.0'
appraise "sidekiq-4.2" do
gem "sidekiq", "~> 4.2.0"
end

appraise 'sidekiq-5.0' do
gem 'sidekiq', '~> 5.0.0'
appraise "sidekiq-5.0" do
gem "sidekiq", "~> 5.0.0"
end

appraise 'sidekiq-5.1' do
gem 'sidekiq', '~> 5.1.0'
appraise "sidekiq-5.1" do
gem "sidekiq", "~> 5.1.0"
end

appraise 'sidekiq-5.2' do
gem 'sidekiq', '~> 5.2.0'
appraise "sidekiq-5.2" do
gem "sidekiq", "~> 5.2.0"
end

appraise 'sidekiq-6.0' do
gem 'sidekiq', ">= 6.0.pre", "< 6.1"
appraise "sidekiq-6.0" do
gem "sidekiq", ">= 6.0.pre", "< 6.1"
end
17 changes: 11 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,28 @@ gem "rspec-its", require: false

platforms :mri do
gem "fasterer"
gem "fuubar"
gem "github_changelog_generator"
gem "guard"
gem "guard-bundler"
gem "guard-reek"
gem "guard-rspec"
gem "guard-rubocop"
gem "hiredis"
gem "pry"
gem "redcarpet", "~> 3.4"
gem "reek", ">= 5.3"
gem "rspec-benchmark"
gem "rubocop"
gem "rubocop-performance"
gem "rubocop-rspec"
gem "simplecov-json"
gem "rubocop-mhenrixon"
gem "simplecov-material"
gem "simplecov-oj"
gem "travis"
end

if respond_to?(:install_if)
install_if -> { RUBY_PLATFORM =~ /darwin/ } do
gem "fuubar"
gem "pry"
gem "rspec-nc"
end
end

eval(File.read(LOCAL_GEMS)) if File.exist?(LOCAL_GEMS) # rubocop:disable Security/Eval
18 changes: 11 additions & 7 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

REEK_ARGS = %w[
--line-numbers
--color
Expand All @@ -16,12 +18,14 @@ RSPEC_OPTIONS = {
cmd: "env COV=true bundle exec rspec",
# cmd_additional_args: "--format documentation",
failed_mode: :focus,
all_on_start: false
}
all_on_start: false,
}.freeze

scope group: :tdd
clearing :on
notification :terminal_notifier, app_name: "sidekiq-unique-jobs ::", activate: "com.googlecode.iTerm2" if `uname` =~ /Darwin/
if /Darwin/.match?(`uname`)
notification :terminal_notifier, app_name: "sidekiq-unique-jobs ::", activate: "com.googlecode.iTerm2"
end

group :tdd, halt_on_fail: true do
guard :rspec, RSPEC_OPTIONS do
Expand All @@ -42,16 +46,16 @@ group :tdd, halt_on_fail: true do
end

guard :rubocop, all_on_start: false, cli: RUBOCOP_ARGS do
watch(%r{.+\.rb$})
watch(/.+\.rb$/)
watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
end

guard :reek, all_on_start: false, cli: REEK_ARGS do
watch(%r{.+\.rb$})
watch('.reek')
watch(/.+\.rb$/)
watch(".reek")
end
end

guard :bundler do
watch('Gemfile')
watch("Gemfile")
end
7 changes: 6 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ RuboCop::RakeTask.new(:rubocop) do |task|
task.options = %w[-DEP --format fuubar]
end

desc "Runs style validations"
task style: [:reek, :rubocop]

RSpec::Core::RakeTask.new(:rspec) do |t|
t.rspec_opts = "--format Fuubar"
t.rspec_opts = "--format Fuubar --format Nc"
end

require "yard"
Expand Down Expand Up @@ -65,10 +66,12 @@ task default: [:style, :rspec, :yard]

namespace :appraisal do
namespace :rspec do
desc "Runs rspec for all appraisals"
task :all do
sh("bundle exec appraisal rspec")
end

desc "Runs rspec for older appraisals than sidekiq 6"
task :pre_sidekiq_6 do
sh("bundle exec appraisal sidekiq-4.0 rspec")
sh("bundle exec appraisal sidekiq-4.1 rspec")
Expand All @@ -78,6 +81,7 @@ namespace :appraisal do
sh("bundle exec appraisal sidekiq-5.2 rspec")
end

desc "Runs rspec for appraisals containing sidekiq 6 or greater"
task :post_sidekiq_6 do
sh("bundle exec appraisal sidekiq-6.0 rspec")
sh("bundle exec appraisal sidekiq-develop rspec")
Expand All @@ -87,6 +91,7 @@ namespace :appraisal do
end
end

desc "Release a new gem version"
task :release do
sh("./update_docs.sh")
sh("gem release --tag --push")
Expand Down
29 changes: 29 additions & 0 deletions bin/_guard-core
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
# The application '_guard-core' 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 /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300))
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("guard", "_guard-core")
Loading

0 comments on commit 5dbb796

Please sign in to comment.