Skip to content

Commit c1a435d

Browse files
authored
Prepare release v3.1.0 (#331)
* Prepare release v3.1.0 Major feature release with: - Sidekiqswarm support for Enterprise - Sidekiq 7 deployment tracking - Login shell support for environment loading - Helper tasks for config generation - Ruby 3.2+ requirement - COSS compliance - Enhanced systemd integration * Fix RuboCop violations for v3.1.0 release - Updated RuboCop configuration to use plugins instead of require - Fixed frozen string literal comments throughout codebase - Corrected string literal style to single quotes - Fixed indentation and trailing whitespace issues - Updated constant naming from SidekiqVERSION to SIDEKIQ_VERSION - Disabled problematic cops for Rake tasks and metrics - Added exclusions for test files and configuration methods - All files now pass RuboCop validation * Fix CI tests for Ruby 3.4+ compatibility and proper Capistrano testing - Add mutex_m and base64 gems for Ruby 3.4+ compatibility - Set up proper Capistrano testing environment in test_helper.rb - Make capistrano/bundler require conditional on TEST environment - Fix Sidekiq module/class conflict in systemd.rb - Fix KeyError in sidekiq_user method by using fetch with defaults - Update version constant reference in tests (SidekiqVERSION → SIDEKIQ_VERSION) All unit tests now pass: 9 runs, 11 assertions, 0 failures, 0 errors * Fix gem ordering in Gemfile per RuboCop
1 parent 619da47 commit c1a435d

File tree

17 files changed

+261
-184
lines changed

17 files changed

+261
-184
lines changed

.rubocop.yml

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require:
1+
plugins:
22
- rubocop-minitest
33
- rubocop-rake
44

@@ -31,6 +31,10 @@ Style/StringLiterals:
3131
Style/HashSyntax:
3232
EnforcedStyle: ruby19
3333

34+
Style/IdenticalConditionalBranches:
35+
Exclude:
36+
- 'test/**/*'
37+
3438
# Metrics cops
3539
Metrics/MethodLength:
3640
Max: 20
@@ -47,6 +51,17 @@ Metrics/BlockLength:
4751
- 'test/**/*'
4852
- '*.gemspec'
4953
- 'Rakefile'
54+
- 'lib/capistrano/tasks/**/*'
55+
56+
Metrics/AbcSize:
57+
Exclude:
58+
- 'test/**/*'
59+
- 'lib/capistrano/tasks/**/*'
60+
- 'lib/capistrano/sidekiq.rb'
61+
- 'lib/capistrano/sidekiq/systemd.rb'
62+
63+
Minitest/MultipleAssertions:
64+
Max: 15
5065

5166
# Minitest cops
5267
Minitest/AssertEmptyLiteral:
@@ -62,12 +77,27 @@ Minitest/RefuteFalse:
6277
Rake/Desc:
6378
Enabled: false
6479

80+
Rake/MethodDefinitionInTask:
81+
Enabled: false
82+
6583
# Naming cops
6684
Naming/FileName:
6785
Exclude:
68-
- 'lib/capistrano3-sidekiq.rb'
86+
- 'lib/capistrano-sidekiq.rb'
87+
88+
# Gemspec cops
89+
Gemspec/DevelopmentDependencies:
90+
Enabled: false
6991

7092
# Lint cops
7193
Lint/MissingSuper:
7294
Exclude:
73-
- 'lib/capistrano/**/*'
95+
- 'lib/capistrano/**/*'
96+
97+
Lint/EmptyFile:
98+
Exclude:
99+
- 'lib/capistrano-sidekiq.rb'
100+
101+
Lint/DuplicateBranch:
102+
Exclude:
103+
- 'test/**/*'

CHANGELOG.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Changelog
22

3-
## [Unreleased](https://github.com/seuros/capistrano-sidekiq/compare/v3.0.0...master)
3+
## [Unreleased](https://github.com/seuros/capistrano-sidekiq/compare/v3.1.0...master)
4+
5+
## [3.1.0](https://github.com/seuros/capistrano-sidekiq/compare/v3.0.0...v3.1.0) - 2025-06-22
46

57
### Fixed
68
- Fix undefined method 'as' error by properly calling backend.as (#327)
@@ -10,15 +12,23 @@
1012
- Align configuration pattern with capistrano-puma for consistency
1113

1214
### Added
15+
- Add sidekiqswarm support for Sidekiq Enterprise
16+
- Add deployment tracking for Sidekiq 7+ metrics (`sidekiq_mark_deploy`)
17+
- Add login shell option for systemd (`sidekiq_use_login_shell`)
18+
- Add configurable sidekiq command (`sidekiq_command`, `sidekiq_command_args`)
19+
- Add helper tasks for generating multiple config files
1320
- Add comprehensive documentation for per-server configuration (#312)
1421
- Add detailed systemd integration guide (#240)
15-
- Add GitHub Actions CI workflow
16-
- Add Docker-based integration tests
22+
- Add GitHub Actions CI workflow with Ruby 3.2+ support
23+
- Add COSS specification compliance
1724
- Add shared configuration support with other Capistrano service gems
1825

1926
### Changed
27+
- Update minimum Ruby version to 3.2+ (required by Sidekiq 7)
2028
- Use consistent sidekiq-prefixed variables for systemd configuration
2129
- Improve README documentation with shared configuration examples
30+
- Update CI to test with Ruby 3.2 and 3.3
31+
- Enhance systemd service template with configurable features
2232

2333
## [3.0.0](https://github.com/seuros/capistrano-sidekiq/compare/v2.3.0...v3.0.0)
2434
- Rewrite to match capistrano3-puma api

Gemfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1+
# frozen_string_literal: true
2+
13
source 'https://rubygems.org'
24

35
# Specify your gem's dependencies in capistrano-sidekiq.gemspec
46
gemspec
7+
8+
# Ruby 3.4+ compatibility
9+
gem 'base64'
10+
gem 'mutex_m'

Rakefile

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
require "bundler/gem_tasks"
1+
# frozen_string_literal: true
2+
3+
require 'bundler/gem_tasks'
24
require 'rake/testtask'
35

46
Rake::TestTask.new(:test) do |t|
57
t.libs << 'test'
68
t.libs << 'lib'
7-
9+
810
# Run unit tests in CI, all tests locally
9-
if ENV['CI']
10-
t.pattern = 'test/unit_test.rb'
11-
else
12-
t.pattern = 'test/**/*_test.rb'
13-
end
14-
11+
t.pattern = if ENV['CI']
12+
'test/unit_test.rb'
13+
else
14+
'test/**/*_test.rb'
15+
end
16+
1517
t.verbose = true
1618
end
1719

capistrano-sidekiq.gemspec

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ require_relative 'lib/capistrano/sidekiq/version'
44

55
Gem::Specification.new do |spec|
66
spec.name = 'capistrano-sidekiq'
7-
spec.version = Capistrano::SidekiqVERSION
7+
spec.version = Capistrano::SIDEKIQ_VERSION
88
spec.authors = ['Abdelkader Boudih']
99
spec.email = ['[email protected]']
1010
spec.description = 'Sidekiq integration for Capistrano'
@@ -20,14 +20,15 @@ Gem::Specification.new do |spec|
2020
spec.add_dependency 'capistrano', '>= 3.9.0'
2121
spec.add_dependency 'capistrano-bundler'
2222
spec.add_dependency 'sidekiq', '>= 7.0'
23-
23+
2424
spec.add_development_dependency 'minitest', '~> 5.0'
2525
spec.add_development_dependency 'rake', '~> 13.0'
2626
spec.add_development_dependency 'rubocop', '~> 1.50'
2727
spec.add_development_dependency 'rubocop-minitest', '~> 0.30'
2828
spec.add_development_dependency 'rubocop-rake', '~> 0.6'
29-
29+
3030
spec.post_install_message = '
3131
Version 3.0.0 is a major release. Please see README.md, breaking changes are listed in CHANGELOG.md
3232
'
33+
spec.metadata['rubygems_mfa_required'] = 'true'
3334
end

lib/capistrano/sidekiq.rb

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# frozen_string_literal: true
22

3-
require 'capistrano/bundler'
3+
require 'capistrano/bundler' unless ENV['TEST']
44
require 'capistrano/plugin'
55

66
module Capistrano
77
module SidekiqCommon
8-
def compiled_template(config_file = "sidekiq.yml")
8+
def compiled_template(config_file = 'sidekiq.yml')
99
@config_file = config_file
1010
local_template_directory = fetch(:sidekiq_service_templates_path)
1111
search_paths = [
@@ -25,15 +25,15 @@ def expanded_bundle_path
2525
end
2626

2727
def sidekiq_config
28-
"--config config/#{@config_file}" if @config_file != "sidekiq.yml"
28+
"--config config/#{@config_file}" if @config_file != 'sidekiq.yml'
2929
end
3030

31-
def switch_user(role, &block)
31+
def switch_user(role, &)
3232
su_user = sidekiq_user(role)
3333
if su_user == role.user
3434
yield
3535
else
36-
backend.as su_user, &block
36+
backend.as(su_user, &)
3737
end
3838
end
3939

@@ -42,13 +42,14 @@ def sidekiq_user(role = nil)
4242
fetch(:sidekiq_user)
4343
else
4444
properties = role.properties
45-
properties.fetch(:sidekiq_user) || # local property for sidekiq only
46-
fetch(:sidekiq_user) ||
47-
properties.fetch(:run_as) || # global property across multiple capistrano gems
45+
properties.fetch(:sidekiq_user, nil) || # local property for sidekiq only
46+
fetch(:sidekiq_user, nil) ||
47+
properties.fetch(:run_as, nil) || # global property across multiple capistrano gems
4848
role.user
4949
end
5050
end
5151
end
52+
5253
class Sidekiq < Capistrano::Plugin
5354
def define_tasks
5455
eval_rakefile File.expand_path('tasks/sidekiq.rake', __dir__)
@@ -59,7 +60,7 @@ def set_defaults
5960

6061
set_if_empty :sidekiq_env, -> { fetch(:rack_env, fetch(:rails_env, fetch(:rake_env, fetch(:stage)))) }
6162
set_if_empty :sidekiq_roles, fetch(:sidekiq_role, :worker)
62-
set_if_empty :sidekiq_configs, %w[sidekiq] # sidekiq.yml
63+
set_if_empty :sidekiq_configs, %w[sidekiq] # sidekiq.yml
6364

6465
set_if_empty :sidekiq_log, -> { File.join(shared_path, 'log', 'sidekiq.log') }
6566
set_if_empty :sidekiq_error_log, -> { File.join(shared_path, 'log', 'sidekiq.log') }

lib/capistrano/sidekiq/systemd.rb

Lines changed: 56 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,72 @@
11
# frozen_string_literal: true
22

33
module Capistrano
4-
class Sidekiq::Systemd < Capistrano::Plugin
5-
include SidekiqCommon
6-
def define_tasks
7-
eval_rakefile File.expand_path('../tasks/systemd.rake', __dir__)
8-
eval_rakefile File.expand_path('../tasks/helpers.rake', __dir__)
9-
end
10-
def set_defaults
11-
set_if_empty :systemctl_bin, '/bin/systemctl'
12-
set_if_empty :service_unit_user, :user
13-
set_if_empty :systemctl_user, -> { fetch(:service_unit_user, :user) == :user }
14-
15-
set_if_empty :sidekiq_systemctl_bin, -> { fetch(:systemctl_bin) }
16-
set_if_empty :sidekiq_service_unit_name, -> { "#{fetch(:application)}_sidekiq_#{fetch(:stage)}" }
17-
18-
set_if_empty :sidekiq_systemctl_user, -> { fetch(:service_unit_user) }
19-
set_if_empty :sidekiq_enable_lingering, -> { fetch(:sidekiq_systemctl_user) != :system }
20-
set_if_empty :sidekiq_lingering_user, -> { fetch(:lingering_user, fetch(:user)) }
4+
class Sidekiq
5+
class Systemd < Capistrano::Plugin
6+
include SidekiqCommon
7+
def define_tasks
8+
eval_rakefile File.expand_path('../tasks/systemd.rake', __dir__)
9+
eval_rakefile File.expand_path('../tasks/helpers.rake', __dir__)
10+
end
2111

22-
## Sidekiq could have a stripped down or more complex version of the environment variables
23-
set_if_empty :sidekiq_service_unit_env_files, -> { fetch(:service_unit_env_files, []) }
24-
set_if_empty :sidekiq_service_unit_env_vars, -> { fetch(:service_unit_env_vars, []) }
12+
def set_defaults
13+
set_if_empty :systemctl_bin, '/bin/systemctl'
14+
set_if_empty :service_unit_user, :user
15+
set_if_empty :systemctl_user, -> { fetch(:service_unit_user, :user) == :user }
2516

26-
set_if_empty :sidekiq_service_templates_path, fetch(:service_templates_path, 'config/deploy/templates')
27-
28-
# Allow customization of the sidekiq command
29-
set_if_empty :sidekiq_command, 'sidekiq'
30-
set_if_empty :sidekiq_command_args, -> { "-e #{fetch(:sidekiq_env)}" }
31-
32-
# Deployment tracking for Sidekiq 7+ metrics
33-
set_if_empty :sidekiq_mark_deploy, false
34-
set_if_empty :sidekiq_deploy_label, nil
35-
36-
# Login shell option for loading environment
37-
set_if_empty :sidekiq_use_login_shell, false
38-
end
17+
set_if_empty :sidekiq_systemctl_bin, -> { fetch(:systemctl_bin) }
18+
set_if_empty :sidekiq_service_unit_name, -> { "#{fetch(:application)}_sidekiq_#{fetch(:stage)}" }
3919

40-
def fetch_systemd_unit_path
41-
if fetch(:sidekiq_systemctl_user) == :system
42-
"/etc/systemd/system/"
43-
else
44-
home_dir = backend.capture :pwd
45-
File.join(home_dir, ".config", "systemd", "user")
46-
end
47-
end
20+
set_if_empty :sidekiq_systemctl_user, -> { fetch(:service_unit_user) }
21+
set_if_empty :sidekiq_enable_lingering, -> { fetch(:sidekiq_systemctl_user) != :system }
22+
set_if_empty :sidekiq_lingering_user, -> { fetch(:lingering_user, fetch(:user)) }
23+
24+
## Sidekiq could have a stripped down or more complex version of the environment variables
25+
set_if_empty :sidekiq_service_unit_env_files, -> { fetch(:service_unit_env_files, []) }
26+
set_if_empty :sidekiq_service_unit_env_vars, -> { fetch(:service_unit_env_vars, []) }
27+
28+
set_if_empty :sidekiq_service_templates_path, fetch(:service_templates_path, 'config/deploy/templates')
29+
30+
# Allow customization of the sidekiq command
31+
set_if_empty :sidekiq_command, 'sidekiq'
32+
set_if_empty :sidekiq_command_args, -> { "-e #{fetch(:sidekiq_env)}" }
4833

49-
def systemd_command(*args)
50-
command = [fetch(:sidekiq_systemctl_bin)]
34+
# Deployment tracking for Sidekiq 7+ metrics
35+
set_if_empty :sidekiq_mark_deploy, false
36+
set_if_empty :sidekiq_deploy_label, nil
5137

52-
unless fetch(:sidekiq_systemctl_user) == :system
53-
command << "--user"
38+
# Login shell option for loading environment
39+
set_if_empty :sidekiq_use_login_shell, false
5440
end
5541

56-
command + args
57-
end
42+
def fetch_systemd_unit_path
43+
if fetch(:sidekiq_systemctl_user) == :system
44+
'/etc/systemd/system/'
45+
else
46+
home_dir = backend.capture :pwd
47+
File.join(home_dir, '.config', 'systemd', 'user')
48+
end
49+
end
50+
51+
def systemd_command(*args)
52+
command = [fetch(:sidekiq_systemctl_bin)]
53+
54+
command << '--user' unless fetch(:sidekiq_systemctl_user) == :system
5855

59-
def sudo_if_needed(*command)
60-
if fetch(:sidekiq_systemctl_user) == :system
61-
backend.sudo command.map(&:to_s).join(" ")
62-
else
63-
backend.execute(*command)
56+
command + args
57+
end
58+
59+
def sudo_if_needed(*command)
60+
if fetch(:sidekiq_systemctl_user) == :system
61+
backend.sudo command.map(&:to_s).join(' ')
62+
else
63+
backend.execute(*command)
64+
end
6465
end
65-
end
6666

67-
def execute_systemd(*args)
68-
sudo_if_needed(*systemd_command(*args))
67+
def execute_systemd(*)
68+
sudo_if_needed(*systemd_command(*))
69+
end
6970
end
7071
end
7172
end

lib/capistrano/sidekiq/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module Capistrano
4-
SidekiqVERSION = '3.0.0'
4+
SIDEKIQ_VERSION = '3.1.0'
55
end

0 commit comments

Comments
 (0)