Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dangerfile and CircleCI config #539

Merged
merged 2 commits into from
Jul 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: 2
jobs:
build:
docker:
- image: circleci/ruby:2.5.1-browsers

working_directory: ~/repo

steps:
- checkout
- run:
name: Install Danger
command: gem install danger
- run:
name: Run Danger
command: danger

workflows:
version: 2
danger-flow:
jobs:
- build:
context: Danger
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This file is used to list changes made in each version of the apache2 cookbook.
## v6.0.0 (tbc)

- Drop Chef 12 support
- Add Danger and CircleCI support

## v5.0.1 (2017-09-01)

Expand Down
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
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

source 'https://rubygems.org'

gem 'stove'
gem 'danger'