Skip to content

Commit

Permalink
Use reusable GitHub Actions for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
nofaralfasi committed Feb 20, 2024
1 parent 498e631 commit 8fb4499
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 4 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/unit_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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

test:
name: Tests
uses: theforeman/actions/.github/workflows/test-gem.yml@v0
with:
command: bundle exec rake test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ pkg
# Locale files
locale/*/*.edit.po
locale/*/*.po.time_stamp

# RubyMine
.idea
8 changes: 8 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
inherit_from: .rubocop_todo.yml

require:
- rubocop-performance

AllCops:
TargetRubyVersion: 2.7

Style/Documentation:
Enabled: false
Lint/RaiseException:
Expand Down
56 changes: 56 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-02-20 16:18:38 UTC using RuboCop version 1.57.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include.
# Include: **/*.gemfile, **/Gemfile, **/gems.rb
Bundler/OrderedGems:
Exclude:
- 'Gemfile'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: final_newline, final_blank_line
Layout/TrailingEmptyLines:
Exclude:
- 'Gemfile'
- 'Rakefile'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, always_true, never
Style/FrozenStringLiteralComment:
Exclude:
- 'lib/hammer_cli_foreman_leapp/i18n.rb'

# Offense count: 5
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiterals:
Exclude:
- 'Rakefile'
- 'hammer_cli_foreman_leapp.gemspec'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowMethodsWithArguments, AllowedMethods, AllowedPatterns, AllowComments.
# AllowedMethods: define_method
Style/SymbolProc:
Exclude:
- 'lib/hammer_cli_foreman_leapp/i18n.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 135
7 changes: 7 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ source 'https://rubygems.org'
gemspec

gem 'gettext', '>= 3.1.3', '< 4.0.0'
gem 'rake', '~> 13.0'
gem 'hammer_cli_foreman', github: 'theforeman/hammer-cli-foreman', branch: 'master'

group :test do
gem 'rubocop', '~> 1.57.0'
gem 'rubocop-performance', '~> 1.5.2'
end
17 changes: 17 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,24 @@ require 'bundler/gem_tasks'

Bundler::GemHelper.install_tasks

Rake::TestTask.new do |t|
t.libs.push "lib"
t.verbose = true
end

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)

default_tasks = [:test]

begin
require 'rubocop/rake_task'
RuboCop::RakeTask.new
default_tasks.prepend(:rubocop)
rescue StandardError
puts 'Rubocop not loaded.'
end

task default: default_tasks
7 changes: 3 additions & 4 deletions hammer_cli_foreman_leapp.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ Gem::Specification.new do |spec|
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.9'
spec.add_development_dependency 'bundler', '>= 2.4', '< 3'
spec.required_ruby_version = '>= 2.7', '< 4'
end

0 comments on commit 8fb4499

Please sign in to comment.