Skip to content

Commit 3fa2a58

Browse files
committed
ci(kitchen+travis): update testing environment
* Use latest pre-salted images * Move from serverspec to inspec * Fix failing tests
1 parent 29c8a43 commit 3fa2a58

File tree

12 files changed

+244
-93
lines changed

12 files changed

+244
-93
lines changed

.kitchen.yml

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

.travis.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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: repositories-debian-9-2019-2-py3
30+
- INSTANCE: repositories-ubuntu-1804-2019-2-py3
31+
- INSTANCE: preferences-debian-9-2019-2-py3
32+
- INSTANCE: preferences-ubuntu-1804-2019-2-py3
33+
34+
script:
35+
- bundle exec kitchen verify ${INSTANCE}
36+
37+
jobs:
38+
include:
39+
# Define the commitlint stage
40+
- stage: commitlint
41+
language: node_js
42+
node_js: lts/*
43+
before_install: skip
44+
script:
45+
- npm install @commitlint/config-conventional -D
46+
- npm install @commitlint/travis-cli -D
47+
- commitlint-travis
48+
# Define the release stage that runs semantic-release
49+
- stage: release
50+
language: node_js
51+
node_js: lts/*
52+
before_install: skip
53+
script:
54+
# Update `AUTHORS.md`
55+
- export MAINTAINER_TOKEN=${GH_TOKEN}
56+
- go get github.com/myii/maintainer
57+
- maintainer contributor
58+
59+
# Install all dependencies required for `semantic-release`
60+
- npm install @semantic-release/changelog@3 -D
61+
- npm install @semantic-release/exec@3 -D
62+
- npm install @semantic-release/git@7 -D
63+
deploy:
64+
provider: script
65+
skip_cleanup: true
66+
script:
67+
# Run `semantic-release`
68+
- 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+

kitchen.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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+
- name: debian-9-2019-2-py3
15+
driver:
16+
image: netmanagers/salt-2019.2-py3:debian-9
17+
- name: ubuntu-1804-2019-2-py3
18+
driver:
19+
image: netmanagers/salt-2019.2-py3:ubuntu-18.04
20+
21+
provisioner:
22+
name: salt_solo
23+
log_level: info
24+
salt_install: none
25+
require_chef: false
26+
formula: apt
27+
salt_copy_filter:
28+
- .kitchen
29+
- .git
30+
pillars:
31+
top.sls:
32+
base:
33+
'*':
34+
- apt
35+
36+
verifier:
37+
# https://www.inspec.io/
38+
name: inspec
39+
sudo: true
40+
# cli, documentation, html, progress, json, json-min, json-rspec, junit
41+
reporter:
42+
- cli
43+
44+
suites:
45+
- name: repositories
46+
provisioner:
47+
state_top:
48+
base:
49+
'*':
50+
- apt.repositories
51+
- apt.update
52+
pillars_from_files:
53+
apt.sls: test/salt/pillar/repositories.pillar.sls
54+
verifier:
55+
inspec_tests:
56+
- path: test/integration/repositories
57+
- name: preferences
58+
provisioner:
59+
state_top:
60+
base:
61+
'*':
62+
- apt.preferences
63+
pillars_from_files:
64+
apt.sls: test/salt/pillar/preferences.pillar.sls
65+
verifier:
66+
inspec_tests:
67+
- path: test/integration/preferences
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,47 @@
1-
require_relative '../../../kitchen/data/spec_helper'
2-
3-
describe 'apt.preferences' do
1+
control 'Apt preferences' do
2+
title 'should be configured'
43

54
describe file('/etc/apt/preferences') do
6-
it { should_not exist }
5+
it { should exist }
6+
its(:size) { should eq 0 }
77
end
88

99
describe file('/etc/apt/preferences.d') do
1010
it { should be_directory }
11-
it { should be_mode 755 }
1211
it { should be_owned_by 'root' }
1312
it { should be_grouped_into 'root' }
13+
its('mode') { should cmp '0755' }
1414
end
1515

1616
describe file('/etc/apt/preferences.d/00-rspamd') do
1717
it { should exist }
18-
it { should be_mode 644 }
1918
it { should be_owned_by 'root' }
2019
it { should be_grouped_into 'root' }
20+
its('mode') { should cmp '0644' }
2121
its(:content) { should match("Package: rspamd\nPin: origin rspamd.com\nPin-Priority: 650\n") }
2222
end
2323

2424
describe file('/etc/apt/preferences.d/01-all') do
2525
it { should exist }
26-
it { should be_mode 644 }
2726
it { should be_owned_by 'root' }
2827
it { should be_grouped_into 'root' }
28+
its('mode') { should cmp '0644' }
2929
its(:content) { should match("Package: *\nPin: release stable\nPin-Priority: 610\n") }
3030
end
3131

3232
describe file('/etc/apt/preferences.d/02-all') do
3333
it { should exist }
34-
it { should be_mode 644 }
3534
it { should be_owned_by 'root' }
3635
it { should be_grouped_into 'root' }
36+
its('mode') { should cmp '0644' }
3737
its(:content) { should match("Package: *\nPin: release testing\nPin-Priority: 600\n") }
3838
end
3939

4040
describe file('/etc/apt/preferences.d/03-all') do
4141
it { should exist }
42-
it { should be_mode 644 }
4342
it { should be_owned_by 'root' }
4443
it { should be_grouped_into 'root' }
44+
its('mode') { should cmp '0644' }
4545
its(:content) { should match("Package: *\nPin: release unstable\nPin-Priority: 50\n") }
4646
end
47-
4847
end
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: preferences
2+
title: Apt Formula
3+
maintainer: Saltstack-formulas org
4+
license: Apache-2.0
5+
summary: Verify that the apt preferences are configured correctly
6+
supports:
7+
- os-name: debian
8+
- os-name: ubuntu
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
control 'Apt repositories' do
2+
title 'should be configured'
3+
4+
if os[:name] == 'ubuntu'
5+
keyring_package = 'ubuntu-keyring'
6+
else
7+
keyring_package = 'debian-archive-keyring'
8+
end
9+
10+
describe package(keyring_package) do
11+
it { should be_installed }
12+
end
13+
14+
describe file('/etc/apt/sources.list') do
15+
it { should exist }
16+
its(:size) { should eq 0 }
17+
end
18+
19+
describe file('/etc/apt/sources.list.d') do
20+
it { should be_directory }
21+
it { should be_owned_by 'root' }
22+
it { should be_grouped_into 'root' }
23+
its('mode') { should cmp '0755' }
24+
end
25+
26+
describe file('/etc/apt/sources.list.d/spotify-binary.list') do
27+
it { should exist }
28+
it { should be_owned_by 'root' }
29+
it { should be_grouped_into 'root' }
30+
its('mode') { should cmp '0644' }
31+
its(:content) { should match(%r{deb \[arch=amd64\] http://repository.spotify.com stable non-free}) }
32+
end
33+
34+
describe file('/etc/apt/sources.list.d/heroku-binary.list') do
35+
it { should exist }
36+
it { should be_owned_by 'root' }
37+
it { should be_grouped_into 'root' }
38+
its('mode') { should cmp '0644' }
39+
its(:content) { should match(%r{deb \[arch=amd64\] https://cli-assets.heroku.com/apt ./}) }
40+
end
41+
end
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: repositories
2+
title: Apt Formula
3+
maintainer: Saltstack-formulas org
4+
license: Apache-2.0
5+
summary: Verify that the apt repositories are configured correctly
6+
supports:
7+
- os-name: debian
8+
- os-name: ubuntu

test/integration/repositories/serverspec/repositories_spec.rb

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apt:
2+
remove_preferences: true
3+
clean_preferences_d: true
4+
5+
preferences:
6+
00-rspamd:
7+
package: rspamd
8+
pin: origin rspamd.com
9+
priority: 650
10+
01-all:
11+
pin: release stable
12+
priority: 610
13+
02-all:
14+
pin: release testing
15+
priority: 600
16+
03-all:
17+
pin: release unstable
18+
priority: 50
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apt:
2+
remove_sources_list: true
3+
clean_sources_list_d: true
4+
5+
repositories:
6+
spotify:
7+
distro: stable
8+
url: http://repository.spotify.com
9+
arch: [amd64]
10+
comps: [non-free]
11+
keyid: 931FF8E79F0876134EDDBDCCA87FF9DF48BF1C90
12+
keyserver: keyserver.ubuntu.com
13+
heroku:
14+
distro: ./
15+
url: https://cli-assets.heroku.com/apt
16+
arch: [amd64]
17+
comps: []
18+
key_url: https://cli-assets.heroku.com/apt/release.key
19+

test/shared/spec_helper.rb

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

0 commit comments

Comments
 (0)