Skip to content

Commit

Permalink
Add Danger.system to review PRs (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmspzz authored Jul 5, 2017
1 parent 957df11 commit 40203ab
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ cabal.sandbox.config
.stack-work/
cabal.project.local
codex.tags
_Dangerfile.tmp
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ sudo: false
# Choose a lightweight base image; we provide our own build tools.
language: c


# GHC depends on GMP. You can add other dependencies here as well.
addons:
apt:
Expand All @@ -17,15 +18,25 @@ env:
- ARGS="--resolver=lts-7"

before_install:
# Update ruby
- rvm use 2.1 --install --binary --fuzzy

# Download and unpack the stack executable
- mkdir -p ~/.local/bin
- export PATH=$HOME/.local/bin:$PATH
- travis_retry curl -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'

# Download and instal hlint
- rake

install:
- bundle install

# This line does all of the work: installs GHC if necessary, build the library,
# executables, and test suites, and runs the test suites. --no-terminal works
# around some quirks in Travis's terminal implementation.
script:
- bundle exec danger
- stack $ARGS setup
- stack $ARGS test --no-terminal --haddock --no-haddock-deps
- stack $ARGS build
Expand Down
20 changes: 20 additions & 0 deletions Dangerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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


affected_files = git.added_files + git.modified_files

haskell_files = affected_files.select { |file| file.end_with?('.hs') }

hlint.lint(haskell_files, true)

# Don't let testing shortcuts get into master by accident
fail("fdescribe left in tests") if `grep -r fdescribe specs/ `.length > 1
fail("fit left in tests") if `grep -r fit specs/ `.length > 1
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true
source "https://rubygems.org"

gem "danger"
gem "danger-hlint"
gem "pry"
64 changes: 64 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.5.1)
public_suffix (~> 2.0, >= 2.0.2)
claide (1.0.2)
claide-plugins (0.9.2)
cork
nap
open4 (~> 1.3)
coderay (1.1.1)
colored2 (3.1.2)
cork (0.3.0)
colored2 (~> 3.1)
danger (5.3.3)
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.7)
terminal-table (~> 1)
danger-hlint (0.0.2)
danger-plugin-api (~> 1.0)
danger-plugin-api (1.0.0)
danger (> 2.0)
faraday (0.12.1)
multipart-post (>= 1.2, < 3)
faraday-http-cache (1.3.1)
faraday (~> 0.8)
git (1.3.0)
kramdown (1.14.0)
method_source (0.8.2)
multipart-post (2.0.0)
nap (1.1.0)
octokit (4.7.0)
sawyer (~> 0.8.0, >= 0.5.3)
open4 (1.3.4)
pry (0.10.4)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
public_suffix (2.0.5)
sawyer (0.8.1)
addressable (>= 2.3.5, < 2.6)
faraday (~> 0.8, < 1.0)
slop (3.6.0)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
unicode-display_width (1.3.0)

PLATFORMS
ruby

DEPENDENCIES
danger
danger-hlint
pry

BUNDLED WITH
1.14.6
27 changes: 27 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

namespace :hlint do

desc "Download and install hlint"
task :install do
REPO = "https://github.com/ndmitchell/hlint"
VERSION = "2.0.9"#DangerHlint::HLINT_VERSION
ASSET = "hlint-#{VERSION}-x86_64-linux.tar.gz"
URL = "#{REPO}/releases/download/v#{VERSION}/#{ASSET}"
DESTINATION_BASE = File.expand_path(File.join(File.dirname(__FILE__), 'bin'))
DESTINATION_TMP = File.join("#{DESTINATION_BASE}", 'tmp')

puts "Downloading hlint@v#{VERSION}"
sh [
"mkdir -p #{DESTINATION_TMP}",
"curl -s -L #{URL} -o #{ASSET}",
"tar -xf #{ASSET} -C #{DESTINATION_TMP}",
"cp #{DESTINATION_TMP}/hlint-#{VERSION}/hlint #{File.expand_path("~/.local/bin")}",
"cp -R #{DESTINATION_TMP}/hlint-#{VERSION}/data #{File.expand_path("~/.local/bin")}",
"rm -r #{DESTINATION_BASE}/",
"rm #{ASSET}"
].join(" && ")
end

end

task default: 'hlint:install'
10 changes: 4 additions & 6 deletions src/Lib.hs
Original file line number Diff line number Diff line change
Expand Up @@ -894,9 +894,8 @@ deleteFrameworkDirectory :: MonadIO m
-> Bool -- ^ A flag controlling verbosity
-> m ()
deleteFrameworkDirectory (FrameworkVersion f _)
platform
verbose =
deleteDirectory frameworkDirectory verbose
platform =
deleteDirectory frameworkDirectory
where
frameworkNameWithFrameworkExtension = appendFrameworkExtensionTo f
platformBuildDirectory = carthageBuildDirectoryForPlatform platform
Expand All @@ -911,9 +910,8 @@ deleteDSYMDirectory :: MonadIO m
-> Bool -- ^ A flag controlling verbosity
-> m ()
deleteDSYMDirectory (FrameworkVersion f _)
platform
verbose =
deleteDirectory dSYMDirectory verbose
platform =
deleteDirectory dSYMDirectory
where
frameworkNameWithFrameworkExtension = appendFrameworkExtensionTo f
platformBuildDirectory = carthageBuildDirectoryForPlatform platform
Expand Down

0 comments on commit 40203ab

Please sign in to comment.