Skip to content

Commit

Permalink
(MODULES-10806) Add Github Actions workflows
Browse files Browse the repository at this point in the history
Added GitHub Actions workflows for `Static Code Analysis` and `Unit
Tests` that run each time there is a new `pull request` or `git push`.
`Unit tests` are also set to run every workday at `05:00:00 UTC`.

More info to be added.

In preparation for the Puppet 7 release, the
`puppet-module-posix-dev-r2.7` and `puppet-module-posix-dev-r2.7` gems
had to be removed from `Gemfile` due to the following dependency error:
  `puppet-module-posix-dev-r2.7` depends on
    `puppet_litmus` which depends on
      `bolt` which depends on
        `puppet` which is locked to a version below 7.

Also added the needed gems that were lost in the above removal process
and adapted the `puppet-blacksmith` version restrictions accordingly.
  • Loading branch information
luchihoratiu committed Sep 22, 2020
1 parent 7467d0a commit 8e35b3f
Show file tree
Hide file tree
Showing 8 changed files with 281 additions and 62 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/daily_unit_tests_with_nightly_puppet_gem.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
name: '[Daily] Unit Tests with nightly Puppet gem'

on:
schedule:
- cron: '0 5 * * 1-5'

jobs:
daily_unit_tests_with_nightly_puppet_gem:
name: ${{ matrix.os_type }} / Puppet${{ matrix.puppet_version }} gem / Ruby ${{ matrix.ruby }}
strategy:
matrix:
os: [ 'ubuntu-18.04', 'macos-10.15', 'windows-2019' ]
puppet_version: [ 5, 6, 7 ]
include:
- puppet_version: 5
ruby: 2.4
- puppet_version: 6
ruby: 2.5
- puppet_version: 7
ruby: 2.7

- os: 'ubuntu-18.04'
os_type: 'Linux'
env_set_cmd: 'export '
gem_file: 'puppet-latest.gem'
- os: 'macos-10.15'
os_type: 'macOS'
env_set_cmd: 'export '
gem_file: 'puppet-latest-universal-darwin.gem'
- os: 'windows-2019'
os_type: 'Windows'
env_set_cmd: '$env:'
gem_file: 'puppet-latest-x64-mingw32.gem'

runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install ruby version ${{ matrix.ruby }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}

- name: Install the latest nightly build of puppet${{ matrix.puppet_version }} gem
run: |
curl http://nightlies.puppet.com/downloads/gems/puppet${{ matrix.puppet_version }}-nightly/${{ matrix.gem_file }} --output puppet.gem
gem install puppet.gem -N
- name: Prepare testing environment with bundler
run: |
bundle config set system 'true'
${{ matrix.env_set_cmd }}PUPPET_GEM_VERSION=$(ruby -e 'puts /puppet\s+\((.+)\)/.match(`gem list -eld puppet`)[1]')
bundle update --jobs 4 --retry 3
- name: Run unit tests
run: bundle exec rake parallel_spec
50 changes: 50 additions & 0 deletions .github/workflows/static_code_analysis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
name: Static Code Analysis

on:
push:
branches: [ MODULES-10806 ]
pull_request:
branches: [ MODULES-10806 ]

jobs:
static_code_analysis:
name: Run checks

env:
ruby_version: 2.5

runs-on: 'ubuntu-18.04'
continue-on-error: true
steps:
- name: Checkout current PR code
uses: actions/checkout@v2

- name: Install ruby version ${{ env.ruby_version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.ruby_version }}

- name: Prepare testing environment with bundler
run: bundle update --jobs 4 --retry 3

- name: Run rake -t
run: bundle exec rake -t

- name: Run commits check
run: bundle exec rake commits

- name: Run validate check
run: bundle exec rake validate

- name: Run lint check
run: bundle exec rake lint

- name: Run metadata_lint check
run: bundle exec rake metadata_lint

- name: Run rubocop check
run: bundle exec rake rubocop

- name: Run syntax check
run: bundle exec rake syntax syntax:hiera syntax:manifests syntax:templates
61 changes: 61 additions & 0 deletions .github/workflows/unit_tests_with_nightly_puppet_gem.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
name: Unit Tests with nightly Puppet gem

on:
push:
branches: [ MODULES-10806 ]
pull_request:
branches: [ MODULES-10806 ]

jobs:
unit_tests_with_nightly_puppet_gem:
name: ${{ matrix.os_type }} / Puppet${{ matrix.puppet_version }} gem / Ruby ${{ matrix.ruby }}
strategy:
matrix:
os: [ 'ubuntu-18.04', 'macos-10.15', 'windows-2019' ]
puppet_version: [ 5, 6, 7 ]
include:
- puppet_version: 5
ruby: 2.4
- puppet_version: 6
ruby: 2.5
- puppet_version: 7
ruby: 2.7

- os: 'ubuntu-18.04'
os_type: 'Linux'
env_set_cmd: 'export '
gem_file: 'puppet-latest.gem'
- os: 'macos-10.15'
os_type: 'macOS'
env_set_cmd: 'export '
gem_file: 'puppet-latest-universal-darwin.gem'
- os: 'windows-2019'
os_type: 'Windows'
env_set_cmd: '$env:'
gem_file: 'puppet-latest-x64-mingw32.gem'

runs-on: ${{ matrix.os }}
continue-on-error: true
steps:
- name: Checkout current PR code
uses: actions/checkout@v2

- name: Install ruby version ${{ matrix.ruby }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}

- name: Install the latest nightly build of puppet${{ matrix.puppet_version }} gem
run: |
curl http://nightlies.puppet.com/downloads/gems/puppet${{ matrix.puppet_version }}-nightly/${{ matrix.gem_file }} --output puppet.gem
gem install puppet.gem -N
- name: Prepare testing environment with bundler
run: |
bundle config set system 'true'
${{ matrix.env_set_cmd }}PUPPET_GEM_VERSION=$(ruby -e 'puts /puppet\s+\((.+)\)/.match(`gem list -eld puppet`)[1]')
bundle update --jobs 4 --retry 3
- name: Run unit tests
run: bundle exec rake parallel_spec
49 changes: 49 additions & 0 deletions .github/workflows/unit_tests_with_released_puppet_gem.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
name: Unit Tests with released Puppet gem

on:
push:
branches: [ MODULES-10806 ]
pull_request:
branches: [ MODULES-10806 ]

jobs:
unit_tests_with_released_puppet_gem:
name: ${{ matrix.os_type }} / Puppet${{ matrix.puppet_version }} gem / Ruby ${{ matrix.ruby }}
strategy:
matrix:
os: [ 'ubuntu-18.04', 'macos-10.15', 'windows-2019' ]
puppet_version: [ 5, 6 ]
include:
- puppet_version: 5
ruby: 2.4
- puppet_version: 6
ruby: 2.5

- os: 'ubuntu-18.04'
os_type: 'Linux'
- os: 'macos-10.15'
os_type: 'macOS'
- os: 'windows-2019'
os_type: 'Windows'

runs-on: ${{ matrix.os }}
continue-on-error: true
env:
PUPPET_GEM_VERSION: ~> ${{ matrix.puppet_version }}.0
steps:
- name: Checkout current PR code
uses: actions/checkout@v2

- name: Install ruby version ${{ matrix.ruby }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}

- name: Prepare testing environment with bundler
run: |
bundle config set system 'true'
bundle update --jobs 4 --retry 3
- name: Run unit tests
run: bundle exec rake parallel_spec
42 changes: 18 additions & 24 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,13 @@

source ENV['GEM_SOURCE'] || "https://rubygems.org"

# Determines what type of gem is requested based on place_or_version.
def gem_type(place_or_version)
if place_or_version =~ /^git:/
:git
elsif place_or_version =~ /^file:/
:file
else
:gem
end
end

# Find a location or specific version for a gem. place_or_version can be a
# version, which is most often used. It can also be git, which is specified as
# `git://somewhere.git#branch`. You can also use a file source location, which
# is specified as `file://some/location/on/disk`.
def location_for(place_or_version, fake_version = nil)
if place_or_version =~ /^(git[:@][^#]*)#(.*)/
def location_for(place, fake_version = nil)
if place.is_a?(String) && place =~ /^(git[:@][^#]*)#(.*)/
[fake_version, { :git => $1, :branch => $2, :require => false }].compact
elsif place_or_version =~ /^file:\/\/(.*)/
elsif place.is_a?(String) && place =~ /^file:\/\/(.*)/
['>= 0', { :path => File.expand_path($1), :require => false }]
else
[place_or_version, { :require => false }]
[place, { :require => false }]
end
end

Expand All @@ -42,14 +27,22 @@ minor_version = "#{ruby_version_segments[0]}.#{ruby_version_segments[1]}"
#end

group :development do
gem "puppet-lint", '2.3.6'
gem "rake", '~> 12', :require => false
gem "parallel_tests", '>= 2.14.1', '< 2.14.3', :require => false
gem "metadata-json-lint", '>= 2.0.2', '< 3.0.0', :require => false
gem "rspec-puppet-facts", '~> 1.10.0', :require => false
gem "rspec_junit_formatter", '~> 0.2', :require => false
gem "rubocop", '~> 0.49.0', :require => false
gem "rubocop-rspec", '~> 1.16.0', :require => false
gem "rubocop-i18n", '~> 1.2.0', :require => false
gem "puppetlabs_spec_helper", '>= 2.9.0', '< 3.0.0', :require => false
gem "puppet-module-posix-default-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-posix-dev-r#{minor_version}", '~> 0.3', :require => false, :platforms => "ruby"
gem "puppet-module-win-dev-r#{minor_version}", '~> 0.0.7', :require => false, :platforms => ["mswin", "mingw", "x64_mingw"]
gem "rspec-puppet", :require => true, git: "https://github.com/rodjek/rspec-puppet", tag: "v2.7.9"
gem "json_pure", '<= 2.0.1', :require => false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')
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 "puppet-lint", '2.3.6'
end

group :system_tests do
Expand All @@ -62,11 +55,12 @@ group :system_tests do
gem "beaker-vmpooler", '~> 1.3'
gem "serverspec", '~> 2.39'
gem "beaker-pe", :require => false
gem "beaker-rspec", *location_for(ENV['BEAKER_RSPEC_VERSION'] || '~> 6.2')
gem "beaker-rspec"
gem "beaker-hostgenerator", *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION'])
gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.1')
gem 'pdk', *location_for(ENV['PDK_GEM_VERSION'])
gem "puppet-blacksmith", '~> 3.4', :require => false
gem "puppet-blacksmith", '~> 3.4', :require => false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('7.0.0')
gem "puppet-blacksmith", '~> 6', :require => false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('7.0.0')
# Bundler fails on 2.1.9 even though this group is excluded
if ENV['GEM_BOLT']
gem 'bolt', '~> 1.15', require: false
Expand Down
1 change: 1 addition & 0 deletions manifests/install/solaris.pp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
notice ("Puppet install log file at ${_logfile}")

$_installsh = "${::env_temp_variable}/solaris_install.sh"

file { $_installsh:
ensure => file,
mode => '0755',
Expand Down
18 changes: 10 additions & 8 deletions spec/spec_helper_local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
require 'rspec-puppet-facts'
include RspecPuppetFacts

location = File.expand_path('/dev/null')

RSpec.configure do |c|
c.default_facts = {
:aio_agent_version => '5.5.10',
Expand All @@ -22,31 +24,31 @@
:system32 => nil,
:fips_enabled => false,

:puppet_ssldir => '/dev/null/ssl',
:puppet_config => '/dev/null/puppet.conf',
:puppet_ssldir => "#{location}/ssl",
:puppet_config => "#{location}/puppet.conf",
:puppet_sslpaths => {
'privatedir' => {
'path' => '/dev/null/ssl/private',
'path' => "#{location}/ssl/private",
'path_exists' => true,
},
'privatekeydir' => {
'path' => '/dev/null/ssl/private_keys',
'path' => "#{location}/ssl/private_keys",
'path_exists' => true,
},
'publickeydir' => {
'path' => '/dev/null/ssl/public_keys',
'path' => "#{location}/ssl/public_keys",
'path_exists' => true,
},
'certdir' => {
'path' => '/dev/null/ssl/certs',
'path' => "#{location}/ssl/certs",
'path_exists' => true,
},
'requestdir' => {
'path' => '/dev/null/ssl/certificate_requests',
'path' => "#{location}/ssl/certificate_requests",
'path_exists' => true,
},
'hostcrl' => {
'path' => '/dev/null/ssl/crl.pem',
'path' => "#{location}/ssl/crl.pem",
'path_exists' => true,
},
},
Expand Down
Loading

0 comments on commit 8e35b3f

Please sign in to comment.