Skip to content

Commit

Permalink
Merge pull request #66 from choria-plugins/ci-update
Browse files Browse the repository at this point in the history
Update CI to use current Ruby
smortex authored Aug 25, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 3178e2a + 077c1a6 commit cf3ba84
Showing 22 changed files with 285 additions and 240 deletions.
15 changes: 0 additions & 15 deletions .circleci/config.yml

This file was deleted.

37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

name: Continuous Integration

on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master

jobs:
unit:
runs-on: ubuntu-latest
needs: rubocop
strategy:
matrix:
ruby:
- "2.6"
- "2.7"
- "3.0"
- "3.1"
name: Ruby ${{ matrix.ruby }}
steps:
- uses: actions/checkout@v3
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run tests
run: bundle exec rake test
22 changes: 22 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

name: Release

on:
push:
tags:
- '*'

jobs:
release:
name: Release
uses: voxpupuli/gha-puppet/.github/workflows/release.yml@v2
with:
allowed_owner: 'choria-plugins'
secrets:
# Configure secrets here:
# https://docs.github.com/en/actions/security-guides/encrypted-secrets
username: ${{ secrets.PUPPET_FORGE_USERNAME }}
api_key: ${{ secrets.PUPPET_FORGE_API_KEY }}
32 changes: 25 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
Gemfile.lock
ext/packaging
puppet/README.md
puppet/CHANGELOG.md
puppet/LICENSE
puppet/NOTICE
*.tar.gz
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

/pkg/
/Gemfile.lock
/Gemfile.local
/vendor/
/.vendor/
/spec/fixtures/manifests/
/spec/fixtures/modules/
/.vagrant/
/.bundle/
/.ruby-version
/coverage/
/log/
/.idea/
/.dependencies/
/.librarian/
/Puppetfile.lock
*.iml
.*.sw?
/.yardoc/
/Guardfile
bolt-debug.log
.rerun.json
39 changes: 39 additions & 0 deletions .pmtignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

/docs/
/pkg/
/Gemfile
/Gemfile.lock
/Gemfile.local
/vendor/
/.vendor/
/spec/
/Rakefile
/.vagrant/
/.bundle/
/.ruby-version
/coverage/
/log/
/.idea/
/.dependencies/
/.github/
/.librarian/
/Puppetfile.lock
/Puppetfile
*.iml
/.editorconfig
/.fixtures.yml
/.gitignore
/.msync.yml
/.overcommit.yml
/.pmtignore
/.rspec
/.rspec_parallel
/.rubocop.yml
/.sync.yml
.*.sw?
/.yardoc/
/.yardopts
/Dockerfile
/HISTORY.md
1 change: 0 additions & 1 deletion .rspec

This file was deleted.

1 change: 0 additions & 1 deletion .ruby-version

This file was deleted.

6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -2,9 +2,9 @@
source "https://rubygems.org"

group :test do
gem "rake", ">= 12.3.2"
gem "rspec", "~> 2.11.0"
gem "mocha", "~> 0.10.0"
gem "rake"
gem "rspec"
gem "mocha"
gem "mcollective-test"
end

24 changes: 14 additions & 10 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,36 +1,40 @@
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

specdir = File.join([File.dirname(__FILE__), "spec"])

require 'rake'
require "rake"
begin
require 'rspec/core/rake_task'
require 'mcollective'
rescue LoadError
require "rspec/core/rake_task"
require "mcollective"
rescue LoadError # rubocop:disable Lint/SuppressedException
end


desc "Run agent and application tests"
task :test do
require "#{specdir}/spec_helper.rb"
if ENV["TARGETDIR"]
test_pattern = "#{File.expand_path(ENV["TARGETDIR"])}/spec/**/*_spec.rb"
test_pattern = "#{File.expand_path(ENV['TARGETDIR'])}/spec/**/*_spec.rb"
else
test_pattern = 'spec/**/*_spec.rb'
test_pattern = "spec/**/*_spec.rb"
end
sh "bundle exec rspec #{Dir.glob(test_pattern).sort.join(' ')}"
end

task :default => :test
task :default => [:test]

desc "Expands the action details section in a README.md file"
task :readme_expand do
ddl_file = Dir.glob(File.join("agent/*.ddl")).first
ddl_file = Dir.glob("agent/*.ddl").first

return unless ddl_file

ddl = MCollective::DDL.new("package", :agent, false)
ddl.instance_eval(File.read(ddl_file))

lines = File.readlines("puppet/README.md").map do |line|
if line =~ /^<\!--- actions -->/
if line.match?(/^<!--- actions -->/)
[
"## Actions\n\n",
"This agent provides the following actions, for details about each please run `mco plugin doc agent/%s`\n\n" % ddl.meta[:name]
@@ -75,5 +79,5 @@ end

desc "Builds the module found in the current directory, run build_prep first"
task :build do
sh "/opt/puppetlabs/puppet/bin/mco plugin package --vendor choria"
sh "/opt/puppetlabs/puppet/bin/mco plugin package --format aiomodulepackage --vendor choria"
end
20 changes: 12 additions & 8 deletions spec/agent/puppet_agent_spec.rb
Original file line number Diff line number Diff line change
@@ -43,12 +43,12 @@

it "on Windows it should use puppet.bat" do
MCollective::Util.stubs(:windows?).returns(true)
expect(@agent.default_agent_command).to eq("puppet.bat agent")
@agent.default_agent_command.should eq("puppet.bat agent")
end

it "on non-Windows it should use puppet" do
MCollective::Util.stubs(:windows?).returns(false)
expect(@agent.default_agent_command).to eq("puppet agent")
@agent.default_agent_command.should eq("puppet agent")
end
end

@@ -598,9 +598,11 @@
:splay => true,
:splaylimit => 30}).returns([:run_in_foreground, ["--rspec"]])
@agent.expects(:run).with("puppet agent --rspec",
:stdout => :summary,
:stderr => :summary,
:chomp => true).returns(0)
{
:stdout => :summary,
:stderr => :summary,
:chomp => true
}).returns(0)

result = @agent.call(:runonce)
result.should be_successful
@@ -612,9 +614,11 @@
:splay => true,
:splaylimit => 30}).returns([:run_in_foreground, ["--rspec"]])
@agent.expects(:run).with("puppet agent --rspec",
:stdout => :summary,
:stderr => :summary,
:chomp => true).returns(1)
{
:stdout => :summary,
:stderr => :summary,
:chomp => true
}).returns(1)

result = @agent.call(:runonce)
result.should be_aborted_error
24 changes: 12 additions & 12 deletions spec/application/puppet_spec.rb
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ class Application
describe "#post_option_parser" do
it "should detect unsupported commands" do
ARGV << "rspec"
expect { @app.post_option_parser(@app.configuration) }.to raise_error(/Action must be/)
lambda { @app.post_option_parser(@app.configuration) }.should raise_error(/Action must be/)
end

it "should get the concurrency for runall" do
@@ -246,7 +246,7 @@ class Application

it "should support disabling with a message" do
@app.configuration[:message] = "rspec test"
@app.client.expects(:disable).with(:message => "rspec test").returns("rspec")
@app.client.expects(:disable).with({ :message => "rspec test" }).returns("rspec")
@app.disable_command
end

@@ -269,16 +269,16 @@ class Application
@app.configuration[:use_cached_catalog] = false
@app.configuration[:ignoreschedules] = true

@app.client.expects(:runonce).with(:force => true,
:server => "rspec:123",
:noop => true,
:environment => "rspec",
:splay => true,
:splaylimit => 60,
:use_cached_catalog => false,
:ignoreschedules => true,
:tags => "one,two",
:skip_tags => "three,four").returns("result")
@app.client.expects(:runonce).with({:force => true,
:server => "rspec:123",
:noop => true,
:environment => "rspec",
:splay => true,
:splaylimit => 60,
:use_cached_catalog => false,
:ignoreschedules => true,
:tags => "one,two",
:skip_tags => "three,four"}).returns("result")
@app.expects(:halt)
@app.runonce_command
end
Loading

0 comments on commit cf3ba84

Please sign in to comment.