diff --git a/Dangerfile b/Dangerfile new file mode 100644 index 0000000..2cb0d6b --- /dev/null +++ b/Dangerfile @@ -0,0 +1,32 @@ +# Sometimes it's a README fix, or something like that - which isn't relevant for +# including in a project's CHANGELOG for example +declared_trivial = github.pr_title.include? "#trivial" + +# Make it more obvious that a PR is a work in progress and shouldn't be merged yet +warn("PR is classed as Work in Progress") if github.pr_title.include? "[WIP]" + +# Warn when there is a big PR +warn("Big PR") if git.lines_of_code > 500 + +# if git.lines_of_code > 3 && !git.modified_files.include?("CHANGELOG.yml") +if !git.modified_files.include?("CHANGELOG.yml") && !declared_trivial + repo_url = github.pr_json['head']['repo']['html_url'] + pr_title = github.pr_title + pr_title += '.' unless pr_title.end_with?('.') + pr_number = github.pr_json['number'] + pr_url = github.pr_json['html_url'] + pr_author = github.pr_author + pr_author_url = "https://github.com/#{pr_author}" + + fail("Please include a CHANGELOG entry. \nYou can find it at [CHANGELOG.md](#{repo_url}/blob/master/CHANGELOG.md).") + changelog_msg = <<-CHANGELOG_FORMAT.gsub(/^ *\|/,'') + |Note: we use the following format for CHANGELOG entries: + |``` + | * #{pr_title} + | [##{pr_number}](#{pr_url}) + | [@#{pr_author}](#{pr_author_url}) + |``` + |:bulb: Don't forget to use 2 spaces after the full stop at the end of the line describing your changes. + CHANGELOG_FORMAT + markdown(changelog_msg) +end diff --git a/Gemfile b/Gemfile index 42481de..9120c2e 100644 --- a/Gemfile +++ b/Gemfile @@ -2,4 +2,5 @@ source 'https://rubygems.org' gem 'cocoapods', '1.2.1' +gem 'danger' gem 'xcpretty' diff --git a/Gemfile.lock b/Gemfile.lock index b788395..744fe7d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,7 +7,13 @@ GEM minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) + addressable (2.5.1) + public_suffix (~> 2.0, >= 2.0.2) claide (1.0.1) + claide-plugins (0.9.2) + cork + nap + open4 (~> 1.3) cocoapods (1.2.1) activesupport (>= 4.0.2, < 5) claide (>= 1.0.1, < 2.0) @@ -42,21 +48,51 @@ GEM netrc (= 0.7.8) cocoapods-try (1.1.0) colored2 (3.1.2) + cork (0.3.0) + colored2 (~> 3.1) + danger (5.1.0) + claide (~> 1.0) + claide-plugins (>= 0.9.2) + colored2 (~> 3.1) + cork (~> 0.1) + faraday (~> 0.9) + faraday-http-cache (~> 1.0) + git (~> 1) + kramdown (~> 1.5) + octokit (~> 4.2) + terminal-table (~> 1) escape (0.0.4) + faraday (0.12.1) + multipart-post (>= 1.2, < 3) + faraday-http-cache (1.3.1) + faraday (~> 0.8) fourflusher (2.0.1) fuzzy_match (2.0.4) gh_inspector (1.0.3) + git (1.3.0) i18n (0.8.1) + kramdown (1.13.2) minitest (5.10.1) molinillo (0.5.7) + multipart-post (2.0.0) nanaimo (0.2.3) nap (1.1.0) netrc (0.7.8) + octokit (4.7.0) + sawyer (~> 0.8.0, >= 0.5.3) + open4 (1.3.4) + public_suffix (2.0.5) rouge (1.11.1) ruby-macho (1.1.0) + sawyer (0.8.1) + addressable (>= 2.3.5, < 2.6) + faraday (~> 0.8, < 1.0) + terminal-table (1.7.3) + unicode-display_width (~> 1.1.1) thread_safe (0.3.6) tzinfo (1.2.3) thread_safe (~> 0.1) + unicode-display_width (1.1.3) xcodeproj (1.4.4) CFPropertyList (~> 2.3.3) claide (>= 1.0.1, < 2.0) @@ -70,6 +106,7 @@ PLATFORMS DEPENDENCIES cocoapods (= 1.2.1) + danger xcpretty BUNDLED WITH diff --git a/circle.yml b/circle.yml index 859fab7..d45aa43 100644 --- a/circle.yml +++ b/circle.yml @@ -7,6 +7,8 @@ dependencies: - rake lint:install test: + pre: + - bundle exec danger override: - rake lint:tests - rake xcode:test