Skip to content

Commit 296b338

Browse files
committed
Test via Travis CI based on template-formula and saltstack-formulas#98
1 parent 6b8e082 commit 296b338

12 files changed

Lines changed: 386 additions & 38 deletions

File tree

.kitchen.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

.travis.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
stages:
2+
- test
3+
- commitlint
4+
- name: release
5+
if: branch = master AND type != pull_request
6+
7+
sudo: required
8+
cache: bundler
9+
language: ruby
10+
11+
services:
12+
- docker
13+
14+
# Make sure the instances listed below match up with
15+
# the `platforms` defined in `kitchen.yml`
16+
# NOTE: Please try to select up to six instances that add some meaningful
17+
# testing of the formula's behaviour. If possible, try to refrain from
18+
# the classical "chosing all the instances because I want to test on
19+
# another/all distro/s" trap: it will just add time to the testing (see
20+
# the discussion on #121). As an example, the set chosen below covers
21+
# the most used distros families, systemd and non-systemd and the latest
22+
# three supported Saltstack versions with python2 and 3."
23+
# As for `kitchen.yml`, that should still contain all of the platforms,
24+
# to allow for comprehensive local testing
25+
# Ref: https://github.com/saltstack-formulas/template-formula/issues/118
26+
# Ref: https://github.com/saltstack-formulas/template-formula/issues/121
27+
env:
28+
matrix:
29+
- INSTANCE: default-debian-9-2019-2-py3
30+
# - INSTANCE: default-ubuntu-1804-2019-2-py3
31+
- INSTANCE: default-centos-7-2019-2-py3
32+
# - INSTANCE: default-fedora-29-2019-2-py3
33+
- INSTANCE: default-opensuse-leap-15-2019-2-py3
34+
# - INSTANCE: default-debian-9-2018-3-py2
35+
- INSTANCE: default-ubuntu-1604-2018-3-py2
36+
# - INSTANCE: default-centos-7-2018-3-py2
37+
- INSTANCE: default-fedora-29-2018-3-py2
38+
# TODO: Use this when fixed instead of `opensuse-leap-42`
39+
# Ref: https://github.com/netmanagers/salt-image-builder/issues/2
40+
# - INSTANCE: default-opensuse-leap-15-2018-3-py2
41+
# - INSTANCE: default-opensuse-leap-42-2018-3-py2
42+
# - INSTANCE: default-debian-8-2017-7-py2
43+
# - INSTANCE: default-ubuntu-1604-2017-7-py2
44+
# TODO: Enable after improving the formula to work with other than `systemd`
45+
- INSTANCE: default-centos-6-2017-7-py2
46+
# - INSTANCE: default-fedora-28-2017-7-py2
47+
# - INSTANCE: default-opensuse-leap-42-2017-7-py2
48+
49+
script:
50+
- bundle exec kitchen verify ${INSTANCE}
51+
52+
jobs:
53+
include:
54+
# Define the commitlint stage
55+
- stage: commitlint
56+
language: node_js
57+
node_js: lts/*
58+
before_install: skip
59+
script:
60+
- npm install @commitlint/config-conventional -D
61+
- npm install @commitlint/travis-cli -D
62+
- commitlint-travis
63+
# Define the release stage that runs semantic-release
64+
- stage: release
65+
language: node_js
66+
node_js: lts/*
67+
before_install: skip
68+
script:
69+
# Update `AUTHORS.md`
70+
- export MAINTAINER_TOKEN=${GH_TOKEN}
71+
- go get github.com/myii/maintainer
72+
- maintainer contributor
73+
74+
# Install all dependencies required for `semantic-release`
75+
- npm install @semantic-release/changelog@3 -D
76+
- npm install @semantic-release/exec@3 -D
77+
- npm install @semantic-release/git@7 -D
78+
deploy:
79+
provider: script
80+
skip_cleanup: true
81+
script:
82+
# Run `semantic-release`
83+
- npx semantic-release@15

Gemfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
source "https://rubygems.org"
2+
3+
gem 'kitchen-docker', '>= 2.9'
4+
gem 'kitchen-salt', '>= 0.6.0'
5+
gem 'kitchen-inspec', '>= 1.1'
6+

commitlint.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: ['@commitlint/config-conventional'],
3+
};

kitchen.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
4+
# For help on this file's format, see https://kitchen.ci/
5+
driver:
6+
name: docker
7+
use_sudo: false
8+
privileged: true
9+
run_command: /lib/systemd/systemd
10+
11+
# Make sure the platforms listed below match up with
12+
# the `env.matrix` instances defined in `.travis.yml`
13+
platforms:
14+
## SALT 2019.2
15+
- name: debian-9-2019-2-py3
16+
driver:
17+
image: netmanagers/salt-2019.2-py3:debian-9
18+
- name: ubuntu-1804-2019-2-py3
19+
driver:
20+
image: netmanagers/salt-2019.2-py3:ubuntu-18.04
21+
- name: centos-7-2019-2-py3
22+
driver:
23+
image: netmanagers/salt-2019.2-py3:centos-7
24+
- name: fedora-29-2019-2-py3
25+
driver:
26+
image: netmanagers/salt-2019.2-py3:fedora-29
27+
- name: opensuse-leap-15-2019-2-py3
28+
driver:
29+
image: netmanagers/salt-2019.2-py3:opensuse-leap-15
30+
run_command: /usr/lib/systemd/systemd
31+
32+
## SALT 2018.3
33+
- name: debian-9-2018-3-py2
34+
driver:
35+
image: netmanagers/salt-2018.3-py2:debian-9
36+
- name: ubuntu-1604-2018-3-py2
37+
driver:
38+
image: netmanagers/salt-2018.3-py2:ubuntu-16.04
39+
- name: centos-7-2018-3-py2
40+
driver:
41+
image: netmanagers/salt-2018.3-py2:centos-7
42+
- name: fedora-29-2018-3-py2
43+
driver:
44+
image: netmanagers/salt-2018.3-py2:fedora-29
45+
# TODO: Use this when fixed instead of `opensuse-leap-42`
46+
# Ref: https://github.com/netmanagers/salt-image-builder/issues/2
47+
# - name: opensuse-leap-15-2018-3-py2
48+
# driver:
49+
# image: netmanagers/salt-2018.3-py2:opensuse-leap-15
50+
# run_command: /usr/lib/systemd/systemd
51+
- name: opensuse-leap-42-2018-3-py2
52+
driver:
53+
image: netmanagers/salt-2018.3-py2:opensuse-leap-42
54+
run_command: /usr/lib/systemd/systemd
55+
56+
## SALT 2017.7
57+
- name: debian-8-2017-7-py2
58+
driver:
59+
image: netmanagers/salt-2017.7-py2:debian-8
60+
- name: ubuntu-1604-2017-7-py2
61+
driver:
62+
image: netmanagers/salt-2017.7-py2:ubuntu-16.04
63+
# TODO: Modify the formula to work for non-`systemd` platforms
64+
- name: centos-6-2017-7-py2
65+
driver:
66+
image: netmanagers/salt-2017.7-py2:centos-6
67+
run_command: /sbin/init
68+
- name: fedora-28-2017-7-py2
69+
driver:
70+
image: netmanagers/salt-2017.7-py2:fedora-28
71+
- name: opensuse-leap-42-2017-7-py2
72+
driver:
73+
image: netmanagers/salt-2017.7-py2:opensuse-leap-42
74+
run_command: /usr/lib/systemd/systemd
75+
76+
provisioner:
77+
name: salt_solo
78+
log_level: info
79+
salt_install: none
80+
require_chef: false
81+
formula: template
82+
salt_copy_filter:
83+
- .kitchen
84+
- .git
85+
state_top:
86+
base:
87+
'*':
88+
- template
89+
pillars:
90+
top.sls:
91+
base:
92+
'*':
93+
- openvpn
94+
pillars_from_files:
95+
openvpn.sls: test/config/pillars.sls
96+
97+
verifier:
98+
# https://www.inspec.io/
99+
name: inspec
100+
sudo: true
101+
# cli, documentation, html, progress, json, json-min, json-rspec, junit
102+
reporter:
103+
- cli
104+
inspec_tests:
105+
- path: test/integration/default
106+
107+
suites:
108+
- name: default

pillar.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
# # Info here: https://community.openvpn.net/openvpn/wiki/OpenvpnSoftwareRepos
2424
# # Valid options: stable (default), testing, release/2.3, release/2.4
2525

26+
See also the example used in tests: test/config/pillars.sls
2627

2728
##
2829
# OpenVPN user and group

release-rules.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// No release is triggered for the types commented out below.
2+
// Commits using these types will be incorporated into the next release.
3+
//
4+
// NOTE: Any changes here must be reflected in `CONTRIBUTING.md`.
5+
module.exports = [
6+
{breaking: true, release: 'major'},
7+
// {type: 'build', release: 'patch'},
8+
// {type: 'chore', release: 'patch'},
9+
// {type: 'ci', release: 'patch'},
10+
{type: 'docs', release: 'patch'},
11+
{type: 'feat', release: 'minor'},
12+
{type: 'fix', release: 'patch'},
13+
{type: 'perf', release: 'patch'},
14+
{type: 'refactor', release: 'patch'},
15+
{type: 'revert', release: 'patch'},
16+
{type: 'style', release: 'patch'},
17+
{type: 'test', release: 'patch'},
18+
];

release.config.js

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
module.exports = {
2+
branch: 'master',
3+
plugins: [
4+
['@semantic-release/commit-analyzer', {
5+
preset: 'angular',
6+
releaseRules: './release-rules.js',
7+
}],
8+
'@semantic-release/release-notes-generator',
9+
['@semantic-release/changelog', {
10+
changelogFile: 'CHANGELOG.md',
11+
changelogTitle: '# Changelog',
12+
}],
13+
['@semantic-release/exec', {
14+
prepareCmd: 'sh ./pre-commit_semantic-release.sh ${nextRelease.version}',
15+
}],
16+
['@semantic-release/git', {
17+
assets: ['*.md', 'docs/*.rst', 'FORMULA'],
18+
}],
19+
'@semantic-release/github',
20+
],
21+
generateNotes: {
22+
preset: 'angular',
23+
writerOpts: {
24+
// Required due to upstream bug preventing all types being displayed.
25+
// Bug: https://github.com/conventional-changelog/conventional-changelog/issues/317
26+
// Fix: https://github.com/conventional-changelog/conventional-changelog/pull/410
27+
transform: (commit, context) => {
28+
const issues = []
29+
30+
commit.notes.forEach(note => {
31+
note.title = `BREAKING CHANGES`
32+
})
33+
34+
// NOTE: Any changes here must be reflected in `CONTRIBUTING.md`.
35+
if (commit.type === `feat`) {
36+
commit.type = `Features`
37+
} else if (commit.type === `fix`) {
38+
commit.type = `Bug Fixes`
39+
} else if (commit.type === `perf`) {
40+
commit.type = `Performance Improvements`
41+
} else if (commit.type === `revert`) {
42+
commit.type = `Reverts`
43+
} else if (commit.type === `docs`) {
44+
commit.type = `Documentation`
45+
} else if (commit.type === `style`) {
46+
commit.type = `Styles`
47+
} else if (commit.type === `refactor`) {
48+
commit.type = `Code Refactoring`
49+
} else if (commit.type === `test`) {
50+
commit.type = `Tests`
51+
} else if (commit.type === `build`) {
52+
commit.type = `Build System`
53+
// } else if (commit.type === `chore`) {
54+
// commit.type = `Maintenance`
55+
} else if (commit.type === `ci`) {
56+
commit.type = `Continuous Integration`
57+
} else {
58+
return
59+
}
60+
61+
if (commit.scope === `*`) {
62+
commit.scope = ``
63+
}
64+
65+
if (typeof commit.hash === `string`) {
66+
commit.hash = commit.hash.substring(0, 7)
67+
}
68+
69+
if (typeof commit.subject === `string`) {
70+
let url = context.repository
71+
? `${context.host}/${context.owner}/${context.repository}`
72+
: context.repoUrl
73+
if (url) {
74+
url = `${url}/issues/`
75+
// Issue URLs.
76+
commit.subject = commit.subject.replace(/#([0-9]+)/g, (_, issue) => {
77+
issues.push(issue)
78+
return `[#${issue}](${url}${issue})`
79+
})
80+
}
81+
if (context.host) {
82+
// User URLs.
83+
commit.subject = commit.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (_, username) => {
84+
if (username.includes('/')) {
85+
return `@${username}`
86+
}
87+
88+
return `[@${username}](${context.host}/${username})`
89+
})
90+
}
91+
}
92+
93+
// remove references that already appear in the subject
94+
commit.references = commit.references.filter(reference => {
95+
if (issues.indexOf(reference.issue) === -1) {
96+
return true
97+
}
98+
99+
return false
100+
})
101+
102+
return commit
103+
},
104+
},
105+
},
106+
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
control 'OpenVPN configuration' do
2+
title 'should match desired lines'
3+
4+
describe file('/etc/openvpn.conf') do
5+
it { should be_file }
6+
it { should be_owned_by 'root' }
7+
it { should be_grouped_into 'root' }
8+
its('mode') { should cmp '0644' }
9+
its('content') { should include '# OpenVPN client configuration' }
10+
its('content') { should include '# Managed by Salt' }
11+
its('content') { should include 'user' }
12+
end
13+
end
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
control 'OpenVPN package' do
2+
title 'should be installed'
3+
4+
describe package('openvpn') do
5+
it { should be_installed }
6+
end
7+
end

0 commit comments

Comments
 (0)