Skip to content

Commit

Permalink
Merge pull request Quick#634 from wongzigii/danger-bot
Browse files Browse the repository at this point in the history
Bot for Quick
  • Loading branch information
jeffh authored Jan 10, 2017
2 parents a303e26 + fd344ef commit ccb3cc6
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 26 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ install:
script:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./script/travis-script-macos; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./script/travis-script-linux; fi
- if [[ "$PODSPEC" ]]; then danger; fi
53 changes: 53 additions & 0 deletions Dangerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# set the number of lines that must be changed before this classifies as a 'Big PR'
@SDM_DANGER_BIG_PR_LINES = 50

# set the files to watch and fail if there are changes
@SDM_DANGER_IMMUTABLE_FILES = ['LICENSE', 'CONTRIBUTING.md', 'CODE_OF_CONDUCT.md']

# Sometimes it's a README fix, or something like that which is trivial
not_declared_trivial = !(github.pr_title.include? "#trivial")
has_app_changes = !git.modified_files.grep(/Sources/).empty?
no_test_modify = git.modified_files.grep(/Tests/).empty?

# Warns when changing source files
if has_app_changes && not_declared_trivial && no_test_modify
warn("Need to add an unit test if you're modifying swift source")
end

# determine if any of the files were modified
def did_modify(files_array)
did_modify_files = false
files_array.each do |file_name|
if git.modified_files.include?(file_name) || git.deleted_files.include?(file_name)
did_modify_files = true
end
end
return did_modify_files
end

# Fail if changes to immutable files, such as License or CoC
fail('Do not modify the license or Code of Conduct') if did_modify(@SDM_DANGER_IMMUTABLE_FILES)

# 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 > @SDM_DANGER_BIG_PR_LINES

# Make a note about contributors not in the organization
unless github.api.organization_member?('Quick', github.pr_author)
# Pay extra attention if they modify the podspec
if git.modified_files.include?("*.podspec")
warn "External contributor has edited the Podspec file"
end
end

# Mainly to encourage writing up some reasoning about the PR, rather than
# just leaving a title
if github.pr_body.length < 5
warn "Please provide a summary in the Pull Request description"
end

swiftlint.config_file = '.swiftlint.yml'
swiftlint.lint_files

2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
source "https://rubygems.org"

gem 'cocoapods', '~> 1.1.0.rc.2'
gem 'danger'
gem 'danger-swiftlint'
98 changes: 72 additions & 26 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,67 +1,113 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (4.2.6)
CFPropertyList (2.3.4)
activesupport (4.2.7.1)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
claide (1.0.0)
cocoapods (1.0.0)
activesupport (>= 4.0.2)
claide (>= 1.0.0, < 2.0)
cocoapods-core (= 1.0.0)
cocoapods-deintegrate (>= 1.0.0, < 2.0)
cocoapods-downloader (>= 1.0.0, < 2.0)
addressable (2.5.0)
public_suffix (~> 2.0, >= 2.0.2)
claide (1.0.1)
claide-plugins (0.9.2)
cork
nap
open4 (~> 1.3)
cocoapods (1.1.1)
activesupport (>= 4.0.2, < 5)
claide (>= 1.0.1, < 2.0)
cocoapods-core (= 1.1.1)
cocoapods-deintegrate (>= 1.0.1, < 2.0)
cocoapods-downloader (>= 1.1.2, < 2.0)
cocoapods-plugins (>= 1.0.0, < 2.0)
cocoapods-search (>= 1.0.0, < 2.0)
cocoapods-stats (>= 1.0.0, < 2.0)
cocoapods-trunk (>= 1.0.0, < 2.0)
cocoapods-try (>= 1.0.0, < 2.0)
cocoapods-trunk (>= 1.1.1, < 2.0)
cocoapods-try (>= 1.1.0, < 2.0)
colored (~> 1.2)
escape (~> 0.0.4)
fourflusher (~> 0.3.0)
molinillo (~> 0.4.5)
fourflusher (~> 2.0.1)
gh_inspector (~> 1.0)
molinillo (~> 0.5.1)
nap (~> 1.0)
xcodeproj (>= 1.0.0, < 2.0)
cocoapods-core (1.0.0)
activesupport (>= 4.0.2)
xcodeproj (>= 1.3.3, < 2.0)
cocoapods-core (1.1.1)
activesupport (>= 4.0.2, < 5)
fuzzy_match (~> 2.0.4)
nap (~> 1.0)
cocoapods-deintegrate (1.0.0)
cocoapods-downloader (1.0.0)
cocoapods-deintegrate (1.0.1)
cocoapods-downloader (1.1.3)
cocoapods-plugins (1.0.0)
nap
cocoapods-search (1.0.0)
cocoapods-stats (1.0.0)
cocoapods-trunk (1.0.0)
cocoapods-trunk (1.1.2)
nap (>= 0.8, < 2.0)
netrc (= 0.7.8)
cocoapods-try (1.0.0)
cocoapods-try (1.1.0)
colored (1.2)
cork (0.2.0)
colored (~> 1.2)
danger (4.0.4)
claide (~> 1.0)
claide-plugins (>= 0.9.2)
colored (~> 1.2)
cork (~> 0.1)
faraday (~> 0.9)
faraday-http-cache (~> 1.0)
git (~> 1)
kramdown (~> 1.5)
octokit (~> 4.2)
terminal-table (~> 1)
danger-swiftlint (0.2.1)
danger
escape (0.0.4)
fourflusher (0.3.0)
faraday (0.10.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.2)
git (1.3.0)
i18n (0.7.0)
json (1.8.3)
minitest (5.8.4)
molinillo (0.4.5)
kramdown (1.13.2)
minitest (5.10.1)
molinillo (0.5.5)
multipart-post (2.0.0)
nanaimo (0.2.3)
nap (1.1.0)
netrc (0.7.8)
octokit (4.6.2)
sawyer (~> 0.8.0, >= 0.5.3)
open4 (1.3.4)
public_suffix (2.0.5)
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.5)
tzinfo (1.2.2)
thread_safe (~> 0.1)
xcodeproj (1.0.0)
unicode-display_width (1.1.2)
xcodeproj (1.4.2)
CFPropertyList (~> 2.3.3)
activesupport (>= 3)
claide (>= 1.0.0, < 2.0)
claide (>= 1.0.1, < 2.0)
colored (~> 1.2)
nanaimo (~> 0.2.3)

PLATFORMS
ruby

DEPENDENCIES
cocoapods (= 1.0)
cocoapods (~> 1.1.0.rc.2)
danger
danger-swiftlint

BUNDLED WITH
1.11.2
1.13.2

0 comments on commit ccb3cc6

Please sign in to comment.