Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run tests on Ruby 3 and remove LC_MESSAGES #900

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ on:

jobs:
test:

runs-on: ubuntu-latest
strategy:
matrix:
ruby: ["2.7"]

ruby: ["2.7", "3.0", "3.1"]
steps:
- uses: actions/checkout@v2
- name: Add hammer-cli-foreman to local gem file
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ doc/
# Locale files
locale/*/*.edit.po
locale/*/*.po.time_stamp
locale/*/LC_MESSAGES/*.mo
47 changes: 37 additions & 10 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,40 @@
inherit_from: .rubocop_todo.yml

AllCops:
TargetRubyVersion: 2.3
TargetRubyVersion: 2.7

Metrics/BlockLength:
Enabled: false

Lint/ConstantDefinitionInBlock:
Enabled: false

Metrics/ModuleLength:
Enabled: false

Style/FormatStringToken:
Enabled: false

Style/GuardClause:
Enabled: false

Naming/MethodParameterName:
Enabled: false

Style/CommentedKeyword:
Enabled: false

Style/CaseLikeIf:
Enabled: false

Style/StringConcatenation:
Enabled: false

Style/OptionalBooleanParameter:
Enabled: false

Lint/MissingSuper:
Enabled: false

MethodLength:
Description: 'Avoid methods longer than 30 lines of code.'
Expand All @@ -24,7 +57,7 @@ Encoding:
Enabled: false

LineLength:
Max: 100
Max: 120

FormatString:
Enabled: false # we use % for i18n
Expand All @@ -47,10 +80,7 @@ RescueModifier:
AssignmentInCondition:
Enabled: false

AlignParameters:
Enabled: false # don't care if parameters are not aligned

AlignParameters:
ParameterAlignment:
Enabled: false # don't care if parameters are not aligned

WhileUntilModifier:
Expand All @@ -74,13 +104,10 @@ RedundantReturn:
SingleLineBlockParams:
Enabled: false

FormatString:
Enabled: false # we use % for i18n

Style/Alias:
Enabled: false

Style/IndentArray:
Layout/FirstArrayElementIndentation:
EnforcedStyle: consistent

Style/MultilineMethodCallBraceLayout:
Expand Down
10 changes: 5 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ gemspec
gem 'gettext', '>= 3.1.3', '< 4.0.0'

group :test do
gem 'rake', '~> 10.1.0'
gem 'thor'
gem 'ci_reporter', '>= 1.6.3', "< 2.0.0", :require => false
gem 'coveralls', '0.8.23', require: false
gem 'minitest', '4.7.4'
gem 'minitest-spec-context'
gem 'mocha'
gem 'coveralls', '0.8.23', require: false
gem 'ci_reporter', '>= 1.6.3', "< 2.0.0", :require => false
gem 'rubocop', '0.42'
gem 'rake', '~> 10.1.0'
gem 'rubocop', '~> 1.28.0'
gem 'rubocop-checkstyle_formatter'
gem 'thor'
end

# load local gemfile
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ begin
--format Rubocop::Formatter::CheckstyleFormatter \
--no-color --out rubocop.xml")
end
rescue => _
rescue StandardError => _e
puts "Rubocop not loaded."
end

Expand Down
23 changes: 12 additions & 11 deletions hammer_cli_katello.gemspec
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
# -*- encoding: utf-8 -*-
$LOAD_PATH.unshift(File.expand_path('../lib', __FILE__))

$LOAD_PATH.unshift(File.expand_path('lib', __dir__))

require 'hammer_cli_katello/version'

# rubocop:disable Layout/LineLength
begin
Dir["locale/**/*.po"].each do |po|
mo = po.sub(/hammer-cli-katello\.po$/, "LC_MESSAGES/hammer-cli-katello.mo")
STDERR.puts "WARNING: File #{mo} does not exist, generate with 'make all-mo'!" unless File.exist?(mo)
STDERR.puts "WARNING: File #{mo} outdated, regenerate with 'make all-mo'" if File.mtime(po) > File.mtime(mo)
warn "WARNING: File #{mo} does not exist, generate with 'make all-mo'!" unless File.exist?(mo)
warn "WARNING: File #{mo} outdated, regenerate with 'make all-mo'" if File.mtime(po) > File.mtime(mo)
# Adding this so you can actually build the gem and the warnings come out, without this
# we get an error when making the gem and it fails as well as a ruby error if the mo files don't exist
end
rescue => e
rescue StandardError => e
puts "#{e} not found"
end
# rubocop:enable Layout/LineLength

Gem::Specification.new do |gem|
gem.authors = [
Expand Down Expand Up @@ -64,17 +63,19 @@ Gem::Specification.new do |gem|
gem.require_paths = ['lib']
gem.version = HammerCLIKatello.version

gem.required_ruby_version = '>= 2.7', '< 4'

gem.add_dependency 'hammer_cli_foreman'
gem.add_dependency 'hammer_cli_foreman_tasks'

gem.add_development_dependency 'rake'
gem.add_development_dependency 'thor'
gem.add_development_dependency 'ci_reporter'
gem.add_development_dependency 'minitest', '4.7.4'
gem.add_development_dependency 'minitest-spec-context'
gem.add_development_dependency 'simplecov'
gem.add_development_dependency 'mocha'
gem.add_development_dependency 'ci_reporter'
gem.add_development_dependency 'rake'
gem.add_development_dependency 'simplecov'
gem.add_development_dependency 'thor'

gem.add_development_dependency "rubocop", "0.42"
gem.add_development_dependency "rubocop", "~> 1.28.0"
gem.add_development_dependency "rubocop-checkstyle_formatter"
end
52 changes: 25 additions & 27 deletions lib/hammer_cli_katello.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
require 'hammer_cli_foreman/output/fields'
require 'hammer_cli_foreman_tasks'

# rubocop:disable Metrics/ModuleLength
module HammerCLIKatello
def self.exception_handler_class
HammerCLIKatello::ExceptionHandler
Expand Down Expand Up @@ -36,17 +35,17 @@ def self.exception_handler_class
HammerCLI::MainCommand.lazy_subcommand("activation-key", _("Manipulate activation keys"),
'HammerCLIKatello::ActivationKeyCommand',
'hammer_cli_katello/activation_key'
)
)

HammerCLI::MainCommand.lazy_subcommand!("organization", _("Manipulate organizations"),
'HammerCLIKatello::Organization',
'hammer_cli_katello/organization'
)
)

HammerCLI::MainCommand.lazy_subcommand!("alternate-content-source", _("Manipulate alternate content sources"), # rubocop:disable LineLength
'HammerCLIKatello::AcsCommand',
'hammer_cli_katello/acs'
)
HammerCLI::MainCommand.lazy_subcommand!("alternate-content-source", _("Manipulate alternate content sources"),
'HammerCLIKatello::AcsCommand',
'hammer_cli_katello/acs'
)

HammerCLI::MainCommand.lazy_subcommand("content-credentials",
_("Manipulate content credentials on the server"),
Expand All @@ -63,12 +62,12 @@ def self.exception_handler_class
HammerCLI::MainCommand.lazy_subcommand("product", _("Manipulate products"),
'HammerCLIKatello::Product',
'hammer_cli_katello/product'
)
)

HammerCLI::MainCommand.lazy_subcommand("repository", _("Manipulate repositories"),
'HammerCLIKatello::Repository',
'hammer_cli_katello/repository'
)
)

HammerCLI::MainCommand.lazy_subcommand("repository-set",
_("Manipulate repository sets on the server"),
Expand All @@ -79,61 +78,61 @@ def self.exception_handler_class
HammerCLI::MainCommand.lazy_subcommand("subscription", _("Manipulate subscriptions"),
'HammerCLIKatello::SubscriptionCommand',
'hammer_cli_katello/subscription'
)
)

HammerCLI::MainCommand.lazy_subcommand('sync-plan', _("Manipulate sync plans"),
'HammerCLIKatello::SyncPlan',
'hammer_cli_katello/sync_plan'
)
)

HammerCLI::MainCommand.lazy_subcommand('host-collection', _("Manipulate host collections"),
'HammerCLIKatello::HostCollection',
'hammer_cli_katello/host_collection'
)
)

HammerCLI::MainCommand.lazy_subcommand("content-view", _("Manipulate content views"),
'HammerCLIKatello::ContentView',
'hammer_cli_katello/content_view'
)
)

# Capsule is just an alias to smart proxy
HammerCLI::MainCommand.lazy_subcommand("capsule", _("Manipulate capsule"),
'HammerCLIForeman::SmartProxy',
'hammer_cli_foreman/smart_proxy'
)
)

HammerCLI::MainCommand.lazy_subcommand("package", _("Manipulate packages"),
'HammerCLIKatello::PackageCommand',
'hammer_cli_katello/package'
)
)

HammerCLI::MainCommand.lazy_subcommand("deb-package", _("Manipulate deb packages"),
'HammerCLIKatello::DebPackageCommand',
'hammer_cli_katello/deb_package'
)
)

HammerCLI::MainCommand.lazy_subcommand("package-group", _("Manipulate package groups"),
'HammerCLIKatello::PackageGroupCommand',
'hammer_cli_katello/package_group'
)
)

HammerCLI::MainCommand.lazy_subcommand("erratum", _("Manipulate errata"),
'HammerCLIKatello::ErratumCommand',
'hammer_cli_katello/erratum'
)
)

HammerCLI::MainCommand.lazy_subcommand("file", _("Manipulate files"),
'HammerCLIKatello::FileCommand',
'hammer_cli_katello/file'
)
)

HammerCLI::MainCommand.lazy_subcommand("content-units", _("Manipulate content units"),
'HammerCLIKatello::ContentUnitsCommand',
'hammer_cli_katello/content_units'
)
)

HammerCLI::MainCommand.lazy_subcommand("content-export",
_("Prepare content for export to a disconnected Katello"),
_("Prepare content for export to a disconnected Katello"),
'HammerCLIKatello::ContentExport',
'hammer_cli_katello/content_export'
)
Expand All @@ -147,12 +146,12 @@ def self.exception_handler_class
HammerCLI::MainCommand.lazy_subcommand("module-stream", _("View Module Streams"),
'HammerCLIKatello::ModuleStreamCommand',
'hammer_cli_katello/module_stream'
)
)

HammerCLI::MainCommand.lazy_subcommand("srpm", _("Manipulate source RPMs"),
'HammerCLIKatello::SrpmCommand',
'hammer_cli_katello/srpm'
)
'HammerCLIKatello::SrpmCommand',
'hammer_cli_katello/srpm'
)

HammerCLI::MainCommand.lazy_subcommand("simple-content-access",
_("Simple content access commands"),
Expand All @@ -163,12 +162,11 @@ def self.exception_handler_class
HammerCLI::MainCommand.lazy_subcommand("docker", _("Manipulate docker content"),
'HammerCLIKatello::DockerCommand',
'hammer_cli_katello/docker'
)
)

# subcommands to hammer_cli_foreman commands
require 'hammer_cli_katello/host'
require 'hammer_cli_katello/hostgroup'
require 'hammer_cli_katello/ping'
require 'hammer_cli_katello/status'
end
# rubocop:enable Metrics/ModuleLength
4 changes: 2 additions & 2 deletions lib/hammer_cli_katello/acs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class RefreshCommand < HammerCLIKatello::SingleResourceCommand
autoload_subcommands

self.subcommand "bulk",
HammerCLIKatello::AcsBulkActionsCommand.desc,
HammerCLIKatello::AcsBulkActionsCommand
HammerCLIKatello::AcsBulkActionsCommand.desc,
HammerCLIKatello::AcsBulkActionsCommand
end
end
6 changes: 3 additions & 3 deletions lib/hammer_cli_katello/activation_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,14 @@ class SubscriptionsCommand < HammerCLIKatello::ListCommand

def extend_data(data)
data["format_consumed"] = _("#{data['consumed']} out of "\
"#{data['quantity'] == -1 ? 'Unlimited' : data['quantity']}")
"#{data['quantity'] == -1 ? 'Unlimited' : data['quantity']}")
data
end

option '--id', "ACTIVATION_KEY_ID", _("ID of the activation key"),
attribute_name: :option_activation_key_id
attribute_name: :option_activation_key_id
option '--name', "ACTIVATION_KEY_NAME", _("Activation key name to search by"),
attribute_name: :option_activation_key_name
attribute_name: :option_activation_key_name

validate_options :before, 'IdResolution' do
any(:option_activation_key_id, :option_activation_key_name).required
Expand Down
30 changes: 14 additions & 16 deletions lib/hammer_cli_katello/command_extensions/content_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,22 @@ class ContentSource < HammerCLI::CommandExtensions
end

request_params do |params, cmd_obj|
begin
resource_name = cmd_obj.resource.singular_name
if cmd_obj.option_content_source && !cmd_obj.option_content_source_id
resource_hash = if resource_name == 'hostgroup'
params[resource_name]
else
params[resource_name]['content_facet_attributes']
end
resource_name = cmd_obj.resource.singular_name
if cmd_obj.option_content_source && !cmd_obj.option_content_source_id
resource_hash = if resource_name == 'hostgroup'
params[resource_name]
else
params[resource_name]['content_facet_attributes']
end

proxy_options = {
HammerCLI.option_accessor_name('name') => cmd_obj.option_content_source
}
resource_hash['content_source_id'] = cmd_obj.resolver.smart_proxy_id(proxy_options)
end
rescue HammerCLIForeman::ResolverError => e
e.message.gsub!('smart_proxy', _('Content Source'))
raise e
proxy_options = {
HammerCLI.option_accessor_name('name') => cmd_obj.option_content_source
}
resource_hash['content_source_id'] = cmd_obj.resolver.smart_proxy_id(proxy_options)
end
rescue HammerCLIForeman::ResolverError => e
e.message.gsub!('smart_proxy', _('Content Source'))
raise e
end
end
end
Expand Down
Loading
Loading