# Based on the default default .travis.yml for usage with Stack.
# See https://docs.haskellstack.org/en/stable/travis_ci/.

language: c

cache:
  directories:
    - $HOME/.stack/

addons:
  apt:
    packages:
      - libgmp-dev

before_install:
  - 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'

install:
  - stack setup --no-terminal

script:
  - stack build -j2 --no-terminal
  - stack test -j2 --no-terminal
  # As CI is running on a Debian-like system, test building
  # the package here too.
  - cd package && VERSION=0.0.0 ./build-package.sh

# Based on the default default .travis.yml for usage with Stack.
# See https://docs.haskellstack.org/en/stable/travis_ci/.

language: c

cache:
  directories:
    - $HOME/.stack/

addons:
  apt:
    packages:
      - libgmp-dev

before_install:
  - 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'

install:
  - stack setup --no-terminal
  - stack install --no-terminal cabal-dependency-licenses

script:
  - stack build -j2 --no-terminal
  - stack test -j2 --no-terminal

  # As CI is running on a Debian-like system, test building
  # the package here too.
  - cd package && VERSION=0.0.0 ./build-package.sh

  # Match the licenses of dependencies agains a whitelist, and fail if anything
  # is not whitelisted. YAML has this arcane feature where an exclamation mark
  # has special meaning, so the entire command is wrapped in single quotes.
  - '! $(stack path --local-bin)/cabal-dependency-licenses | grep "#" | egrep -v "BSD3|MIT|PublicDomain"'

Check dependency licenses on Travis CI
Check dependency licenses on Travis CI

To avoid accidentally depending on a library that has a license
incompatible with Apache 2.0 (for instance, LGPL, because GHC links
Haskell dependencies statically), verify the list of dependency licenses
against a whitelist of allowed licenses.

Hackage is surprisingly uniform in with licenses: the vast majority of
dependency licenses is BSD3, a few are MIT, and one is public domain.
So far, so good.
