Skip to content
This repository has been archived by the owner on May 20, 2020. It is now read-only.

Integration Test trial #53

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
1 change: 1 addition & 0 deletions .foodcritic
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
~FC057
68 changes: 68 additions & 0 deletions .kitchen.docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
driver:
name: dokken
chef_version: latest
privileged: true # because Docker and SystemD/Upstart

transport:
name: dokken

provisioner:
name: dokken

verifier:
name: inspec

platforms:
- name: centos-6
driver:
image: centos:6
platform: rhel
pid_one_command: /sbin/init
intermediate_instructions:
- RUN yum -y install which initscripts

- name: centos-7
driver:
image: centos:7
platform: rhel
pid_one_command: /usr/lib/systemd/systemd
intermediate_instructions:
- RUN yum -y install lsof which systemd-sysv initscripts

- name: ubuntu-14.04
driver:
image: ubuntu-upstart:14.04
pid_one_command: /sbin/init
intermediate_instructions:
- RUN /usr/bin/apt-get update

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

suites:
- name: default
driver:
vm_hostname: mongo3
run_list:
- recipe[mongodb3::default]
attributes:
chef_client:
config:
force_logger: true
log_level: info
build-essential:
compile_time: false
mongodb3:
mongod:
disable-transparent-hugepages: true
provisioner:
client_rb:
environment: dev
excludes:
- oel-6.6
- ami-2014.03

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do these 2 come from?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is not from me, it is from the original master

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you don't define then, there is no need for them here

52 changes: 42 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,47 @@
language: ruby
rvm:
- 2.1.0
bundler_args: --without integration
gemfile:
- Gemfile
# NOTE: we used ChefDK so we are not stick to which Ruby version.
sudo: required
dist: trusty

# install the pre-release chef-dk. Use chef-stable-trusty to install the stable release
addons:
apt:
sources:
- chef-current-trusty
packages:
- chefdk

# Don't `bundle install` which takes about 1.5 mins
install: echo "skip bundle install"

branches:
only:
- master
- develop

services: docker

env:
matrix:
- INSTANCE=default-centos-6
- INSTANCE=default-centos-7
- INSTANCE=default-ubuntu-1404
- INSTANCE=default-ubuntu-1604

before_script:
- bundle exec berks
script:
- bundle exec foodcritic .
- bundle exec rspec test/libraries
- sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER )
- eval "$(/opt/chefdk/bin/chef shell-init bash)"

script: KITCHEN_LOCAL_YAML=.kitchen.docker.yml /opt/chefdk/embedded/bin/kitchen verify ${INSTANCE}

# NOTE: we include a separate build for Unit test and Linter
# MIGHT NOT KNOW the purpose of `UNIT_AND_LINT=1`.
matrix:
include:
- before_script:
- eval "$(/opt/chefdk/bin/chef shell-init bash)"
- /opt/chefdk/embedded/bin/chef --version
- /opt/chefdk/embedded/bin/cookstyle --version
- /opt/chefdk/embedded/bin/foodcritic --version
- script:
- /opt/chefdk/bin/chef exec rake
env: UNIT_AND_LINT=1
13 changes: 13 additions & 0 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- This is a generated file. Please do not edit directly -->

# Maintainers

This file lists how this cookbook project is maintained. When making changes to the system, this file tells you who needs to review your patch - you need a review from an existing maintainer for the cookbook to provide a :+1: on your pull request. Additionally, you need to not receive a veto from a Lieutenant or the Project Lead.

Check out [How Cookbooks are Maintained](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD) for details on the process and how to become a maintainer or the project lead.

# Project Maintainer
* [Sunggun Yu](https://github.com/sunggun-yu)

# Maintainers
* [Sunggun Yu](https://github.com/sunggun-yu)
28 changes: 28 additions & 0 deletions MAINTAINERS.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# This file is structured to be consumed by both humans and computers.
# It is a TOML document containing Markdown
#
[Preamble]
title = "Maintainers"
text = """

This file lists how this cookbook project is maintained. When making changes to the system, this file tells you who needs to review your patch - you need a review from an existing maintainer for the cookbook to provide a :+1: on your pull request. Additionally, you need to not receive a veto from a Lieutenant or the Project Lead.

Check out [How Cookbooks are Maintained](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD) for details on the process and how to become a maintainer or the project lead.
"""

[Org]
[Org.Components]
[Org.Components.Core]
title = "Project Maintainer"

lieutenant = 'sunggun'

maintainers = [
'sunggun'
]

[people]
[people.sunggun]
name = "Sunggun Yu"
github = "sunggun-yu"
69 changes: 69 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env rake

require_relative 'tasks/maintainers'

# Style tests. cookstyle (rubocop) and Foodcritic
namespace :style do
begin
require 'cookstyle'
require 'rubocop/rake_task'

desc 'Run Ruby style checks'
RuboCop::RakeTask.new(:ruby)
rescue LoadError => e
puts ">>> Gem load error: #{e}, omitting style:ruby" unless ENV['CI']
end

begin
require 'foodcritic'

desc 'Run Chef style checks'
FoodCritic::Rake::LintTask.new(:chef) do |t|
t.options = {
fail_tags: ['any'],
progress: true
}
end
rescue LoadError
puts ">>> Gem load error: #{e}, omitting style:chef" unless ENV['CI']
end
end

desc 'Run all style checks'
task style: ['style:chef', 'style:ruby']

# ChefSpec
begin
require 'rspec/core/rake_task'

desc 'Run ChefSpec examples'
RSpec::Core::RakeTask.new(:spec)
rescue LoadError => e
puts ">>> Gem load error: #{e}, omitting spec" unless ENV['CI']
end

# Integration tests. Kitchen.ci
namespace :integration do
begin
require 'kitchen/rake_tasks'

desc 'Run kitchen integration tests'
Kitchen::RakeTasks.new
rescue StandardError => e
puts ">>> Kitchen error: #{e}, omitting #{task.name}" unless ENV['CI']
end
end

namespace :supermarket do
begin
require 'stove/rake_task'

desc 'Publish cookbook to Supermarket with Stove'
Stove::RakeTask.new
rescue LoadError => e
puts ">>> Gem load error: #{e}, omitting #{task.name}" unless ENV['CI']
end
end

# Default
task default: %w(style spec)
3 changes: 3 additions & 0 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@
depends 'yum'
depends 'user'
depends 'runit', '~> 1.7.0'

source_url 'https://github.com/sunggun-yu/chef-mongodb3/issues'
issues_url 'https://github.com/sunggun-yu/chef-mongodb3'
76 changes: 76 additions & 0 deletions tasks/maintainers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#
# Copyright:: Copyright (c) 2015-2016 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require 'rake'

SOURCE = File.join(File.dirname(__FILE__), '..', 'MAINTAINERS.toml')
TARGET = File.join(File.dirname(__FILE__), '..', 'MAINTAINERS.md')

begin
require 'tomlrb'
task default: 'maintainers:generate'

namespace :maintainers do
desc 'Generate MarkDown version of MAINTAINERS file'
task :generate do
@toml = Tomlrb.load_file SOURCE
out = "<!-- This is a generated file. Please do not edit directly -->\n\n"

out << preamble
out << project_lieutenant
out << all_maintainers

File.open(TARGET, 'w') do |fn|
fn.write out
end
end
end

rescue LoadError
STDERR.puts "\n*** TomlRb not available. Skipping the Maintainers Rake task\n\n"
end

private

def preamble
<<-EOL
# #{@toml['Preamble']['title']}
#{@toml['Preamble']['text']}
EOL
end

def project_lieutenant
<<-EOL
# #{@toml['Org']['Components']['Core']['title']}
#{github_link(@toml['Org']['Components']['Core']['lieutenant'])}

EOL
end

def all_maintainers
text = "# Maintainers\n"
@toml['Org']['Components']['Core']['maintainers'].each do |m|
text << "#{github_link(m)}\n"
end
text
end

def github_link(person)
name = @toml['people'][person]['name']
github = @toml['people'][person]['github']
"* [#{name}](https://github.com/#{github})"
end