From 388ef14ddfd5ff685560d5e3c98714df2c07f7ae Mon Sep 17 00:00:00 2001 From: Andrea Bizzotto Date: Thu, 18 May 2017 16:02:32 +0100 Subject: [PATCH 1/5] Add Dangerfile and make it run on CI --- .travis.yml | 1 + Dangerfile | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 Dangerfile diff --git a/.travis.yml b/.travis.yml index 4323d077..7267bdf2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,3 +9,4 @@ install: script: - swiftlint - ./scripts/build.sh + - bundle exec danger diff --git a/Dangerfile b/Dangerfile new file mode 100644 index 00000000..fa0026e6 --- /dev/null +++ b/Dangerfile @@ -0,0 +1,17 @@ +## Let's check if there are any changes in the project folder +has_app_changes = !git.modified_files.grep(/SwiftyStoreKit/).empty? + +## Then, we should check if tests are updated +has_test_changes = !git.modified_files.grep(/SwiftyStoreKitTests/).empty? + +# 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 + +## Finally, let's combine them and put extra condition +## for changed number of lines of code +if has_app_changes && !has_test_changes && git.lines_of_code > 20 + fail("Tests were not updated", sticky: false) +end From 92d3eec76213d7140fce42856a9dc35a6855ab57 Mon Sep 17 00:00:00 2001 From: Andrea Bizzotto Date: Thu, 18 May 2017 16:18:36 +0100 Subject: [PATCH 2/5] Add Gemfile (required by Danger) --- Gemfile | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Gemfile diff --git a/Gemfile b/Gemfile new file mode 100644 index 00000000..c9c92bd2 --- /dev/null +++ b/Gemfile @@ -0,0 +1,3 @@ +source 'https://rubygems.org' + +gem 'danger' From fb3dcbcf291d233ee6283190fbe441072bcdd98d Mon Sep 17 00:00:00 2001 From: Andrea Bizzotto Date: Thu, 18 May 2017 16:18:50 +0100 Subject: [PATCH 3/5] Update Dangerfile --- Dangerfile | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Dangerfile b/Dangerfile index fa0026e6..87d94f5b 100644 --- a/Dangerfile +++ b/Dangerfile @@ -1,8 +1,8 @@ -## Let's check if there are any changes in the project folder -has_app_changes = !git.modified_files.grep(/SwiftyStoreKit/).empty? +# Ensure there is a summary for a pull request +fail 'Please provide a summary in the Pull Request description' if github.pr_body.length < 5 -## Then, we should check if tests are updated -has_test_changes = !git.modified_files.grep(/SwiftyStoreKitTests/).empty? +# Warn about develop branch +warn("Please target PRs to `develop` branch") if github.branch_for_base != "develop" # 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]" @@ -10,6 +10,12 @@ 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 +## Let's check if there are any changes in the project folder +has_app_changes = !git.modified_files.grep(/SwiftyStoreKit/).empty? + +## Then, we should check if tests are updated +has_test_changes = !git.modified_files.grep(/SwiftyStoreKitTests/).empty? + ## Finally, let's combine them and put extra condition ## for changed number of lines of code if has_app_changes && !has_test_changes && git.lines_of_code > 20 From 0e50adf50f7208c874f0332a4357591eea84d378 Mon Sep 17 00:00:00 2001 From: Andrea Bizzotto Date: Thu, 18 May 2017 16:40:34 +0100 Subject: [PATCH 4/5] Add installation step to install Danger --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7267bdf2..4ee4be34 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,9 @@ osx_image: xcode8.3 install: - ./scripts/install_swiftlint.sh + - bundle install --path vendor/bundle script: - swiftlint - ./scripts/build.sh - - bundle exec danger + - bundle exec danger --verbose From 93ef99c09334eae2d07a2ceff4d60cf6290a3807 Mon Sep 17 00:00:00 2001 From: Andrea Bizzotto Date: Thu, 18 May 2017 16:40:56 +0100 Subject: [PATCH 5/5] Update Dangerfile --- Dangerfile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Dangerfile b/Dangerfile index 87d94f5b..0e45c35d 100644 --- a/Dangerfile +++ b/Dangerfile @@ -4,9 +4,16 @@ fail 'Please provide a summary in the Pull Request description' if github.pr_bod # Warn about develop branch warn("Please target PRs to `develop` branch") if github.branch_for_base != "develop" +# 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 no CHANGELOG +warn("No CHANGELOG changes made") if git.lines_of_code > 50 && !git.modified_files.include?("CHANGELOG.md") && !declared_trivial + # Warn when there is a big PR warn("Big PR") if git.lines_of_code > 500