Skip to content

Commit

Permalink
Merge pull request #12 from choria-plugins/ci-update
Browse files Browse the repository at this point in the history
Update CI to use current Ruby
  • Loading branch information
smortex authored Aug 25, 2024
2 parents 1281b6a + f929e22 commit 0b0975e
Show file tree
Hide file tree
Showing 14 changed files with 172 additions and 55 deletions.
15 changes: 0 additions & 15 deletions .circleci/config.yml

This file was deleted.

48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
# 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:
rubocop:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0
bundler-cache: true
- name: Run static code analysis
run: bundle exec rubocop
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 }}
33 changes: 25 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
Gemfile.lock
ext/packaging
puppet/README.md
puppet/CHANGELOG.md
puppet/LICENSE
puppet/NOTICE
*.tar.gz
.ruby-version
# 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
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ We do not have strong guidelines on what you put in an issue, we'll gladly work

# PRs

Almost every PR will need an issue first. You do not need issues for trivial updates like typos, most documentation updates etc. But if you're doing a PR that adjusts behaviour we will need a issue to go with it.
Almost every PR will need an issue first. You do not need issues for trivial updates like typos, most documentation updates etc. But if you're doing a PR that adjusts behavior we will need a issue to go with it.

Once you have an issue note the number and once you are ready to send your PR please squash your commits then make a single commit with something like the following format:

Expand All @@ -23,7 +23,7 @@ it can be used for such and such.
To deliver this feature we had to extend, this that and the other
with new behaviours
Backwards compatability is kept
Backwards compatibility is kept
```

Please see [How to Write a Git Commit Message](https://chris.beams.io/posts/git-commit/) for excellent coverage of the topic of commit messages. We don't require things to be as detailed or strict as that but it's a great resource to keep in mind.
Expand Down
8 changes: 4 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ source "https://rubygems.org"

group :test do
# Pin json for Ruby < 2.0.0
gem "json", "~> 1.8.3"
gem "json"
gem "mcollective-test"
gem "mocha", "~> 0.10.0"
gem "rake", "~> 10.4"
gem "rspec", "~> 2.11.0"
gem "mocha"
gem "rake"
gem "rspec"
gem "rubocop", "0.51.0"
gem "sys-proctable"
end
Expand Down
13 changes: 8 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

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

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

desc "Run rubycop style checks"
task :rubocop do
sh("rubocop -f progress -f offenses")
sh("rubocop")
end

desc "Run agent and application tests"
Expand All @@ -23,19 +26,19 @@ task :test do
sh "bundle exec rspec #{Dir.glob(test_pattern).sort.join(' ')}"
end

task :default => [:test, :rubocop]
task :default => [:rubocop, :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]
Expand Down
2 changes: 1 addition & 1 deletion spec/agent/process_agent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ module Agent
name.expects(:uid).raises("error")
Log.expects(:debug).with("Could not get uid for user: user1")
result = @agent.send(:get_uid, "user1")
result.should be_false
result.should be_falsey
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/aggregate/process_summary_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Aggregate
end

it "should set type and value variables" do
expect(aggregate.result[:value]).to eq([0, 0, 0, 0])
aggregate.result[:value].should eq([0, 0, 0, 0])
aggregate.result[:type].should == :numeric
end
end
Expand Down
14 changes: 7 additions & 7 deletions spec/application/process_application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ class Application

it "should fail if an action was not specified" do
ARGV.shift
expect {
lambda {
@app.post_option_parser({})
}.to raise_error
}.should raise_error(RuntimeError, "Please provide an action")
end

it "should fail on an invalid action" do
ARGV.shift
ARGV << "rspec"

expect {
lambda {
@app.post_option_parser({})
}.to raise_error
}.should raise_error(ArgumentError, "too few arguments")
end

it "should set fields from the cli" do
Expand Down Expand Up @@ -77,7 +77,7 @@ class Application
it "should set the value of just_zombies to a TrueClass or FalseClass" do
config = {:fields => []}
@app.post_option_parser(config)
expect(config[:just_zombies]).to be(false)
config[:just_zombies].should be(false)

ARGV << "list"

Expand All @@ -103,9 +103,9 @@ class Application

it "should fail on a invalid field name" do
config = {:fields => ["rspec"]}
expect {
lambda {
@app.validate_configuration(config)
}.to raise_error
}.should raise_error(RuntimeError, "'rspec' specified as process field. Valid options are PID, USER, VSZ, COMMAND, TTY, RSS, STATE")
end
end

Expand Down
1 change: 0 additions & 1 deletion spec/spec.opts

This file was deleted.

8 changes: 6 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
$: << File.join([File.dirname(__FILE__), "lib"])
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

require "rubygems"
require "rspec"
require "mcollective"
require "mcollective/test"
require "rspec/mocks"
require "mocha"
require "tempfile"

RSpec.configure do |config|
config.mock_with :mocha
config.include(MCollective::Test::Matchers)
config.raise_errors_for_deprecations!
config.expect_with(:rspec) { |c| c.syntax = :should }

config.before :each do
MCollective::PluginManager.clear
end
end

Dir["./spec/support/spec/**/*.rb"].sort.each { |f| require f }
18 changes: 9 additions & 9 deletions spec/util/processagent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@ module Util
class Processagent
describe "bytes_to_human" do
it "should return 0 if the value is a fraction" do
expect(Processagent.bytes_to_human(0.4)).to eq("0 B")
Processagent.bytes_to_human(0.4).should eq("0 B")
end

it "should return 0 if the value is negative" do
expect(Processagent.bytes_to_human(-1)).to eq("0 B")
Processagent.bytes_to_human(-1).should eq("0 B")
end

it "should correctly convert bignums" do
expect(Processagent.bytes_to_human(1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024)).to eq("1073741824.000 TB")
Processagent.bytes_to_human(1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024).should eq("1073741824.000 TB")
end

it "should cap the result at TB" do
expect(Processagent.bytes_to_human(1024 * 1024 * 1024 * 1024 * 1024)).to eq("1024.000 TB")
Processagent.bytes_to_human(1024 * 1024 * 1024 * 1024 * 1024).should eq("1024.000 TB")
end

it "should convert a value to the correct humand readable format" do
expect(Processagent.bytes_to_human(50)).to eq("50.000 B")
expect(Processagent.bytes_to_human(1024)).to eq("1.000 KB")
expect(Processagent.bytes_to_human(1024 * 1024)).to eq("1.000 MB")
expect(Processagent.bytes_to_human(1024 * 1024 * 1024)).to eq("1.000 GB")
expect(Processagent.bytes_to_human(1024 * 1024 * 1024 * 1024)).to eq("1.000 TB")
Processagent.bytes_to_human(50).should eq("50.000 B")
Processagent.bytes_to_human(1024).should eq("1.000 KB")
Processagent.bytes_to_human(1024 * 1024).should eq("1.000 MB")
Processagent.bytes_to_human(1024 * 1024 * 1024).should eq("1.000 GB")
Processagent.bytes_to_human(1024 * 1024 * 1024 * 1024).should eq("1.000 TB")
end
end
end
Expand Down

0 comments on commit 0b0975e

Please sign in to comment.