Skip to content

Commit

Permalink
Update cookbook to sous-chefs standards
Browse files Browse the repository at this point in the history
  • Loading branch information
damacus committed Oct 5, 2018
1 parent b980045 commit 9802760
Show file tree
Hide file tree
Showing 15 changed files with 161 additions and 109 deletions.
14 changes: 14 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2.1

orbs:
kitchen: sous-chefs/kitchen@1.0.0

workflows:
kitchen:
jobs:
- kitchen/lint:
name: lint
- kitchen/dokken:
name: default
suite: default
requires: [ lint ]
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.rbc
.config
.envrc
coverage
InstalledFiles
lib/bundler/man
Expand Down Expand Up @@ -34,15 +35,18 @@ _yardoc
doc/
.idea

#chef stuff
# chef stuff
Berksfile.lock
.kitchen
.kitchen.local.yml
vendor/
.coverage/
.zero-knife.rb
Policyfile.lock.json
Cheffile.lock
.librarian/

#vagrant stuff
# vagrant stuff
.vagrant/
.vagrant.d/
.kitchen/
68 changes: 68 additions & 0 deletions .kitchen.dokken.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
driver:
name: dokken
privileged: true # because Docker and SystemD/Upstart
chef_version: <%= ENV['CHEF_VERSION'] || "current" %>

transport:
name: dokken

provisioner:
name: dokken
deprecations_as_errors: true

verifier:
name: inspec

platforms:
- name: debian-8
driver:
image: dokken/debian-8
pid_one_command: /sbin/init
intermediate_instructions:
- RUN /usr/bin/apt-get update
- RUN /usr/bin/apt-get install sudo -y

- name: debian-9
driver:
image: dokken/debian-9
pid_one_command: /bin/systemd
intermediate_instructions:
- RUN /usr/bin/apt-get update
- RUN /usr/bin/apt-get install sudo -y

- name: centos-6
driver:
image: dokken/centos-6
pid_one_command: /sbin/init
intermediate_instructions:
- RUN yum -y install sudo

- name: centos-7
driver:
image: dokken/centos-7
pid_one_command: /usr/lib/systemd/systemd
intermediate_instructions:
- RUN yum -y install sudo

- name: fedora-latest
driver:
image: dokken/fedora-latest
pid_one_command: /usr/lib/systemd/systemd
intermediate_instructions:
- RUN dnf -y install sudo

- name: ubuntu-16.04
driver:
image: dokken/ubuntu-16.04
pid_one_command: /bin/systemd
intermediate_instructions:
- RUN /usr/bin/apt-get update
- RUN /usr/bin/apt-get install sudo -y

- name: ubuntu-18.04
driver:
image: dokken/ubuntu-18.04
pid_one_command: /bin/systemd
intermediate_instructions:
- RUN /usr/bin/apt-get update
- RUN /usr/bin/apt-get install sudo -y
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
AllCops:
Exclude:
- 'Dangerfile'
7 changes: 7 additions & 0 deletions Berksfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
source 'https://supermarket.chef.io'

metadata

group :integration do
cookbook 'test', path: 'test/fixtures/cookbooks/test'
end
40 changes: 40 additions & 0 deletions Dangerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Reference: http://danger.systems/reference.html

# A pull request summary is required. Add a description of the pull request purpose.
# Add labels to the pull request in github to identify the type of change. https://help.github.com/articles/applying-labels-to-issues-and-pull-requests/
# Changelog must be updated for each pull request.
# Warnings will be issued for:
# Pull request with more than 400 lines of code changed
# Pull reqest that change more than 5 lines without test changes

def code_changes?
code = %w(libraries attributes recipes resources)
code.each do |location|
return true unless git.modified_files.grep(/#{location}/).empty?
end
false
end

def test_changes?
tests = %w(spec test .kitchen.yml .kitchen.dokken.yml)
tests.each do |location|
return true unless git.modified_files.grep(/#{location}/).empty?
end
false
end

fail 'Please provide a summary of your Pull Request.' if github.pr_body.length < 10

fail 'Please add labels to this Pull Request' if github.pr_labels.empty?

warn 'This is a big Pull Request.' if git.lines_of_code > 400

# Require a CHANGELOG entry for non-test changes.
if !git.modified_files.include?('CHANGELOG.md') && code_changes?
fail 'Please include a [CHANGELOG](https://github.com/sous-chefs/line-cookbook/blob/master/CHANGELOG.md) entry.'
end

# A sanity check for tests.
if git.lines_of_code > 5 && code_changes? && !test_changes?
warn 'This Pull Request is probably missing tests.'
end
93 changes: 0 additions & 93 deletions libraries/matchers.rb

This file was deleted.

File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions test/fixtures/cookbooks/test/metadata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name 'test'
version '0.99.0'

depends 'ruby_rbenv'
5 changes: 0 additions & 5 deletions test/integration/default/bats/aptly_install.bats

This file was deleted.

10 changes: 10 additions & 0 deletions test/integration/default/controls/default_install.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

control 'Aptly should be installed' do
title 'Should install the Aply binary'

desc 'Aplty binary'
describe command('aptly') do
it { should exist }
end
end
9 changes: 0 additions & 9 deletions test/integration/default/cookbooks/aptly_test/metadata.rb

This file was deleted.

9 changes: 9 additions & 0 deletions test/integration/default/inspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: rbenv
title: rbenv profile
maintainer: Sous Chefs
copyright: Webb Agile Solutions Ltd.
license: Apache-2.0
summary: Verifies gems install correctly to the correct Ruby versions
version: 1.0.0
supports:
- os-family: linux

0 comments on commit 9802760

Please sign in to comment.