From b3143d6776f633934db28969d3cc4096a2f49fba Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Tue, 27 Feb 2024 13:58:33 +0100 Subject: [PATCH 1/4] Drop APP_RAKEFILE This is only possible if there was a dummy application, but we don't include that. --- Rakefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Rakefile b/Rakefile index 8c2f287..00fb675 100755 --- a/Rakefile +++ b/Rakefile @@ -20,8 +20,6 @@ RDoc::Task.new(:rdoc) do |rdoc| rdoc.rdoc_files.include('lib/**/*.rb') end -APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__) - Bundler::GemHelper.install_tasks require 'rake/testtask' From 4e57ea76ef83a3e55c9144d1843546609ad6c061 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Tue, 27 Feb 2024 14:03:05 +0100 Subject: [PATCH 2/4] Make rdoc rake task optional This also gets rid of the rake/rdoctask fallback since that was dropped with Ruby 2.0. --- Rakefile | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/Rakefile b/Rakefile index 00fb675..a5083c9 100755 --- a/Rakefile +++ b/Rakefile @@ -7,17 +7,15 @@ end begin require 'rdoc/task' rescue LoadError - require 'rdoc/rdoc' - require 'rake/rdoctask' - RDoc::Task = Rake::RDocTask -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') + # 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 Bundler::GemHelper.install_tasks From 952f9422336a2f67e6a3935d24c38c79b08008fd Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Tue, 27 Feb 2024 14:05:53 +0100 Subject: [PATCH 3/4] Load run RuboCop (if available) before tests in default task --- Rakefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Rakefile b/Rakefile index a5083c9..bbdbdda 100755 --- a/Rakefile +++ b/Rakefile @@ -29,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]) From 51d96445d4089f3ac3349227edbcf1cf2038e4e4 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Tue, 27 Feb 2024 14:05:13 +0100 Subject: [PATCH 4/4] Convert CI to GitHub Actions using reusable workflows --- .github/workflows/ci.yml | 25 ++++++++++++++++++++ lib/tasks/foreman_plugin_template_tasks.rake | 22 ----------------- 2 files changed, 25 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/ci.yml 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/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