Skip to content

Commit

Permalink
ci: Refactor Sidekiq-Pro tests conditionals
Browse files Browse the repository at this point in the history
Kudos to @mnovelo and @gstokkink for catching this and coming with
proposals on fixes.

Closes: #181
Related-To: #180
Co-authored-by: Mauricio Novelo <5916364+mnovelo@users.noreply.github.com>
Signed-off-by: Alexey Zapparov <alexey@zapparov.com>
  • Loading branch information
ixti and mnovelo committed Jan 26, 2024
1 parent b4027cc commit 085e9bb
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,7 @@ jobs:
bundler-cache: true

- name: Run test suites
run: |
if [[ -n "${BUNDLE_GEMS__CONTRIBSYS__COM}" ]]; then
cp .rspec.sidekiq-pro .rspec-local
fi
bundle exec rake test
run: bundle exec rake test

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
Expand Down
1 change: 0 additions & 1 deletion .rspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
--require simplecov
--require spec_helper
--tag ~sidekiq_pro
2 changes: 0 additions & 2 deletions .rspec.sidekiq-pro

This file was deleted.

6 changes: 3 additions & 3 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ appraise "sidekiq-7.0.x" do

# Sidekiq Pro license must be set in global bundler config
# or in BUNDLE_GEMS__CONTRIBSYS__COM env variable
install_if "-> { Bundler.settings['gems.contribsys.com']&.include?(':') || ENV['BUNDLE_GEMS__CONTRIBSYS__COM'] }" do
install_if "-> { Bundler.settings['gems.contribsys.com']&.include?(':') }" do
source "https://gems.contribsys.com/" do
gem "sidekiq-pro", "~> 7.0.0"
end
Expand All @@ -26,7 +26,7 @@ appraise "sidekiq-7.1.x" do

# Sidekiq Pro license must be set in global bundler config
# or in BUNDLE_GEMS__CONTRIBSYS__COM env variable
install_if "-> { Bundler.settings['gems.contribsys.com']&.include?(':') || ENV['BUNDLE_GEMS__CONTRIBSYS__COM'] }" do
install_if "-> { Bundler.settings['gems.contribsys.com']&.include?(':') }" do
source "https://gems.contribsys.com/" do
gem "sidekiq-pro", "~> 7.1.0"
end
Expand All @@ -40,7 +40,7 @@ appraise "sidekiq-7.2.x" do

# Sidekiq Pro license must be set in global bundler config
# or in BUNDLE_GEMS__CONTRIBSYS__COM env variable
install_if "-> { Bundler.settings['gems.contribsys.com']&.include?(':') || ENV['BUNDLE_GEMS__CONTRIBSYS__COM'] }" do
install_if "-> { Bundler.settings['gems.contribsys.com']&.include?(':') }" do
source "https://gems.contribsys.com/" do
gem "sidekiq-pro", "~> 7.2.0"
end
Expand Down
6 changes: 3 additions & 3 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,9 @@ And the following Sidekiq Pro versions:

=== Sidekiq-Pro

If you're working on Sidekiq-Pro support make sure to copy `.rspec-sidekiq-pro`
to `.rspec-local` and that you have Sidekiq-Pro license in the global config,
or in the `BUNDLE_GEMS\__CONTRIBSYS__COM` env variable.
If you're working on Sidekiq-Pro support make sure that you have Sidekiq-Pro
license set either in the global config, or in `BUNDLE_GEMS\__CONTRIBSYS__COM`
environment variable.

== Contributing

Expand Down
7 changes: 7 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
end
end

# Sidekiq-Pro related specs require license set in Bundler
unless Bundler.settings["gems.contribsys.com"]&.include?(":") && SIDEKIQ7
config.define_derived_metadata(sidekiq_pro: true) do |metadata|
metadata[:skip] = "Sidekiq::Pro license not found or not supported"
end
end

# rspec-expectations config goes here. You can use an alternate
# assertion/expectation library such as wrong or the stdlib/minitest
# assertions if you prefer.
Expand Down
13 changes: 7 additions & 6 deletions spec/support/sidekiq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
$TESTING = true # rubocop:disable Style/GlobalVars

REDIS_URL = ENV.fetch("REDIS_URL", "redis://localhost:6379")
SIDEKIQ7 = Gem::Version.new("7.0.0") <= Gem::Version.new(Sidekiq::VERSION)

module SidekiqThrottledHelper
def new_sidekiq_config
Expand All @@ -31,10 +32,10 @@ def new_sidekiq_config
end

def reset_redis!
if Gem::Version.new(Sidekiq::VERSION) < Gem::Version.new("7.0.0")
reset_redis_v6!
else
if SIDEKIQ7
reset_redis_v7!
else
reset_redis_v6!
end
end

Expand Down Expand Up @@ -105,12 +106,12 @@ def output
end
end

if Gem::Version.new(Sidekiq::VERSION) < Gem::Version.new("7.0.0")
Sidekiq[:queues] = %i[default]
else
if SIDEKIQ7
Sidekiq.configure_server do |config|
config.queues = %i[default]
end
else
Sidekiq[:queues] = %i[default]
end

Sidekiq.configure_server do |config|
Expand Down

0 comments on commit 085e9bb

Please sign in to comment.