Skip to content

Commit

Permalink
Add GHA CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
archanaserver committed Aug 2, 2024
1 parent d9ca190 commit 7566c64
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 15 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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
with:
command: bundle exec rubocop --parallel --format github

test:
name: Ruby
needs: rubocop
uses: theforeman/actions/.github/workflows/foreman_plugin.yml@v0
with:
plugin: foreman_plugin_template
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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
with:
command: bundle exec rubocop --parallel --format github

test:
name: Ruby
needs: rubocop
uses: theforeman/actions/.github/workflows/foreman_plugin.yml@v0
with:
plugin: foreman_plugin_template
5 changes: 0 additions & 5 deletions lib/tasks/foreman_plugin_template_tasks.rake
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,3 @@ namespace :foreman_plugin_template do
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
20 changes: 10 additions & 10 deletions rename.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,15 @@ def usage

old_dirs = []
Find.find('.') do |path|
next unless File.file?(path)
next if path =~ /\.git/
next if path == './rename.rb'

# Change content on all files
tmp_file = "#{path}.tmp"
system(%(sed 's/foreman_plugin_template/#{snake}/g' #{path} > #{tmp_file}))
system(%(sed 's/ForemanPluginTemplate/#{camel}/g' #{tmp_file} > #{path}))
system(%(sed 's/foremanPluginTemplate/#{camel_lower}/g' #{tmp_file} > #{path}))
system(%(rm #{tmp_file}))
if File.basename(path) == '.git'
Find.prune
elsif File.file?(path)
tmp_file = "#{path}.tmp"
system(%(sed 's/foreman_plugin_template/#{snake}/g' #{path} > #{tmp_file}))
system(%(sed 's/ForemanPluginTemplate/#{camel}/g' #{tmp_file} > #{path}))
system(%(sed 's/foremanPluginTemplate/#{camel_lower}/g' #{tmp_file} > #{path}))
system(%(rm #{tmp_file}))
end
end

Find.find('.') do |path|
Expand All @@ -63,6 +62,7 @@ def usage
FileUtils.rm_rf(old_dirs)

FileUtils.mv('README.plugin.md', 'README.md')
FileUtils.mv('.github/workflows/ci.yml.tpl', '.github/workflows/ci.yml')

puts 'All done!'
puts "Add this to Foreman's bundler configuration:"
Expand Down

0 comments on commit 7566c64

Please sign in to comment.