diff --git a/.foodcritic b/.foodcritic new file mode 100644 index 0000000..cf9e43e --- /dev/null +++ b/.foodcritic @@ -0,0 +1 @@ +~FC057 diff --git a/.kitchen.docker.yml b/.kitchen.docker.yml new file mode 100644 index 0000000..e6d5e80 --- /dev/null +++ b/.kitchen.docker.yml @@ -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 diff --git a/.travis.yml b/.travis.yml index 9de479f..a9930c4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/MAINTAINERS.md b/MAINTAINERS.md new file mode 100644 index 0000000..d20421d --- /dev/null +++ b/MAINTAINERS.md @@ -0,0 +1,13 @@ + + +# 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) diff --git a/MAINTAINERS.toml b/MAINTAINERS.toml new file mode 100644 index 0000000..27c980e --- /dev/null +++ b/MAINTAINERS.toml @@ -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" diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..293ccde --- /dev/null +++ b/Rakefile @@ -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) diff --git a/metadata.rb b/metadata.rb index 88556e1..e09d00f 100644 --- a/metadata.rb +++ b/metadata.rb @@ -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' diff --git a/tasks/maintainers.rb b/tasks/maintainers.rb new file mode 100644 index 0000000..1ce3302 --- /dev/null +++ b/tasks/maintainers.rb @@ -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 = "\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