Skip to content

Commit

Permalink
Copy working setup from master (#420)
Browse files Browse the repository at this point in the history
*  Copy working setup from master

* Remove unused configuration (rspec-retry)

* Fix broken specs

* Make specs more reliable

* Fix sidekiq develop (#426)

* Mandatory rubocop commit

* Allow failures on sidekiq.develop

# Conflicts:
#	lib/sidekiq_unique_jobs/version_check.rb
#	spec/sidekiq_unique_jobs/key_spec.rb

* Mandatory rubocop commit

* Fix tests

* Update ruby versions

Takes care of some security breaches

* Prevent JRuby from using Pry

* Use pry for jruby

* Use fake irb too for the sake of jfuckingruby

* Make testing of console_class.start work

* Mandatory rubocop commit

* Another mandatory rubocop commit

* Include .simplecov with rubocop

* Cleanup after experiments

* Unfortunately truffleruby is sooooo slooooow

* Update rubocop 💣

* Fix compatibility with Sidekiq 6.0. logger

* Fix .yardopts

* Improve performance by avoiding the block arg
  • Loading branch information
mhenrixon authored Oct 3, 2019
1 parent f6c9b24 commit 7fac46b
Show file tree
Hide file tree
Showing 43 changed files with 509 additions and 278 deletions.
43 changes: 39 additions & 4 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
---
version: '2'
version: "2" # required to adjust maintainability checks
checks:
argument-count:
config:
threshold: 5
complex-logic:
config:
threshold: 4
file-lines:
config:
threshold: 300
method-complexity:
config:
threshold: 5
method-count:
config:
threshold: 20
method-lines:
config:
threshold: 25
nested-control-flow:
config:
threshold: 4
return-statements:
config:
threshold: 4
similar-code:
config:
threshold: # language-specific defaults. an override will affect all languages.
identical-code:
config:
threshold: # language-specific defaults. an override will affect all languages.

plugins:
duplication:
enabled: true
Expand All @@ -18,7 +50,7 @@ plugins:
file: .reek.yml
rubocop:
enabled: true
channel: rubocop-0-63
channel: rubocop-0-74
config:
file: .rubocop.yml

Expand All @@ -27,6 +59,9 @@ exclude_patterns:
- "*.gemspec"
- "Appraisals"
- "gemfiles/"
- "rails_example/"
- "redis/"
- "my_app/"
- "tmp/"
- "spec/"
- "assets/"
- "spec/support/sidekiq/logging.rb"
- "spec/support/sidekiq_unique_jobs/testing.rb"
20 changes: 14 additions & 6 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ AllCops:
- "bin/**/*.rb"
- "spec/**/*.rb"
- "examples/**/*.rb"
- ".simplecov"
Exclude:
- "Gemfile.lock"
- "**/*.erb"
- "gemfiles/**/*"
- "bin/bench"

Layout/EndAlignment:
EnforcedStyleAlignWith: variable

Lint/AmbiguousBlockAssociation:
Exclude:
Expand Down Expand Up @@ -87,14 +92,17 @@ RSpec/ExpectActual:
Enabled: false

RSpec/ExpectChange:
Exclude:
- spec/integration/sidekiq_unique_jobs/lock/**/*_spec.rb
EnforcedStyle: block

RSpec/FilePath:
Enabled: true
RSpec/MessageSpies:
Exclude:
- spec/unit/sidekiq_unique_jobs/scripts_spec.rb
- spec/performance/locksmith_spec.rb

RSpec/InstanceVariable:
Exclude:
- spec/sidekiq_unique_jobs/middleware/client/call_spec.rb
- spec/sidekiq_unique_jobs/middleware/server/call_spec.rb

RSpec/MultipleExpectations:
Enabled: false
Expand All @@ -105,13 +113,13 @@ RSpec/NestedGroups:

RSpec/RepeatedExample:
Exclude:
- spec/unit/sidekiq_unique_jobs/unique_args_spec.rb
- spec/sidekiq_unique_jobs/unique_args_spec.rb

Style/Documentation:
Enabled: true
Exclude:
- "examples/**/*.rb"
- "rails_example/**/*.rb"
- "my_app/**/*.rb"
- "bin/**/*.rb"
- "lib/sidekiq_unique_jobs/testing.rb"
- "lib/sidekiq_unique_jobs/core_ext.rb"
Expand Down
24 changes: 14 additions & 10 deletions .simplecov
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
require 'simplecov-json'
# frozen_string_literal: true

SimpleCov.command_name 'RSpec'
require "simplecov-json"

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

SimpleCov.start do
add_filter '/spec/'
add_filter '/bin/'
add_filter '/gemfiles/'
add_filter '/examples/'
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 'Client', 'lib/sidekiq_unique_jobs/client'
add_group 'Locks', 'lib/sidekiq_unique_jobs/lock'
add_group 'Server', 'lib/sidekiq_unique_jobs/server'
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
29 changes: 15 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,39 @@ services:
- redis-server

before_install:
- gem install bundler -v 2.0.1
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- gem install bundler -v 2.0.2
- if [[ "${COV}" = "true" ]]; then curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter; fi;
- if [[ "${COV}" = "true" ]]; then chmod +x ./cc-test-reporter; fi;

before_script:
- if [[ "${COV}" = "true" ]]; then ./cc-test-reporter before-build; fi;

script:
- if [[ "${COV}" = "true" ]]; then bundle exec rubocop -P; fi;
- bundle exec rspec --require spec_helper
- if [[ "${COV}" = "true" ]]; then bundle exec reek .; fi;
- bundle exec rspec --require spec_helper --tag ~perf

after_script:
- if [[ "${COV}" = "true" ]]; then ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT; fi;
rvm:
- 2.6.2
- 2.4.5
- 2.3.8
- jruby-9.2.7.0
- 2.6.5
- 2.4.8
- jruby-9.2.8.0

matrix:
fast_finish: true
allow_failures:
- gemfile: gemfiles/sidekiq_develop.gemfile
include:
- rvm: 2.5.5
gemfile: gemfiles/sidekiq_develop.gemfile
env: COV=true
- rvm: 2.6.2
- rvm: 2.5.7
gemfile: gemfiles/sidekiq_6.0.gemfile
- rvm: 2.5.5
- rvm: 2.6.5
gemfile: gemfiles/sidekiq_develop.gemfile
- rvm: 2.6.5
gemfile: gemfiles/sidekiq_6.0.gemfile
env: COV=true

gemfile:
- gemfiles/sidekiq_develop.gemfile
- gemfiles/sidekiq_4.0.gemfile
- gemfiles/sidekiq_4.1.gemfile
- gemfiles/sidekiq_4.2.gemfile
Expand Down
9 changes: 8 additions & 1 deletion .yardopts
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
--no-private --markup-provider=redcarpet --markup=markdown lib/**/*.rb - README.md
--no-private
--markup-provider=redcarpet
--markup=markdown
--exclude lib/sidekiq_unique_jobs/testing.rb
--exclude lib/sidekiq_unique_jobs/web/helpers.rb
--readme README.md
--files CHANGELOG.md,LICENSE.txt
lib/sidekiq_unique_jobs/**/*.rb
2 changes: 1 addition & 1 deletion Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ appraise 'sidekiq-5.2' do
end

appraise 'sidekiq-6.0' do
gem 'sidekiq', git: 'https://github.com/mperham/sidekiq.git', branch: '6-0'
gem 'sidekiq', ">= 6.0.pre", "< 6.1"
end
22 changes: 18 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,41 @@
source "https://rubygems.org"
gemspec

gem "appraisal", "~> 2.2.0"
LOCAL_GEMS = "Gemfile.local"

gem "appraisal", ">= 2.2"
gem "rspec-eventually", require: false
gem "rspec-its", require: false
gem "rspec-retry", require: false
gem "sidekiq", git: "https://github.com/mperham/sidekiq.git", branch: "6-0"

platforms :mri_25 do
platforms :jruby do
gem "pry-debugger-jruby"
end

platforms :mri do
gem "benchmark-ips"
gem "fasterer"
gem "fuubar"
gem "guard"
gem "guard-bundler"
gem "guard-reek"
gem "guard-rspec"
gem "guard-rubocop"
gem "hiredis"
gem "memory_profiler"
gem "pry"
gem "redcarpet", "~> 3.4"
gem "reek", ">= 5.3"
gem "rspec-benchmark"
gem "rubocop"
gem "rubocop-performance"
gem "rubocop-rspec"
gem "ruby-prof"
gem "simplecov-json"
gem "stackprof"
gem "terminal-notifier-guard"
gem "test-prof"
gem "toxiproxy"
gem "travis"
end

eval(File.read(LOCAL_GEMS)) if File.exist?(LOCAL_GEMS) # rubocop:disable Security/Eval
75 changes: 53 additions & 22 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,57 @@
guard :rspec, cmd: "env COV=false bundle exec rspec" do
require "guard/rspec/dsl"
dsl = Guard::RSpec::Dsl.new(self)

# RSpec files
rspec = dsl.rspec
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/unit/#{m[1]}_spec.rb" }
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/integration/#{m[1]}_spec.rb" }
watch(%r{^examples/(.+)\.rb$}) { |m| "spec/examples/#{m[1]}_spec.rb" }
watch(rspec.spec_helper) { rspec.spec_dir }
watch(rspec.spec_support) { rspec.spec_dir }
watch(rspec.spec_files)

ruby = dsl.ruby
dsl.watch_spec_files_for(ruby.lib_files)
end
REEK_ARGS = %w[
--line-numbers
--color
--documentation
--progress
--single-line
--sort-by smelliness
].freeze

RUBOCOP_ARGS = %w[
-P
--format fuubar
].freeze

RSPEC_OPTIONS = {
cmd: "env COV=true bundle exec rspec",
# cmd_additional_args: "--format documentation",
failed_mode: :focus,
all_on_start: false
}

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

group :tdd, halt_on_fail: true do
guard :rspec, RSPEC_OPTIONS do
require "guard/rspec/dsl"
dsl = Guard::RSpec::Dsl.new(self)

# RSpec files
rspec = dsl.rspec
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/unit/#{m[1]}_spec.rb" }
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/integration/#{m[1]}_spec.rb" }
watch(%r{^spec/support/workers/(.+)\.rb$}) { |m| "spec/workers/#{m[1]}_spec.rb" }
watch(rspec.spec_helper) { rspec.spec_dir }
watch(rspec.spec_support) { rspec.spec_dir }
watch(rspec.spec_files)

ruby = dsl.ruby
dsl.watch_spec_files_for(ruby.lib_files)
end

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

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

guard 'reek' do
watch(%r{.+\.rb$})
watch('.reek')
guard :bundler do
watch('Gemfile')
end
15 changes: 11 additions & 4 deletions gemfiles/sidekiq_4.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,35 @@

source "https://rubygems.org"

gem "appraisal", "~> 2.2.0"
gem "appraisal", ">= 2.2"
gem "rspec-eventually", require: false
gem "rspec-its", require: false
gem "rspec-retry", require: false
gem "sidekiq", "~> 4.0.0"

platforms :mri_25 do
platforms :mri do
gem "benchmark-ips"
gem "fasterer"
gem "fuubar"
gem "guard"
gem "guard-bundler"
gem "guard-reek"
gem "guard-rspec"
gem "guard-rubocop"
gem "hiredis"
gem "memory_profiler"
gem "pry"
gem "reek", ">= 5.3"
gem "redcarpet", "~> 3.4"
gem "reek", ">= 5.3"
gem "rspec-benchmark"
gem "rubocop"
gem "rubocop-performance"
gem "rubocop-rspec"
gem "ruby-prof"
gem "simplecov-json"
gem "stackprof"
gem "terminal-notifier-guard"
gem "test-prof"
gem "toxiproxy"
gem "travis"
end

Expand Down
Loading

0 comments on commit 7fac46b

Please sign in to comment.