Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,29 @@ on:
branches:
- main
- master
workflow_dispatch:
inputs:
beaker_staging_url:
description: |-
URL to a staging Server to test unreleased packages.
We will append the version to the Server and assume all packages are in the same directory.
Only supported for AIO packages.
required: false
type: string
default: 'https://artifacts.voxpupuli.org/openvox-agent'
beaker_collection:
description: |-
When set to staging, we will download the packages from staging_url.
Otherwise we will use the official repos. Supported values: puppet7, puppet8, openvox7, openvox8, staging.
When unset, we will generate a list of supported collections based on metadata.json.
required: false
type: string
beaker_staging_version:
description: |-
The package version we want to test.
Only used for beaker_collection = staging
required: false
type: string

concurrency:
group: ${{ github.ref_name }}
Expand All @@ -22,6 +45,9 @@ permissions:
jobs:
puppet:
name: Puppet
uses: voxpupuli/gha-puppet/.github/workflows/basic.yml@v4
uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v4
with:
beaker_staging_url: ${{ inputs.beaker_staging_url }}
beaker_collection: ${{ inputs.beaker_collection }}
beaker_staging_version: ${{ inputs.beaker_staging_version }}
additional_packages: 'libaugeas-dev augeas-tools'
2 changes: 2 additions & 0 deletions .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ Gemfile:
spec/spec_helper.rb:
spec_overrides:
- "require 'spec_helper_local'"
spec/spec_helper_acceptance.rb:
unmanaged: false
66 changes: 66 additions & 0 deletions spec/acceptance/apache_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# frozen_string_literal: true

require 'spec_helper_acceptance'

describe 'apache_directive and apache_setenv' do
before(:all) do
shell("printf 'ServerName foo.example.com\\n<IfModule mpm_prefork_module>\\n StartServers 2\\n</IfModule>\\n' > /tmp/apache_test.conf")
end

context 'with ensure => present' do
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<~PUPPET
apache_directive { 'Timeout':
ensure => present,
args => '60',
target => '/tmp/apache_test.conf',
}
apache_directive { 'StartServers for mpm_prefork_module':
ensure => present,
name => 'StartServers',
context => 'IfModule[arg="mpm_prefork_module"]',
args => '4',
target => '/tmp/apache_test.conf',
}
apache_setenv { 'SPECIAL_PATH':
ensure => present,
value => '/foo/bin',
target => '/tmp/apache_test.conf',
}
PUPPET
end
end

describe file('/tmp/apache_test.conf') do
its(:content) { is_expected.to match(%r{^ServerName foo\.example\.com$}) }
its(:content) { is_expected.to match(%r{^Timeout 60$}) }
its(:content) { is_expected.to match(%r{^<IfModule mpm_prefork_module>\n\s+StartServers 4\n</IfModule>$}) }
its(:content) { is_expected.to match(%r{^SetEnv SPECIAL_PATH /foo/bin$}) }
end
end

context 'with ensure => absent' do
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<~PUPPET
apache_directive { 'ServerName':
ensure => absent,
args => 'foo.example.com',
target => '/tmp/apache_test.conf',
}
apache_setenv { 'SPECIAL_PATH':
ensure => absent,
target => '/tmp/apache_test.conf',
}
PUPPET
end
end

describe file('/tmp/apache_test.conf') do
its(:content) { is_expected.not_to match(%r{ServerName}) }
its(:content) { is_expected.not_to match(%r{SPECIAL_PATH}) }
its(:content) { is_expected.to match(%r{^Timeout 60$}) }
end
end
end
10 changes: 10 additions & 0 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

require 'voxpupuli/acceptance/spec_helper_acceptance'

configure_beaker(modules: :metadata)

Dir['./spec/support/acceptance/**/*.rb'].sort.each { |f| require f }
Loading