I will guide you through a quick set up using GitHub and
Travis CI. Reading this guide will probably take you
longer than setting things up as it is very easy.

Refer to the complete guide for different set ups or if you get into trouble.

Dangerfile

The Dangerfile is where you specify the rules to apply to the code, and that is
where we’ll use danger-hlint. The Dangerfile is a ruby script that we will write using function from danger-hlint and the danger gem itself.

Create a file called Dangerfile in the root of your project and paste in the
following

# get all affected files by the changes in the current diffaffected_files=git.added_files+git.modified_files# limit files to .hs fileshaskell_files=affected_files.select{|file|file.end_with?('.hs')}# run hlint on the files and comment inline in the PRhlint.linthaskell_filesinline_mode: true

If you wish to pass more arguments to hlint just add them as keyword arguments
like so

# run hlint on the files with my special hint file and comment inline in the PRhlint.linthaskell_filesinline_mode: truehint: "/path/to/MyHlinHintfile.yaml"

All arguments should be passed on transparently to hlint, if they are not feel
free to submit a pull request
to fix that.

Travis

Now that you have Danger set up locally, the next step is to run
it on your CI. I will explain here how to set up Travis to run Danger specifically
for Haskell projects. You can find a complete .travis.yamlhere and at the end of this
section.

Next in the the install step we want to install Danger and danger-hlint on
Travis.

We specified these gems as dependencies earlier in the Gemfile and
Gemfile.lock and committed those to files on in our project’s repository.
We can just then run bundle install --deployment. We want to use the --deployment
flag so that we can cache the vendor/bundle directory where bundler is going
to install the dependencies.

install:# Run bundler and install the dependencies in vendor/bundle# so that it can be cached.-bundle install --deployment

Next in the script step we want to run Danger so we simply add bundle exec danger

script:-bundle exec danger

Last we’re going to tell Travis to cache the vendor/bundle directory so that on
the next run bundle install --deployment will potentially do no work.

# Caching so the next build will be fast too.cache:directories:-vendor/bundle

Here is an example of how a final and complete .travis.yaml file looks like for
Haskell projects, including Danger setup.

In the next section we will see how to allow Danger to comment on the pull requests
that will be open on our project from now on.

Enabling Danger to comment on pull requests

Danger is able to comment on pull request on GitHub by controlling an account via
a personal access token. Rather than using
your own account you can create another account on GitHub using the incognito mode on
you web browser as suggested on Danger.systems.

Alternatively I have already created @hlintBot. Feel
free to use this account in the next steps, the access token to control @hlintBot is

In the Environment Variables section add an environment variable called
DANGER_GITHUB_API_TOKEN and assign it the value of your access token. Refer to
the CI/Token Setup section on Danger.Systems if these instructions are unclear.