Skip to content

Commit 9f34c8a

Browse files
authored
Merge pull request #218 from alxwr/make-composer-dependencies-configurable
feat(composer): make dependencies configurable
2 parents bf6a758 + cb2758d commit 9f34c8a

File tree

14 files changed

+745
-8
lines changed

14 files changed

+745
-8
lines changed

.github/workflows/kitchen.vagrant.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
4+
name: 'Kitchen Vagrant (FreeBSD)'
5+
'on': ['push', 'pull_request']
6+
7+
env:
8+
KITCHEN_LOCAL_YAML: 'kitchen.vagrant.yml'
9+
10+
jobs:
11+
test:
12+
runs-on: 'macos-10.15'
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
instance:
17+
- freebsd-freebsd-122-latest-py3
18+
- freebsd-freebsd-114-latest-py3
19+
steps:
20+
- name: 'Check out code'
21+
uses: 'actions/checkout@v2'
22+
- name: 'Set up Bundler cache'
23+
uses: 'actions/cache@v1'
24+
with:
25+
path: 'vendor/bundle'
26+
key: "${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}"
27+
restore-keys: "${{ runner.os }}-gems-"
28+
- name: 'Run Bundler'
29+
run: |
30+
ruby --version
31+
bundle config path vendor/bundle
32+
bundle install --jobs 4 --retry 3
33+
- name: 'Run Test Kitchen'
34+
run: 'bundle exec kitchen verify ${{ matrix.instance }}'

Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ gem 'kitchen-docker', git: 'https://gitlab.com/saltstack-formulas/infrastructure
1212
# rubocop:enable Layout/LineLength
1313
gem 'kitchen-inspec', '>= 2.2.1'
1414
gem 'kitchen-salt', '>= 0.6.3'
15+
16+
group :vagrant do
17+
gem 'kitchen-vagrant'
18+
end

Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ GEM
292292
kitchen-salt (0.6.3)
293293
hashie (>= 3.5)
294294
test-kitchen (>= 1.4)
295+
kitchen-vagrant (1.7.0)
296+
test-kitchen (>= 1.4, < 3)
295297
libyajl2 (1.2.0)
296298
license-acceptance (1.0.19)
297299
pastel (~> 0.7)
@@ -525,6 +527,7 @@ DEPENDENCIES
525527
kitchen-docker!
526528
kitchen-inspec (>= 2.2.1)
527529
kitchen-salt (>= 0.6.3)
530+
kitchen-vagrant
528531

529532
BUNDLED WITH
530533
2.1.2

kitchen.vagrant.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
4+
driver:
5+
name: vagrant
6+
cache_directory: false
7+
customize:
8+
usbxhci: 'off'
9+
gui: false
10+
linked_clone: true
11+
ssh:
12+
shell: /bin/sh
13+
14+
platforms:
15+
- name: freebsd-122-latest-py3
16+
driver:
17+
box: bento/freebsd-12.2
18+
- name: freebsd-114-latest-py3
19+
driver:
20+
box: bento/freebsd-11.4
21+
22+
provisioner:
23+
salt_install: bootstrap

kitchen.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,3 +455,23 @@ suites:
455455
verifier:
456456
inspec_tests:
457457
- path: test/integration/default
458+
- name: freebsd
459+
includes:
460+
- freebsd-122-latest-py3
461+
- freebsd-114-latest-py3
462+
provisioner:
463+
state_top:
464+
base:
465+
'*':
466+
- php._mapdata
467+
- php.composer
468+
pillars:
469+
top.sls:
470+
base:
471+
'*':
472+
- php
473+
pillars_from_files:
474+
php.sls: test/salt/pillar/freebsd.sls
475+
verifier:
476+
inspec_tests:
477+
- path: test/integration/default

php/composer.sls

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,9 @@
1212
1313
include:
1414
- php
15-
{% if grains['os_family'] == 'FreeBSD' %}
16-
- php.filter
17-
- php.hash
18-
- php.json
19-
- php.mbstring
20-
- php.openssl
21-
- php.phar
22-
{% endif %}
15+
{%- for module in php.lookup.get('composer', {}).get('required_modules', []) %}
16+
- php.{{ module }}
17+
{%- endfor %}
2318
2419
get-composer:
2520
file.managed:

php/map.jinja

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3102,6 +3102,15 @@
31023102
'cli': {
31033103
'ini': '/usr/local/etc/php.ini'
31043104
},
3105+
'composer': {
3106+
'required_modules': [
3107+
'filter',
3108+
'json',
3109+
'mbstring',
3110+
'openssl',
3111+
'phar',
3112+
],
3113+
},
31053114
'pkgs': {
31063115
'apache2': 'mod_php' + freebsd_php_version,
31073116
'composer_bin': 'composer',

pillar.example

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,16 @@ php:
7474
cli:
7575
ini: /location/of/php-cli/php.ini
7676

77+
# php.composer
78+
# Some OS need modules to be installed
79+
composer:
80+
required_modules:
81+
- filter
82+
- json
83+
- mbstring
84+
- openssl
85+
- phar
86+
7787
# php-fpm settings
7888
fpm:
7989

test/integration/default/controls/config_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,23 @@ def test_redhat; end
2929

3030
def test_suse; end
3131

32+
def test_bsd
33+
describe file('/usr/local/bin/composer') do
34+
it { should be_file }
35+
it { should be_owned_by 'root' }
36+
it { should be_grouped_into 'wheel' }
37+
its('mode') { should cmp '0755' }
38+
end
39+
end
40+
3241
case os[:family]
3342
when 'debian'
3443
test_debian
3544
when 'redhat', 'fedora'
3645
test_redhat
3746
when 'suse'
3847
test_suse
48+
when 'bsd'
49+
test_bsd
3950
end
4051
end

test/integration/default/controls/package_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,24 @@ def test_suse
4444
end
4545
end
4646

47+
def test_bsd
48+
%w[
49+
php74 php74-filter php74-json php74-mbstring php74-openssl php74-phar
50+
].each do |pkg|
51+
describe package(pkg) do
52+
it { should be_installed }
53+
end
54+
end
55+
end
56+
4757
case os[:family]
4858
when 'debian'
4959
test_debian
5060
when 'redhat', 'fedora'
5161
test_redhat
5262
when 'suse'
5363
test_suse
64+
when 'bsd'
65+
test_bsd
5466
end
5567
end

test/integration/default/controls/service_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,16 @@ def test_redhat; end
1919

2020
def test_suse; end
2121

22+
def test_bsd; end
23+
2224
case os[:family]
2325
when 'debian'
2426
test_debian
2527
when 'redhat', 'fedora'
2628
test_redhat
2729
when 'suse'
2830
test_suse
31+
when 'bsd'
32+
test_bsd
2933
end
3034
end

0 commit comments

Comments
 (0)