Skip to content

Commit

Permalink
ci(kitchen+travis): update testing environment
Browse files Browse the repository at this point in the history
* Use latest pre-salted images
* Move from serverspec to inspec
* Fix failing tests
  • Loading branch information
javierbertoli committed May 27, 2019
1 parent 29c8a43 commit 3fa2a58
Show file tree
Hide file tree
Showing 12 changed files with 244 additions and 93 deletions.
38 changes: 0 additions & 38 deletions .kitchen.yml

This file was deleted.

68 changes: 68 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
stages:
- test
- commitlint
- name: release
if: branch = master AND type != pull_request

sudo: required
cache: bundler
language: ruby

services:
- docker

# Make sure the instances listed below match up with
# the `platforms` defined in `kitchen.yml`
# NOTE: Please try to select up to six instances that add some meaningful
# testing of the formula's behaviour. If possible, try to refrain from
# the classical "chosing all the instances because I want to test on
# another/all distro/s" trap: it will just add time to the testing (see
# the discussion on #121). As an example, the set chosen below covers
# the most used distros families, systemd and non-systemd and the latest
# three supported Saltstack versions with python2 and 3."
# As for `kitchen.yml`, that should still contain all of the platforms,
# to allow for comprehensive local testing
# Ref: https://github.com/saltstack-formulas/template-formula/issues/118
# Ref: https://github.com/saltstack-formulas/template-formula/issues/121
env:
matrix:
- INSTANCE: repositories-debian-9-2019-2-py3
- INSTANCE: repositories-ubuntu-1804-2019-2-py3
- INSTANCE: preferences-debian-9-2019-2-py3
- INSTANCE: preferences-ubuntu-1804-2019-2-py3

script:
- bundle exec kitchen verify ${INSTANCE}

jobs:
include:
# Define the commitlint stage
- stage: commitlint
language: node_js
node_js: lts/*
before_install: skip
script:
- npm install @commitlint/config-conventional -D
- npm install @commitlint/travis-cli -D
- commitlint-travis
# Define the release stage that runs semantic-release
- stage: release
language: node_js
node_js: lts/*
before_install: skip
script:
# Update `AUTHORS.md`
- export MAINTAINER_TOKEN=${GH_TOKEN}
- go get github.com/myii/maintainer
- maintainer contributor

# Install all dependencies required for `semantic-release`
- npm install @semantic-release/changelog@3 -D
- npm install @semantic-release/exec@3 -D
- npm install @semantic-release/git@7 -D
deploy:
provider: script
skip_cleanup: true
script:
# Run `semantic-release`
- npx semantic-release@15
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source "https://rubygems.org"

gem 'kitchen-docker', '>= 2.9'
gem 'kitchen-salt', '>= 0.6.0'
gem 'kitchen-inspec', '>= 1.1'

67 changes: 67 additions & 0 deletions kitchen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
# For help on this file's format, see https://kitchen.ci/
driver:
name: docker
use_sudo: false
privileged: true
run_command: /lib/systemd/systemd

# Make sure the platforms listed below match up with
# the `env.matrix` instances defined in `.travis.yml`
platforms:
- name: debian-9-2019-2-py3
driver:
image: netmanagers/salt-2019.2-py3:debian-9
- name: ubuntu-1804-2019-2-py3
driver:
image: netmanagers/salt-2019.2-py3:ubuntu-18.04

provisioner:
name: salt_solo
log_level: info
salt_install: none
require_chef: false
formula: apt
salt_copy_filter:
- .kitchen
- .git
pillars:
top.sls:
base:
'*':
- apt

verifier:
# https://www.inspec.io/
name: inspec
sudo: true
# cli, documentation, html, progress, json, json-min, json-rspec, junit
reporter:
- cli

suites:
- name: repositories
provisioner:
state_top:
base:
'*':
- apt.repositories
- apt.update
pillars_from_files:
apt.sls: test/salt/pillar/repositories.pillar.sls
verifier:
inspec_tests:
- path: test/integration/repositories
- name: preferences
provisioner:
state_top:
base:
'*':
- apt.preferences
pillars_from_files:
apt.sls: test/salt/pillar/preferences.pillar.sls
verifier:
inspec_tests:
- path: test/integration/preferences
Original file line number Diff line number Diff line change
@@ -1,48 +1,47 @@
require_relative '../../../kitchen/data/spec_helper'

describe 'apt.preferences' do
control 'Apt preferences' do
title 'should be configured'

describe file('/etc/apt/preferences') do
it { should_not exist }
it { should exist }
its(:size) { should eq 0 }
end

describe file('/etc/apt/preferences.d') do
it { should be_directory }
it { should be_mode 755 }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its('mode') { should cmp '0755' }
end

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

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

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

describe file('/etc/apt/preferences.d/03-all') do
it { should exist }
it { should be_mode 644 }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its('mode') { should cmp '0644' }
its(:content) { should match("Package: *\nPin: release unstable\nPin-Priority: 50\n") }
end

end
8 changes: 8 additions & 0 deletions test/integration/preferences/inspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: preferences
title: Apt Formula
maintainer: Saltstack-formulas org
license: Apache-2.0
summary: Verify that the apt preferences are configured correctly
supports:
- os-name: debian
- os-name: ubuntu
41 changes: 41 additions & 0 deletions test/integration/repositories/controls/repositories_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
control 'Apt repositories' do
title 'should be configured'

if os[:name] == 'ubuntu'
keyring_package = 'ubuntu-keyring'
else
keyring_package = 'debian-archive-keyring'
end

describe package(keyring_package) do
it { should be_installed }
end

describe file('/etc/apt/sources.list') do
it { should exist }
its(:size) { should eq 0 }
end

describe file('/etc/apt/sources.list.d') do
it { should be_directory }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its('mode') { should cmp '0755' }
end

describe file('/etc/apt/sources.list.d/spotify-binary.list') do
it { should exist }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its('mode') { should cmp '0644' }
its(:content) { should match(%r{deb \[arch=amd64\] http://repository.spotify.com stable non-free}) }
end

describe file('/etc/apt/sources.list.d/heroku-binary.list') do
it { should exist }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its('mode') { should cmp '0644' }
its(:content) { should match(%r{deb \[arch=amd64\] https://cli-assets.heroku.com/apt ./}) }
end
end
8 changes: 8 additions & 0 deletions test/integration/repositories/inspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: repositories
title: Apt Formula
maintainer: Saltstack-formulas org
license: Apache-2.0
summary: Verify that the apt repositories are configured correctly
supports:
- os-name: debian
- os-name: ubuntu
36 changes: 0 additions & 36 deletions test/integration/repositories/serverspec/repositories_spec.rb

This file was deleted.

18 changes: 18 additions & 0 deletions test/salt/pillar/preferences.pillar.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apt:
remove_preferences: true
clean_preferences_d: true

preferences:
00-rspamd:
package: rspamd
pin: origin rspamd.com
priority: 650
01-all:
pin: release stable
priority: 610
02-all:
pin: release testing
priority: 600
03-all:
pin: release unstable
priority: 50
19 changes: 19 additions & 0 deletions test/salt/pillar/repositories.pillar.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apt:
remove_sources_list: true
clean_sources_list_d: true

repositories:
spotify:
distro: stable
url: http://repository.spotify.com
arch: [amd64]
comps: [non-free]
keyid: 931FF8E79F0876134EDDBDCCA87FF9DF48BF1C90
keyserver: keyserver.ubuntu.com
heroku:
distro: ./
url: https://cli-assets.heroku.com/apt
arch: [amd64]
comps: []
key_url: https://cli-assets.heroku.com/apt/release.key

9 changes: 0 additions & 9 deletions test/shared/spec_helper.rb

This file was deleted.

0 comments on commit 3fa2a58

Please sign in to comment.