Skip to content

Commit 9ac4beb

Browse files
authored
Improve CI (#334)
* Fix rubocop violations Fixed all violations using `rubocop -a` * Add Ruby3.4 to CI matrix * Fix issue in sidekiq_user method The following test started failing after the commit Harmonize interface with 68d734f ``` 1) Error: SidekiqCommonTest#test_sidekiq_user_with_role: KeyError: key not found: :sidekiq_user lib/capistrano/sidekiq.rb:56:in 'Hash#fetch' lib/capistrano/sidekiq.rb:56:in 'Capistrano::SidekiqCommon#sidekiq_user' test/unit_test.rb:58:in 'SidekiqCommonTest#test_sidekiq_user_with_role' ``` This occurred because the implementation did not account for the case where sidekiq_user or run_as is missing in role.properties. I judged the implementation to be incorrect and fixed the code accordingly.
1 parent 3bd14f8 commit 9ac4beb

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
ruby-version: ['3.2', '3.3']
15-
14+
ruby-version: ['3.2', '3.3', '3.4']
15+
1616
steps:
1717
- name: Checkout repository
1818
uses: actions/checkout@v4
@@ -22,10 +22,10 @@ jobs:
2222
with:
2323
ruby-version: ${{ matrix.ruby-version }}
2424
bundler-cache: true
25-
25+
2626
- name: Run RuboCop
2727
run: bundle exec rubocop
28-
28+
2929
- name: Run Tests
3030
run: bundle exec rake test
3131

lib/capistrano/sidekiq.rb

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ def compiled_template_sidekiq(from, role, config_file = 'sidekiq.yml')
99
@role = role
1010
@config_file = config_file
1111
file = [
12-
"lib/capistrano/templates/#{from}-#{role.hostname}-#{fetch(:stage)}.rb",
13-
"lib/capistrano/templates/#{from}-#{role.hostname}.rb",
14-
"lib/capistrano/templates/#{from}-#{fetch(:stage)}.rb",
15-
"lib/capistrano/templates/#{from}.rb.erb",
16-
"lib/capistrano/templates/#{from}.rb",
17-
"lib/capistrano/templates/#{from}.erb",
18-
"config/deploy/templates/#{from}.rb.erb",
19-
"config/deploy/templates/#{from}.rb",
20-
"config/deploy/templates/#{from}.erb",
21-
File.expand_path("../templates/#{from}.erb", __FILE__),
22-
File.expand_path("../templates/#{from}.rb.erb", __FILE__)
12+
"lib/capistrano/templates/#{from}-#{role.hostname}-#{fetch(:stage)}.rb",
13+
"lib/capistrano/templates/#{from}-#{role.hostname}.rb",
14+
"lib/capistrano/templates/#{from}-#{fetch(:stage)}.rb",
15+
"lib/capistrano/templates/#{from}.rb.erb",
16+
"lib/capistrano/templates/#{from}.rb",
17+
"lib/capistrano/templates/#{from}.erb",
18+
"config/deploy/templates/#{from}.rb.erb",
19+
"config/deploy/templates/#{from}.rb",
20+
"config/deploy/templates/#{from}.erb",
21+
File.expand_path("../templates/#{from}.erb", __FILE__),
22+
File.expand_path("../templates/#{from}.rb.erb", __FILE__)
2323
].detect { |path| File.file?(path) }
2424
erb = File.read(file)
2525
StringIO.new(ERB.new(erb, trim_mode: '-').result(binding))
@@ -37,12 +37,12 @@ def sidekiq_config
3737
"--config config/#{@config_file}" if @config_file != 'sidekiq.yml'
3838
end
3939

40-
def sidekiq_switch_user(role, &block)
40+
def sidekiq_switch_user(role, &)
4141
su_user = sidekiq_user(role)
4242
if su_user == role.user
4343
yield
4444
else
45-
backend.as(su_user, &block)
45+
backend.as(su_user, &)
4646
end
4747
end
4848

@@ -52,10 +52,10 @@ def sidekiq_user(role = nil)
5252
else
5353
properties = role.properties
5454
return role.user unless properties
55-
56-
properties.fetch(:sidekiq_user) || # local property for sidekiq only
55+
56+
properties.fetch(:sidekiq_user, nil) || # local property for sidekiq only
5757
fetch(:sidekiq_user, nil) ||
58-
properties.fetch(:run_as) || # global property across multiple capistrano gems
58+
properties.fetch(:run_as, nil) || # global property across multiple capistrano gems
5959
role.user
6060
end
6161
end

lib/capistrano/sidekiq/systemd.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module Capistrano
44
class Sidekiq
55
class Systemd < Capistrano::Plugin
66
include SidekiqCommon
7+
78
def define_tasks
89
eval_rakefile File.expand_path('../tasks/systemd.rake', __dir__)
910
eval_rakefile File.expand_path('../tasks/helpers.rake', __dir__)

0 commit comments

Comments
 (0)