Skip to content

Commit

Permalink
Added lint and spec tests, automated forge builds
Browse files Browse the repository at this point in the history
  • Loading branch information
mvisonneau committed Jan 20, 2017
1 parent fc36f04 commit b23b6d2
Show file tree
Hide file tree
Showing 16 changed files with 210 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fixtures:
repositories:
apt: "git://github.com/puppetlabs/puppetlabs-apt.git"
stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git"
symlinks:
curator: "#{source_dir}"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Gemfile.lock
spec/fixtures
35 changes: 35 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
language: ruby
before_install:
- bundle -v
- rm Gemfile.lock || true
- gem update --system
- gem update bundler
- gem --version
- bundle -v
script:
- 'bundle exec rake $CHECK'
matrix:
fast_finish: true
include:
- rvm: 2.4.0
env: PUPPET_VERSION="~> 4.0" CHECK=lint
- rvm: 2.4.0
env: PUPPET_VERSION="~> 4.0" CHECK=spec
- rvm: 2.4.0
env: PUPPET_VERSION="~> 4.0" CHECK=build DEPLOY_TO_FORGE=yes
branches:
only:
- master
- /^v\d/
notifications:
email: false
deploy:
provider: puppetforge
user: mvisonneau
password:
secure: "G9TITzYhtWVDFp3FcXT+QmJlpLZWo8a9xsjFErrRnLEXC2hnTyyKjvnmI1oH+UOjOipWx3lPnou+kV31JD7V7mkBZCw+lXT4G/8zS56a7hgzUwaicMWzgHmtU/KmCSLwROE0g7jE25fmouw08fH9WnZa01ROrD6yz+s9qwW8BaYsaOjp7XuNgAUInL8KY5eHkVT4uYdOVsUYJRFh13qO+hqm4Z0zplDV/5mEqxJyDl0XGJXhKoSE8qPlZlR69oskN50JlnXC1nAsbP72YU5BiV8vLGOhURPPPrMT13PCh3OXKXKH0ncC7tQumJ8i+Q8nVoQ6KR3o9nmct/V4+yRgP7oNxPKATI0KW7DyMcKLpO8yVLC0qd2HKKG48y8E+SaUZu10HH8yX/9YpCMKZ8TlJlCNJKeHgc9zH9Z4yhRDijXYXLfalNChaThNanF3aRefQNkPbfGChEewiegp/4J9VIGwfyKrHla1msMJ9c41wTrzKAZbmhmPs5Tom/eVeLQGPqJwMd0SACh4jDy3k8yiiuCDm1MLmm/WpI+jp6CP98is4SsJIR7vf1g2vNcVXMJzioMRTa99rlw2LDadMim051PbaLUDECM8WlNZr7NiS38SWV6YZSbAmoheT5TWgmtzWeZr/DzIC1nc0S/VSiUCOEQWx8TlcABD7h4/kNa3nSs="
on:
tags: true
all_branches: true
condition: "$DEPLOY_TO_FORGE = yes"
12 changes: 12 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
source 'https://rubygems.org'

gem 'facter'
gem 'hiera'
gem 'puppet-blacksmith'
gem 'puppet-lint'
gem 'puppet'
gem 'puppetlabs_spec_helper'
gem 'rake'
gem 'rspec-puppet-facts'
gem 'rspec-puppet'
gem 'rspec'
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ curator::job { 'purge_logstash_over_45_days_everyday':
```

### Hiera support
### Builtin Hiera support

You can also directly use hiera in order to manage your resources :

Expand Down
11 changes: 11 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'puppet_blacksmith/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
require 'puppetlabs_spec_helper/rake_tasks'

## PUPPETLINT CONFIGURATION
Rake::Task[:lint].clear
PuppetLint::RakeTask.new :lint do |config|
config.disable_checks = [
'140chars'
]
end
6 changes: 6 additions & 0 deletions manifests/action.pp
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# == Define: curator::action
#
# Creates a curator action
#
# === Parameters
#
define curator::action (
String $config_path = $::curator::config_path,
String $config_owner = $::curator::user_name,
Expand Down
8 changes: 8 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# == Class: curator::config
#
# Automatically called within the curator class
#
# Creates the configuration file for the tool
#
# === Parameters
#
class curator::config (
Optional[String] $certificate = $::curator::certificate,
String $config_path = $::curator::config_path,
Expand Down
8 changes: 7 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

# == Class: curator
#
# Main class that needs to be included to your manifests in order to install
# the tool.
#
# === Parameters
#
class curator (
String $ensure = present,
Hash $actions = {},
Expand Down
9 changes: 8 additions & 1 deletion manifests/install.pp
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@

# == Class: curator::install
#
# Automatically called within the curator class
#
# Handles the installation of the tool.
#
# === Parameters
#
class curator::install (
String $ensure = $::curator::ensure,
Boolean $manage_repository = $::curator::manage_repository,
Expand Down
6 changes: 6 additions & 0 deletions manifests/job.pp
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# == Define: curator::job
#
# Creates a cronjob that automates the trigger of curator::actions defined resources.
#
# === Parameters
#
define curator::job (
String $action,
String $hour,
Expand Down
9 changes: 9 additions & 0 deletions manifests/repository.pp
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# == Class: curator::repository
#
# Automatically called within the curator class by default but can be removed
# setting $manage_repository to false
#
# Handles the installation of the repository accordingly to the os type
#
# === Parameters
#
class curator::repository (
String $version = $::curator::repository_version,
) inherits curator {
Expand Down
6 changes: 6 additions & 0 deletions manifests/repository/apt.pp
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# == Class: curator::repository::apt
#
# Private class included if $manage_repository is true and if the os family is debian.
#
# === Parameters
#
class curator::repository::apt (
String $version = $::curator::repository::version,
) inherits curator::repository {
Expand Down
6 changes: 6 additions & 0 deletions manifests/repository/yum.pp
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# == Class: curator::repository::yum
#
# Private class included if $manage_repository is true and if the os family is redhat.
#
# === Parameters
#
class curator::repository::yum (
String $rhel_major_release = $::os['release']['major'],
String $version = $::curator::repository::version,
Expand Down
86 changes: 86 additions & 0 deletions spec/classes/curator_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
require 'spec_helper'

describe 'curator' do

context 'with default configuration on Debian' do
let :facts do {
:lsbdistid => 'Debian',
:osfamily => 'Debian',
:os => { :family => 'Debian' },
:puppetversion => '4.8.2'
}
end

it { should compile.with_all_deps }
it { should contain_class( 'curator::install' ) }
it { should contain_class( 'curator::config' ) }
it { should contain_class( 'curator::repository' ) }
it { should contain_class( 'curator::repository::apt' ) }
it { should_not contain_class( 'curator::repository::yum' ) }
end

context 'with manage_repository=false on Debian' do
let :params do {
:manage_repository => false,
}
end

let :facts do {
:lsbdistid => 'Debian',
:osfamily => 'Debian',
:os => { :family => 'Debian' },
:puppetversion => '4.8.2'
}
end

it { should compile.with_all_deps }
it { should contain_class( 'curator::install' ) }
it { should contain_class( 'curator::config' ) }
it { should_not contain_class( 'curator::repository' ) }
it { should_not contain_class( 'curator::repository::apt' ) }
it { should_not contain_class( 'curator::repository::yum' ) }
end

context 'with default configuration on RedHat' do
let :facts do {
:os => {
:family => 'RedHat',
:release => {
:major => '7'
}
}
}
end

it { should compile.with_all_deps }
it { should contain_class( 'curator::install' ) }
it { should contain_class( 'curator::config' ) }
it { should contain_class( 'curator::repository' ) }
it { should_not contain_class( 'curator::repository::apt' ) }
it { should contain_class( 'curator::repository::yum' ) }
end

context 'with manage_repository=false on RedHat' do
let :params do {
:manage_repository => false,
}
end

let :facts do {
:os => {
:family => 'RedHat',
:release => {
:major => '7'
}
}
}
end

it { should compile.with_all_deps }
it { should contain_class( 'curator::install' ) }
it { should contain_class( 'curator::config' ) }
it { should_not contain_class( 'curator::repository' ) }
it { should_not contain_class( 'curator::repository::apt' ) }
it { should_not contain_class( 'curator::repository::yum' ) }
end
end
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require 'puppetlabs_spec_helper/module_spec_helper'

0 comments on commit b23b6d2

Please sign in to comment.