From d7da0a512b416bd0934a275049a93c741d379b6d Mon Sep 17 00:00:00 2001 From: Chris Edester Date: Tue, 21 Jun 2016 12:25:47 -0400 Subject: [PATCH 1/8] Add environment param for passing in web proxy and what not --- manifests/init.pp | 10 +++++++--- manifests/package.pp | 19 ++++++++++++++----- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index c980e53..c74beb7 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,11 +1,15 @@ -class r { +# init.pp + +class r ( + $package_ensure = installed, +) { case $::osfamily { 'Debian': { - package {'r-base': ensure => installed} + package { 'r-base': ensure => $package_ensure } } 'RedHat': { - package {'R-core': ensure => installed} + package { 'R-core': ensure => $package_ensure } } 'windows': { # Choco package does not install static version and does not add R to PATH diff --git a/manifests/package.pp b/manifests/package.pp index ba8f6f7..0fe425b 100644 --- a/manifests/package.pp +++ b/manifests/package.pp @@ -1,4 +1,12 @@ -define r::package($r_path = '', $repo = 'http://cran.rstudio.com', $dependencies = false, $timeout = 300) { +# package.pp + +define r::package ( + $r_path = '', + $repo = 'http://cran.rstudio.com', + $dependencies = false, + $environment = undef, + $timeout = 300, +) { case $::osfamily { '^(Debian|RedHat)$': { @@ -17,10 +25,11 @@ } exec { "install_r_package_${name}": - command => $command, - timeout => $timeout, - unless => "${binary} -q -e \"'${name}' %in% installed.packages()\" | grep 'TRUE'", - require => Class['r'] + command => $command, + environment => $environment, + timeout => $timeout, + unless => "${binary} -q -e \"'${name}' %in% installed.packages()\" | grep 'TRUE'", + require => Class['r'] } } From 95df1a5cb824bcdf87c50cba2d398d83de57e585 Mon Sep 17 00:00:00 2001 From: Chris Edester Date: Tue, 21 Jun 2016 12:10:56 -0400 Subject: [PATCH 2/8] Update to metadata.json --- Modulefile | 8 -------- metadata.json | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 8 deletions(-) delete mode 100644 Modulefile create mode 100644 metadata.json diff --git a/Modulefile b/Modulefile deleted file mode 100644 index ea8667d..0000000 --- a/Modulefile +++ /dev/null @@ -1,8 +0,0 @@ -name 'forward3ddev-r' -version '0.0.3' -source 'UNKNOWN' -author 'forward3d' -license 'Apache License, Version 2.0' -summary 'Install and manage R and its packages' -description 'Install and manage R; provides a defined type to install packages' -project_page 'https://github.com/forward3d/puppet-r' diff --git a/metadata.json b/metadata.json new file mode 100644 index 0000000..e4756ab --- /dev/null +++ b/metadata.json @@ -0,0 +1,50 @@ +{ + "name": "forward3ddev-r", + "version": "0.0.3", + "author": "forward3d", + "summary": "Install and manage R and its packages", + "license": "Apache License, Version 2.0", + "source": "https://github.com/forward3d/puppet-r.git", + "project_page": "https://github.com/forward3d/puppet-r", + "issues_url": "https://github.com/forward3d/puppet-r/issues", + "description": "Install and manage R; provides a defined type to install packages", + "dependencies": [ + + ], + "operatingsystem_support": [ + { + "operatingsystem": "RedHat", + "operatingsystemrelease": ["6", "7"] + }, + { + "operatingsystem": "CentOS", + "operatingsystemrelease": ["6", "7"] + }, + { + "operatingsystem": "OracleLinux", + "operatingsystemrelease": ["6", "7"] + }, + { + "operatingsystem": "Debian", + "operatingsystemrelease": ["7", "8"] + }, + { + "operatingsystem": "Ubuntu", + "operatingsystemrelease": ["12.04", "14.04"] + }, + { + "operatingsystem": "Windows", + "operatingsystemrelease": ["2008", "2008 R2", "2012", "2012 R2"] + } + ], + "requirements": [ + { + "name": "pe", + "version_requirement": ">= 3.0.0 < 5.0.0" + }, + { + "name": "puppet", + "version_requirement": ">= 3.0.0 < 5.0.0" + } + ] +} From e9aed374bce4fe60f1fa0bcd65cdbd5693d631f9 Mon Sep 17 00:00:00 2001 From: Chris Edester Date: Tue, 21 Jun 2016 13:12:01 -0400 Subject: [PATCH 3/8] Use https for packages --- manifests/package.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/package.pp b/manifests/package.pp index 0fe425b..38502b5 100644 --- a/manifests/package.pp +++ b/manifests/package.pp @@ -2,7 +2,7 @@ define r::package ( $r_path = '', - $repo = 'http://cran.rstudio.com', + $repo = 'https://cran.rstudio.com', $dependencies = false, $environment = undef, $timeout = 300, From 481c1548feaea1142c19533c0b8383c8530c2d3b Mon Sep 17 00:00:00 2001 From: Chris Edester Date: Tue, 21 Jun 2016 22:20:20 -0400 Subject: [PATCH 4/8] Fix invalid case syntax --- manifests/package.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/package.pp b/manifests/package.pp index 38502b5..2ed521d 100644 --- a/manifests/package.pp +++ b/manifests/package.pp @@ -9,7 +9,7 @@ ) { case $::osfamily { - '^(Debian|RedHat)$': { + 'Debian', 'RedHat': { if $r_path == '' { $binary = '/usr/bin/R' From 48f5e2b66d7f4582a1cfcf503ee379f0ddb4552f Mon Sep 17 00:00:00 2001 From: Chris Edester Date: Tue, 21 Jun 2016 23:24:09 -0400 Subject: [PATCH 5/8] Add optional dev package --- manifests/init.pp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index c74beb7..f271ff4 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,15 +1,17 @@ # init.pp class r ( - $package_ensure = installed, + $ensure = installed, + $devel = absent, ) { case $::osfamily { 'Debian': { - package { 'r-base': ensure => $package_ensure } + package { 'r-base': ensure => $ensure } } 'RedHat': { - package { 'R-core': ensure => $package_ensure } + package { 'R': ensure => $devel } -> + package { 'R-core': ensure => $ensure } } 'windows': { # Choco package does not install static version and does not add R to PATH From eaf7a6d1ec23865bec9ac5b748d30ce67d49cbc8 Mon Sep 17 00:00:00 2001 From: Bradley Koby Date: Tue, 17 Jul 2018 18:21:44 -0400 Subject: [PATCH 6/8] Install packages from github --- manifests/package.pp | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/manifests/package.pp b/manifests/package.pp index 2ed521d..79af6b5 100644 --- a/manifests/package.pp +++ b/manifests/package.pp @@ -1,11 +1,15 @@ # package.pp define r::package ( - $r_path = '', - $repo = 'https://cran.rstudio.com', - $dependencies = false, - $environment = undef, - $timeout = 300, + $r_path = '', + $repo = 'https://cran.rstudio.com', + $source = 'CRAN', + Boolean $dependencies = false, + $environment = undef, + $timeout = 300, + $configure_args = undef, + Boolean $quiet = true, + Boolean $force = false, ) { case $::osfamily { @@ -19,16 +23,21 @@ $binary = $r_path } - $command = $dependencies ? { - true => "${binary} -e \"install.packages('${name}', repos='${repo}', dependencies = TRUE)\"", - default => "${binary} -e \"install.packages('${name}', repos='${repo}', dependencies = FALSE)\"" + $command = $source ? { + 'github' => "${binary} -e \"library(devtools); install_github('${name}', ref='master', quiet=${quiet.bool2str.upcase}, force=${force.bool2str.upcase})\"", + default => "${binary} -e \"install.packages('${name}', repos='${repo}', dependencies=${dependencies.bool2str.upcase}, configure.args='${configure_args}', quite=${quiet.bool2str.upcase}, force=${force.bool2str.upcase})\"" + } + + $unless_command = $force ? { + true => "/usr/bin/echo FALSE | grep 'TRUE'", + false => "${binary} -q -e \"'${name.split('/')[-1]}' %in% installed.packages()\" | grep 'TRUE'" } exec { "install_r_package_${name}": command => $command, environment => $environment, timeout => $timeout, - unless => "${binary} -q -e \"'${name}' %in% installed.packages()\" | grep 'TRUE'", + unless => $unless_command, require => Class['r'] } From f9b64e563c3642b02cc274515545815f1538bda4 Mon Sep 17 00:00:00 2001 From: Bradley Koby Date: Sat, 4 Aug 2018 10:35:15 -0400 Subject: [PATCH 7/8] add ref parameter --- manifests/package.pp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manifests/package.pp b/manifests/package.pp index 79af6b5..e967c81 100644 --- a/manifests/package.pp +++ b/manifests/package.pp @@ -4,6 +4,7 @@ $r_path = '', $repo = 'https://cran.rstudio.com', $source = 'CRAN', + $ref = 'master', Boolean $dependencies = false, $environment = undef, $timeout = 300, @@ -24,7 +25,7 @@ } $command = $source ? { - 'github' => "${binary} -e \"library(devtools); install_github('${name}', ref='master', quiet=${quiet.bool2str.upcase}, force=${force.bool2str.upcase})\"", + 'github' => "${binary} -e \"library(devtools); install_github('${name}', ref=${ref}, quiet=${quiet.bool2str.upcase}, force=${force.bool2str.upcase})\"", default => "${binary} -e \"install.packages('${name}', repos='${repo}', dependencies=${dependencies.bool2str.upcase}, configure.args='${configure_args}', quite=${quiet.bool2str.upcase}, force=${force.bool2str.upcase})\"" } From efebfb05a3901cfdc196e45cdd8b57fd036f8fee Mon Sep 17 00:00:00 2001 From: Bradley Koby Date: Sat, 4 Aug 2018 14:17:07 -0400 Subject: [PATCH 8/8] Make compatible with PDK --- .gitignore | 25 ++++++++- .gitlab-ci.yml | 40 ++++++++++++++ .pdkignore | 24 +++++++++ .rspec | 2 + .rubocop.yml | 116 +++++++++++++++++++++++++++++++++++++++++ .travis.yml | 44 ++++++++++++++++ .yardopts | 1 + Gemfile | 78 +++++++++++++++++++++++++++ Rakefile | 5 ++ appveyor.yml | 52 ++++++++++++++++++ manifests/init.pp | 4 +- manifests/package.pp | 4 +- metadata.json | 45 +++++++++++----- spec/default_facts.yml | 8 +++ spec/spec_helper.rb | 52 +++++++++++++----- 15 files changed, 470 insertions(+), 30 deletions(-) create mode 100644 .gitlab-ci.yml create mode 100644 .pdkignore create mode 100644 .rspec create mode 100644 .rubocop.yml create mode 100644 .travis.yml create mode 100644 .yardopts create mode 100644 Gemfile create mode 100644 Rakefile create mode 100644 appveyor.yml create mode 100644 spec/default_facts.yml diff --git a/.gitignore b/.gitignore index 01d0a08..650022e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,24 @@ -pkg/ +.git/ +.*.sw[op] +.metadata +.yardoc +.yardwarns +*.iml +/.bundle/ +/.idea/ +/.vagrant/ +/coverage/ +/bin/ +/doc/ +/Gemfile.local +/Gemfile.lock +/junit/ +/log/ +/pkg/ +/spec/fixtures/manifests/ +/spec/fixtures/modules/ +/tmp/ +/vendor/ +/convert_report.txt +/update_report.txt +.DS_Store diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..43df405 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,40 @@ +--- +stages: + - syntax + - unit + +cache: + paths: + - vendor/bundle + +before_script: + - bundle -v + - rm Gemfile.lock || true + - gem update --system + - gem --version + - bundle -v + - bundle install --without system_tests --path vendor/bundle --jobs $(nproc) + +parallel_spec-Ruby 2.1.9-Puppet ~> 4.0: + stage: syntax + image: ruby:2.1.9 + script: + - bundle exec rake parallel_spec + variables: + PUPPET_GEM_VERSION: '~> 4.0' + +syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop-Ruby 2.4.4-Puppet ~> 5.5: + stage: syntax + image: ruby:2.4.4 + script: + - bundle exec rake syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop + variables: + PUPPET_GEM_VERSION: '~> 5.5' + +parallel_spec-Ruby 2.4.4-Puppet ~> 5.5: + stage: syntax + image: ruby:2.4.4 + script: + - bundle exec rake parallel_spec + variables: + PUPPET_GEM_VERSION: '~> 5.5' diff --git a/.pdkignore b/.pdkignore new file mode 100644 index 0000000..650022e --- /dev/null +++ b/.pdkignore @@ -0,0 +1,24 @@ +.git/ +.*.sw[op] +.metadata +.yardoc +.yardwarns +*.iml +/.bundle/ +/.idea/ +/.vagrant/ +/coverage/ +/bin/ +/doc/ +/Gemfile.local +/Gemfile.lock +/junit/ +/log/ +/pkg/ +/spec/fixtures/manifests/ +/spec/fixtures/modules/ +/tmp/ +/vendor/ +/convert_report.txt +/update_report.txt +.DS_Store diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..16f9cdb --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--color +--format documentation diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..faa6470 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,116 @@ +--- +require: rubocop-rspec +AllCops: + DisplayCopNames: true + TargetRubyVersion: '2.1' + Include: + - "./**/*.rb" + Exclude: + - bin/* + - ".vendor/**/*" + - "**/Gemfile" + - "**/Rakefile" + - pkg/**/* + - spec/fixtures/**/* + - vendor/**/* + - "**/Puppetfile" + - "**/Vagrantfile" + - "**/Guardfile" +Metrics/LineLength: + Description: People have wide screens, use them. + Max: 200 +RSpec/BeforeAfterAll: + Description: Beware of using after(:all) as it may cause state to leak between tests. + A necessary evil in acceptance testing. + Exclude: + - spec/acceptance/**/*.rb +RSpec/HookArgument: + Description: Prefer explicit :each argument, matching existing module's style + EnforcedStyle: each +Style/BlockDelimiters: + Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to + be consistent then. + EnforcedStyle: braces_for_chaining +Style/ClassAndModuleChildren: + Description: Compact style reduces the required amount of indentation. + EnforcedStyle: compact +Style/EmptyElse: + Description: Enforce against empty else clauses, but allow `nil` for clarity. + EnforcedStyle: empty +Style/FormatString: + Description: Following the main puppet project's style, prefer the % format format. + EnforcedStyle: percent +Style/FormatStringToken: + Description: Following the main puppet project's style, prefer the simpler template + tokens over annotated ones. + EnforcedStyle: template +Style/Lambda: + Description: Prefer the keyword for easier discoverability. + EnforcedStyle: literal +Style/RegexpLiteral: + Description: Community preference. See https://github.com/voxpupuli/modulesync_config/issues/168 + EnforcedStyle: percent_r +Style/TernaryParentheses: + Description: Checks for use of parentheses around ternary conditions. Enforce parentheses + on complex expressions for better readability, but seriously consider breaking + it up. + EnforcedStyle: require_parentheses_when_complex +Style/TrailingCommaInArguments: + Description: Prefer always trailing comma on multiline argument lists. This makes + diffs, and re-ordering nicer. + EnforcedStyleForMultiline: comma +Style/TrailingCommaInLiteral: + Description: Prefer always trailing comma on multiline literals. This makes diffs, + and re-ordering nicer. + EnforcedStyleForMultiline: comma +Style/SymbolArray: + Description: Using percent style obscures symbolic intent of array's contents. + EnforcedStyle: brackets +RSpec/MessageSpies: + EnforcedStyle: receive +Style/Documentation: + Exclude: + - lib/puppet/parser/functions/**/* + - spec/**/* +Style/WordArray: + EnforcedStyle: brackets +Style/CollectionMethods: + Enabled: true +Style/MethodCalledOnDoEndBlock: + Enabled: true +Style/StringMethods: + Enabled: true +Layout/EndOfLine: + Enabled: false +Metrics/AbcSize: + Enabled: false +Metrics/BlockLength: + Enabled: false +Metrics/ClassLength: + Enabled: false +Metrics/CyclomaticComplexity: + Enabled: false +Metrics/MethodLength: + Enabled: false +Metrics/ModuleLength: + Enabled: false +Metrics/ParameterLists: + Enabled: false +Metrics/PerceivedComplexity: + Enabled: false +RSpec/DescribeClass: + Enabled: false +RSpec/ExampleLength: + Enabled: false +RSpec/MessageExpectation: + Enabled: false +RSpec/MultipleExpectations: + Enabled: false +RSpec/NestedGroups: + Enabled: false +Style/AsciiComments: + Enabled: false +Style/IfUnlessModifier: + Enabled: false +Style/SymbolProc: + Enabled: false diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..81f77dd --- /dev/null +++ b/.travis.yml @@ -0,0 +1,44 @@ +--- +sudo: false +dist: trusty +language: ruby +cache: bundler +before_install: + - bundle -v + - rm -f Gemfile.lock + - gem update --system + - gem --version + - bundle -v +script: + - 'bundle exec rake $CHECK' +bundler_args: --without system_tests +rvm: + - 2.4.1 +env: + global: + - BEAKER_PUPPET_COLLECTION=puppet5 PUPPET_GEM_VERSION="~> 5.0" +matrix: + fast_finish: true + include: + - + env: CHECK="syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop" + - + env: CHECK=parallel_spec + - + env: PUPPET_GEM_VERSION="~> 4.0" CHECK=parallel_spec + rvm: 2.1.9 +branches: + only: + - master + - /^v\d/ +notifications: + email: false +deploy: + provider: puppetforge + user: puppet + password: + secure: "" + on: + tags: true + all_branches: true + condition: "$DEPLOY_TO_FORGE = yes" diff --git a/.yardopts b/.yardopts new file mode 100644 index 0000000..29c933b --- /dev/null +++ b/.yardopts @@ -0,0 +1 @@ +--markup markdown diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..5cda86e --- /dev/null +++ b/Gemfile @@ -0,0 +1,78 @@ +source ENV['GEM_SOURCE'] || 'https://rubygems.org' + +def location_for(place_or_version, fake_version = nil) + if place_or_version =~ %r{\A(git[:@][^#]*)#(.*)} + [fake_version, { git: Regexp.last_match(1), branch: Regexp.last_match(2), require: false }].compact + elsif place_or_version =~ %r{\Afile:\/\/(.*)} + ['>= 0', { path: File.expand_path(Regexp.last_match(1)), require: false }] + else + [place_or_version, { require: false }] + end +end + +def gem_type(place_or_version) + if place_or_version =~ %r{\Agit[:@]} + :git + elsif !place_or_version.nil? && place_or_version.start_with?('file:') + :file + else + :gem + end +end + +ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments +minor_version = ruby_version_segments[0..1].join('.') + +group :development do + gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0') + gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0') + gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0') + gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9') + gem "json", '<= 2.0.4', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.4.4') + gem "puppet-module-posix-default-r#{minor_version}", require: false, platforms: [:ruby] + gem "puppet-module-posix-dev-r#{minor_version}", require: false, platforms: [:ruby] + gem "puppet-module-win-default-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "puppet-module-win-dev-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw] +end + +puppet_version = ENV['PUPPET_GEM_VERSION'] +puppet_type = gem_type(puppet_version) +facter_version = ENV['FACTER_GEM_VERSION'] +hiera_version = ENV['HIERA_GEM_VERSION'] + +gems = {} + +gems['puppet'] = location_for(puppet_version) + +# If facter or hiera versions have been specified via the environment +# variables + +gems['facter'] = location_for(facter_version) if facter_version +gems['hiera'] = location_for(hiera_version) if hiera_version + +if Gem.win_platform? && puppet_version =~ %r{^(file:///|git://)} + # If we're using a Puppet gem on Windows which handles its own win32-xxx gem + # dependencies (>= 3.5.0), set the maximum versions (see PUP-6445). + gems['win32-dir'] = ['<= 0.4.9', require: false] + gems['win32-eventlog'] = ['<= 0.6.5', require: false] + gems['win32-process'] = ['<= 0.7.5', require: false] + gems['win32-security'] = ['<= 0.2.5', require: false] + gems['win32-service'] = ['0.8.8', require: false] +end + +gems.each do |gem_name, gem_params| + gem gem_name, *gem_params +end + +# Evaluate Gemfile.local and ~/.gemfile if they exist +extra_gemfiles = [ + "#{__FILE__}.local", + File.join(Dir.home, '.gemfile'), +] + +extra_gemfiles.each do |gemfile| + if File.file?(gemfile) && File.readable?(gemfile) + eval(File.read(gemfile), binding) + end +end +# vim: syntax=ruby diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..ed96b54 --- /dev/null +++ b/Rakefile @@ -0,0 +1,5 @@ +require 'puppetlabs_spec_helper/rake_tasks' +require 'puppet-syntax/tasks/puppet-syntax' +require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any? + +PuppetLint.configuration.send('disable_relative') diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..4a5b227 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,52 @@ +--- +version: 1.1.x.{build} +skip_commits: + message: /^\(?doc\)?.*/ +clone_depth: 10 +init: + - SET + - 'mkdir C:\ProgramData\PuppetLabs\code && exit 0' + - 'mkdir C:\ProgramData\PuppetLabs\facter && exit 0' + - 'mkdir C:\ProgramData\PuppetLabs\hiera && exit 0' + - 'mkdir C:\ProgramData\PuppetLabs\puppet\var && exit 0' +environment: + matrix: + - + RUBY_VERSION: 24-x64 + CHECK: syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop + - + PUPPET_GEM_VERSION: ~> 4.0 + RUBY_VERSION: 21 + CHECK: parallel_spec + - + PUPPET_GEM_VERSION: ~> 4.0 + RUBY_VERSION: 21-x64 + CHECK: parallel_spec + - + PUPPET_GEM_VERSION: ~> 5.0 + RUBY_VERSION: 24 + CHECK: parallel_spec + - + PUPPET_GEM_VERSION: ~> 5.0 + RUBY_VERSION: 24-x64 + CHECK: parallel_spec +matrix: + fast_finish: true +install: + - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH% + - bundle install --jobs 4 --retry 2 --without system_tests + - type Gemfile.lock +build: off +test_script: + - bundle exec puppet -V + - ruby -v + - gem -v + - bundle -v + - bundle exec rake %CHECK% +notifications: + - provider: Email + to: + - nobody@nowhere.com + on_build_success: false + on_build_failure: false + on_build_status_changed: false diff --git a/manifests/init.pp b/manifests/init.pp index f271ff4..878afce 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -10,8 +10,8 @@ package { 'r-base': ensure => $ensure } } 'RedHat': { - package { 'R': ensure => $devel } -> - package { 'R-core': ensure => $ensure } + package { 'R': ensure => $devel } + -> package { 'R-core': ensure => $ensure } } 'windows': { # Choco package does not install static version and does not add R to PATH diff --git a/manifests/package.pp b/manifests/package.pp index e967c81..e745e78 100644 --- a/manifests/package.pp +++ b/manifests/package.pp @@ -25,8 +25,8 @@ } $command = $source ? { - 'github' => "${binary} -e \"library(devtools); install_github('${name}', ref=${ref}, quiet=${quiet.bool2str.upcase}, force=${force.bool2str.upcase})\"", - default => "${binary} -e \"install.packages('${name}', repos='${repo}', dependencies=${dependencies.bool2str.upcase}, configure.args='${configure_args}', quite=${quiet.bool2str.upcase}, force=${force.bool2str.upcase})\"" + 'github' => "${binary} -e \"library(devtools); install_github('${name}', ref=\'${ref}\', quiet=${quiet.bool2str.upcase}, force=${force.bool2str.upcase})\"", # lint:ignore:140chars + default => "${binary} -e \"install.packages('${name}', repos='${repo}', dependencies=${dependencies.bool2str.upcase}, configure.args='${configure_args}', quite=${quiet.bool2str.upcase}, force=${force.bool2str.upcase})\"" # lint:ignore:140chars } $unless_command = $force ? { diff --git a/metadata.json b/metadata.json index e4756ab..b75d2a2 100644 --- a/metadata.json +++ b/metadata.json @@ -3,48 +3,67 @@ "version": "0.0.3", "author": "forward3d", "summary": "Install and manage R and its packages", - "license": "Apache License, Version 2.0", + "license": "Apache-2.0", "source": "https://github.com/forward3d/puppet-r.git", "project_page": "https://github.com/forward3d/puppet-r", "issues_url": "https://github.com/forward3d/puppet-r/issues", - "description": "Install and manage R; provides a defined type to install packages", "dependencies": [ ], "operatingsystem_support": [ { "operatingsystem": "RedHat", - "operatingsystemrelease": ["6", "7"] + "operatingsystemrelease": [ + "6", + "7" + ] }, { "operatingsystem": "CentOS", - "operatingsystemrelease": ["6", "7"] + "operatingsystemrelease": [ + "6", + "7" + ] }, { "operatingsystem": "OracleLinux", - "operatingsystemrelease": ["6", "7"] + "operatingsystemrelease": [ + "6", + "7" + ] }, { "operatingsystem": "Debian", - "operatingsystemrelease": ["7", "8"] + "operatingsystemrelease": [ + "7", + "8" + ] }, { "operatingsystem": "Ubuntu", - "operatingsystemrelease": ["12.04", "14.04"] + "operatingsystemrelease": [ + "12.04", + "14.04" + ] }, { "operatingsystem": "Windows", - "operatingsystemrelease": ["2008", "2008 R2", "2012", "2012 R2"] + "operatingsystemrelease": [ + "2008", + "2008 R2", + "2012", + "2012 R2" + ] } ], "requirements": [ - { - "name": "pe", - "version_requirement": ">= 3.0.0 < 5.0.0" - }, { "name": "puppet", "version_requirement": ">= 3.0.0 < 5.0.0" } - ] + ], + "description": "Install and manage R; provides a defined type to install packages", + "pdk-version": "1.6.0", + "template-url": "file://C:/Program Files/Puppet Labs/DevelopmentKit/share/cache/pdk-templates.git", + "template-ref": "1.6.0-0-gf5564c0" } diff --git a/spec/default_facts.yml b/spec/default_facts.yml new file mode 100644 index 0000000..3248be5 --- /dev/null +++ b/spec/default_facts.yml @@ -0,0 +1,8 @@ +# Use default_module_facts.yml for module specific facts. +# +# Facts specified here will override the values provided by rspec-puppet-facts. +--- +concat_basedir: "/tmp" +ipaddress: "172.16.254.254" +is_pe: false +macaddress: "AA:AA:AA:AA:AA:AA" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5fda588..e69d11d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,17 +1,45 @@ -dir = File.expand_path(File.dirname(__FILE__)) -$LOAD_PATH.unshift File.join(dir, 'lib') -require 'mocha' -require 'puppet' -require 'rspec' -require 'spec/autorun' +require 'puppetlabs_spec_helper/module_spec_helper' +require 'rspec-puppet-facts' -Spec::Runner.configure do |config| - config.mock_with :mocha +begin + require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb')) +rescue LoadError => loaderror + warn "Could not require spec_helper_local: #{loaderror.message}" end -# We need this because the RAL uses 'should' as a method. This -# allows us the same behaviour but with a different method name. -class Object - alias :must :should +include RspecPuppetFacts + +default_facts = { + puppetversion: Puppet.version, + facterversion: Facter.version, +} + +default_facts_path = File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')) +default_module_facts_path = File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')) + +if File.exist?(default_facts_path) && File.readable?(default_facts_path) + default_facts.merge!(YAML.safe_load(File.read(default_facts_path))) +end + +if File.exist?(default_module_facts_path) && File.readable?(default_module_facts_path) + default_facts.merge!(YAML.safe_load(File.read(default_module_facts_path))) end + +RSpec.configure do |c| + c.default_facts = default_facts + c.before :each do + # set to strictest setting for testing + # by default Puppet runs at warning level + Puppet.settings[:strict] = :warning + end +end + +def ensure_module_defined(module_name) + module_name.split('::').reduce(Object) do |last_module, next_module| + last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module) + last_module.const_get(next_module) + end +end + +# 'spec_overrides' from sync.yml will appear below this line