From 47c06d54794c670b4ad8657134c44c50fe4ed704 Mon Sep 17 00:00:00 2001 From: nofaralfasi Date: Tue, 20 Feb 2024 18:28:46 +0200 Subject: [PATCH] Use reusable GitHub Actions for testing --- .github/workflows/unit_tests.yaml | 16 ++++++++++++++++ .gitignore | 3 +++ .rubocop.yml | 3 +++ Gemfile | 6 ++++++ Rakefile | 15 ++++++++++++--- hammer_cli_foreman_leapp.gemspec | 8 +++----- lib/hammer_cli_foreman_leapp/i18n.rb | 5 ++++- 7 files changed, 47 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/unit_tests.yaml diff --git a/.github/workflows/unit_tests.yaml b/.github/workflows/unit_tests.yaml new file mode 100644 index 0000000..2ac0c0c --- /dev/null +++ b/.github/workflows/unit_tests.yaml @@ -0,0 +1,16 @@ +name: CI + +on: + pull_request: + push: + branches: + - 'master' + +concurrency: + group: ${{ github.ref_name }}-${{ github.workflow }} + cancel-in-progress: true + +jobs: + rubocop: + name: Rubocop + uses: theforeman/actions/.github/workflows/rubocop.yml@v0 diff --git a/.gitignore b/.gitignore index 06ba05f..006a171 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,6 @@ pkg # Locale files locale/*/*.edit.po locale/*/*.po.time_stamp + +# RubyMine +.idea diff --git a/.rubocop.yml b/.rubocop.yml index 71db957..719ac16 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,6 @@ +require: + - rubocop-performance + Style/Documentation: Enabled: false Lint/RaiseException: diff --git a/Gemfile b/Gemfile index 1f4c45f..e7e04f1 100644 --- a/Gemfile +++ b/Gemfile @@ -5,3 +5,9 @@ source 'https://rubygems.org' gemspec gem 'gettext', '>= 3.1.3', '< 4.0.0' +gem 'rake', '~> 13.0' + +group :test do + gem 'rubocop', '~> 1.57.0' + gem 'rubocop-performance', '~> 1.5.2' +end diff --git a/Rakefile b/Rakefile index 32e73c2..d71469c 100644 --- a/Rakefile +++ b/Rakefile @@ -5,7 +5,16 @@ require 'bundler/gem_tasks' Bundler::GemHelper.install_tasks -require "hammer_cli_foreman_leapp/version" -require "hammer_cli_foreman_leapp/i18n" -require "hammer_cli/i18n/find_task" +require 'hammer_cli_foreman_leapp/version' +require 'hammer_cli_foreman_leapp/i18n' +require 'hammer_cli/i18n/find_task' HammerCLI::I18n::FindTask.define(HammerCLIForemanLeapp::I18n::LocaleDomain.new, HammerCLIForemanLeapp.version.to_s) + +begin + require 'rubocop/rake_task' +rescue LoadError + # RuboCop is optional +else + RuboCop::RakeTask.new + task default: [:rubocop] +end diff --git a/hammer_cli_foreman_leapp.gemspec b/hammer_cli_foreman_leapp.gemspec index 28b7c89..b9eadac 100644 --- a/hammer_cli_foreman_leapp.gemspec +++ b/hammer_cli_foreman_leapp.gemspec @@ -18,12 +18,10 @@ Gem::Specification.new do |spec| spec.platform = Gem::Platform::RUBY spec.summary = 'Foreman Leapp plugin for Hammer CLI' - spec.files = Dir['{lib,config}/**/*', 'LICENSE', 'README*'] + Dir["locale/**/*.{po,pot,mo}"] + spec.files = Dir['{lib,config}/**/*', 'LICENSE', 'README*'] + Dir['locale/**/*.{po,pot,mo}'] spec.require_paths = ['lib'] spec.test_files = Dir['{test}/**/*'] - spec.add_dependency 'hammer_cli_foreman', '>= 2.0.0', '< 4.0.0' - spec.add_development_dependency 'bundler' - spec.add_development_dependency 'rake' - spec.add_development_dependency 'rubocop', '~> 0.80' + spec.add_dependency 'hammer_cli_foreman', '~> 3.10' + spec.required_ruby_version = '>= 2.7', '< 4' end diff --git a/lib/hammer_cli_foreman_leapp/i18n.rb b/lib/hammer_cli_foreman_leapp/i18n.rb index baca2c5..9c80f4f 100644 --- a/lib/hammer_cli_foreman_leapp/i18n.rb +++ b/lib/hammer_cli_foreman_leapp/i18n.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'hammer_cli/i18n' module HammerCLIForemanLeapp @@ -24,5 +26,6 @@ def locale_dir end end -domain = [HammerCLIForemanLeapp::I18n::LocaleDomain.new, HammerCLIForemanLeapp::I18n::SystemLocaleDomain.new].find { |d| d.available? } +domain = [HammerCLIForemanLeapp::I18n::LocaleDomain.new, + HammerCLIForemanLeapp::I18n::SystemLocaleDomain.new].find(&:available?) HammerCLI::I18n.add_domain(domain) if domain