diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e247141 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,25 @@ +--- +name: CI + +on: + pull_request: + push: + branches: + - 'develop' + - '*-stable' + +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: Ruby + needs: rubocop + uses: theforeman/actions/.github/workflows/foreman_plugin.yml@v0 + with: + plugin: foreman_plugin_template diff --git a/Rakefile b/Rakefile index 8c2f287..bbdbdda 100755 --- a/Rakefile +++ b/Rakefile @@ -7,21 +7,17 @@ end begin require 'rdoc/task' rescue LoadError - require 'rdoc/rdoc' - require 'rake/rdoctask' - RDoc::Task = Rake::RDocTask + # No rdoc +else + RDoc::Task.new(:rdoc) do |rdoc| + rdoc.rdoc_dir = 'rdoc' + rdoc.title = 'ForemanPluginTemplate' + rdoc.options << '--line-numbers' + rdoc.rdoc_files.include('README.rdoc') + rdoc.rdoc_files.include('lib/**/*.rb') + end end -RDoc::Task.new(:rdoc) do |rdoc| - rdoc.rdoc_dir = 'rdoc' - rdoc.title = 'ForemanPluginTemplate' - rdoc.options << '--line-numbers' - rdoc.rdoc_files.include('README.rdoc') - rdoc.rdoc_files.include('lib/**/*.rb') -end - -APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__) - Bundler::GemHelper.install_tasks require 'rake/testtask' @@ -33,15 +29,15 @@ Rake::TestTask.new(:test) do |t| t.verbose = false end -task default: :test +task :default begin require 'rubocop/rake_task' RuboCop::RakeTask.new -rescue - puts 'Rubocop not loaded.' +rescue LoadError + # No RuboCop +else + Rake::Task[:default].enhance([:rubocop]) end -task :default do - Rake::Task['rubocop'].execute -end +Rake::Task[:default].enhance([:test]) diff --git a/lib/tasks/foreman_plugin_template_tasks.rake b/lib/tasks/foreman_plugin_template_tasks.rake index 48c73c8..83b64d5 100644 --- a/lib/tasks/foreman_plugin_template_tasks.rake +++ b/lib/tasks/foreman_plugin_template_tasks.rake @@ -23,26 +23,4 @@ namespace :test do end end -namespace :foreman_plugin_template do - task :rubocop do - begin - require 'rubocop/rake_task' - RuboCop::RakeTask.new(:rubocop_foreman_plugin_template) do |task| - task.patterns = ["#{ForemanPluginTemplate::Engine.root}/app/**/*.rb", - "#{ForemanPluginTemplate::Engine.root}/lib/**/*.rb", - "#{ForemanPluginTemplate::Engine.root}/test/**/*.rb"] - end - rescue - puts 'Rubocop not loaded.' - end - - Rake::Task['rubocop_foreman_plugin_template'].invoke - end -end - Rake::Task[:test].enhance ['test:foreman_plugin_template'] - -load 'tasks/jenkins.rake' -if Rake::Task.task_defined?(:'jenkins:unit') - Rake::Task['jenkins:unit'].enhance ['test:foreman_plugin_template', 'foreman_plugin_template:rubocop'] -end