Skip to content

Commit f1c43be

Browse files
authored
Merge pull request #282 from myii/ci/add-freebsd-vagrant-in-github-actions
ci: enable FreeBSD Vagrant-based testing using GitHub Actions
2 parents 1e5cd11 + c79ce9a commit f1c43be

File tree

9 files changed

+136
-35
lines changed

9 files changed

+136
-35
lines changed

.github/workflows/kitchen.vagrant.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
- default-freebsd-122-latest-py3
18+
# - freebsd-122-latest-py3
19+
- default-freebsd-114-latest-py3
20+
# - freebsd-114-latest-py3
21+
steps:
22+
- name: 'Check out code'
23+
uses: 'actions/checkout@v2'
24+
- name: 'Set up Bundler cache'
25+
uses: 'actions/cache@v1'
26+
with:
27+
path: 'vendor/bundle'
28+
key: "${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}"
29+
restore-keys: "${{ runner.os }}-gems-"
30+
- name: 'Run Bundler'
31+
run: |
32+
ruby --version
33+
bundle config path vendor/bundle
34+
bundle install --jobs 4 --retry 3
35+
- name: 'Run Test Kitchen'
36+
run: 'bundle exec kitchen verify ${{ matrix.instance }}'

.pre-commit-config.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ repos:
1717
stages: [manual]
1818
additional_dependencies: ['@commitlint/[email protected]']
1919
always_run: true
20+
- repo: https://github.com/rubocop-hq/rubocop
21+
rev: v1.9.1
22+
hooks:
23+
- id: rubocop
24+
name: Check Ruby files with rubocop
25+
args: [--debug]
26+
always_run: true
27+
pass_filenames: false
2028
- repo: https://github.com/shellcheck-py/shellcheck-py
2129
rev: v0.7.1.1
2230
hooks:

.travis.yml

+5-16
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,14 @@ stages:
3636
# - name: 'release'
3737
# if: 'branch = master AND type != pull_request'
3838
jobs:
39-
allow_failures:
40-
- env: Lint_rubocop
41-
fast_finish: true
4239
include:
4340
## Define the test stage that runs the linters (and testing matrix, if applicable)
4441

45-
# Run all of the linters in a single job (except `rubocop`)
42+
# Run all of the linters in a single job
4643
- language: 'node_js'
4744
node_js: 'lts/*'
4845
env: 'Lint'
49-
name: 'Lint: salt-lint, yamllint, shellcheck & commitlint'
46+
name: 'Lint: salt-lint, yamllint, rubocop, shellcheck & commitlint'
5047
before_install: 'skip'
5148
script:
5249
# Install and run `salt-lint`
@@ -57,6 +54,9 @@ jobs:
5754
# Need at least `v1.17.0` for the `yaml-files` setting
5855
- pip install --user yamllint>=1.17.0
5956
- yamllint -s .
57+
# Install and run `rubocop`
58+
- gem install rubocop
59+
- rubocop -d
6060
# Run `shellcheck` (already pre-installed in Travis)
6161
- shellcheck --version
6262
- git ls-files -- '*.sh' '*.bash' '*.ksh'
@@ -65,17 +65,6 @@ jobs:
6565
- npm i -D @commitlint/config-conventional
6666
@commitlint/travis-cli
6767
- commitlint-travis
68-
# Run the `rubocop` linter in a separate job that is allowed to fail
69-
# Once these lint errors are fixed, this can be merged into a single job
70-
- language: node_js
71-
node_js: lts/*
72-
env: Lint_rubocop
73-
name: 'Lint: rubocop'
74-
before_install: skip
75-
script:
76-
# Install and run `rubocop`
77-
- gem install rubocop
78-
- rubocop -d
7968

8069
# Run `pre-commit` linters in a single job
8170
- language: 'python'

Gemfile

+4
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

+3
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

+23
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

+28
Original file line numberDiff line numberDiff line change
@@ -326,13 +326,41 @@ suites:
326326
- path: test/integration/default
327327
- name: passenger
328328
includes:
329+
- debian-10-tiamat-py3
330+
- debian-9-tiamat-py3
331+
- ubuntu-2004-tiamat-py3
332+
- ubuntu-1804-tiamat-py3
333+
- centos-8-tiamat-py3
334+
- centos-7-tiamat-py3
335+
- oraclelinux-8-tiamat-py3
329336
- debian-10-master-py3
330337
- debian-9-master-py3
331338
- ubuntu-2004-master-py3
332339
- ubuntu-1804-master-py3
333340
- centos-8-master-py3
334341
- centos-7-master-py3
335342
- oraclelinux-8-master-py3
343+
- debian-10-3002-5-py3
344+
- debian-9-3002-5-py3
345+
- ubuntu-2004-3002-5-py3
346+
- ubuntu-1804-3002-5-py3
347+
- centos-8-3002-5-py3
348+
- centos-7-3002-5-py3
349+
- oraclelinux-8-3002-5-py3
350+
- debian-10-3001-6-py3
351+
- debian-9-3001-6-py3
352+
- ubuntu-2004-3001-6-py3
353+
- ubuntu-1804-3001-6-py3
354+
- centos-8-3001-6-py3
355+
- centos-7-3001-6-py3
356+
- oraclelinux-8-3001-6-py3
357+
- debian-10-3000-8-py3
358+
- debian-9-3000-8-py3
359+
- ubuntu-1804-3000-8-py3
360+
- centos-8-3000-8-py3
361+
- centos-7-3000-8-py3
362+
- oraclelinux-8-3000-8-py3
363+
- ubuntu-1804-3000-8-py2
336364
provisioner:
337365
state_top:
338366
base:

nginx/map.jinja

+1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
'server_enabled': '/usr/local/etc/nginx/sites-enabled',
106106
'snippets_dir': '/usr/local/etc/nginx/snippets',
107107
'server_use_symlink': True,
108+
'openssl_package': 'openssl',
108109
'pid_file': '/var/run/nginx.pid',
109110
},
110111
}, default='Debian' ),

test/integration/default/controls/config.rb

+28-19
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,36 @@
22

33
# Set defaults, use debian as base
44

5-
server_available = '/etc/nginx/sites-available'
6-
server_enabled = '/etc/nginx/sites-enabled'
7-
85
# Override by platform family
9-
case platform[:family]
10-
when 'redhat', 'fedora'
11-
server_available = '/etc/nginx/conf.d'
12-
server_enabled = '/etc/nginx/conf.d'
13-
when 'suse'
14-
server_available = '/etc/nginx/vhosts.d'
15-
server_enabled = '/etc/nginx/vhosts.d'
16-
end
6+
server_available, server_enabled =
7+
case platform[:family]
8+
when 'redhat', 'fedora'
9+
%w[/etc/nginx/conf.d /etc/nginx/conf.d]
10+
when 'suse'
11+
%w[/etc/nginx/vhosts.d /etc/nginx/vhosts.d]
12+
when 'bsd'
13+
%w[/usr/local/etc/nginx/sites-available /usr/local/etc/nginx/sites-enabled]
14+
else
15+
%w[/etc/nginx/sites-available /etc/nginx/sites-enabled]
16+
end
17+
18+
nginx_conf, snippets_letsencrypt_conf, file_owner, file_group =
19+
case platform[:family]
20+
when 'bsd'
21+
%w[/usr/local/etc/nginx/nginx.conf /usr/local/etc/nginx/snippets/letsencrypt.conf
22+
root wheel]
23+
else
24+
%w[/etc/nginx/nginx.conf /etc/nginx/snippets/letsencrypt.conf root root]
25+
end
1726

1827
control 'Nginx configuration' do
1928
title 'should match desired lines'
2029

2130
# main configuration
22-
describe file('/etc/nginx/nginx.conf') do
31+
describe file(nginx_conf) do
2332
it { should be_file }
24-
it { should be_owned_by 'root' }
25-
it { should be_grouped_into 'root' }
33+
it { should be_owned_by file_owner }
34+
it { should be_grouped_into file_group }
2635
its('mode') { should cmp '0644' }
2736
its('content') do
2837
# rubocop:disable Metrics/LineLength
@@ -34,10 +43,10 @@
3443
end
3544

3645
# snippets configuration
37-
describe file('/etc/nginx/snippets/letsencrypt.conf') do
46+
describe file(snippets_letsencrypt_conf) do
3847
it { should be_file }
39-
it { should be_owned_by 'root' }
40-
it { should be_grouped_into 'root' }
48+
it { should be_owned_by file_owner }
49+
it { should be_grouped_into file_group }
4150
its('mode') { should cmp '0644' }
4251
its('content') { should include 'location ^~ /.well-known/acme-challenge/ {' }
4352
its('content') { should include 'proxy_pass http://localhost:9999;' }
@@ -52,8 +61,8 @@
5261

5362
describe file "#{dir}/mysite" do
5463
it { should be_file }
55-
it { should be_owned_by 'root' }
56-
it { should be_grouped_into 'root' }
64+
it { should be_owned_by file_owner }
65+
it { should be_grouped_into file_group }
5766
its('mode') { should cmp '0644' }
5867
its('content') { should include 'server_name localhost;' }
5968
its('content') { should include 'listen 80 default_server;' }

0 commit comments

Comments
 (0)