# 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

  # 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"'

  # 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

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

  # 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.
  # TODO: Enable this once Stack supports it.
  # See https://github.com/commercialhaskell/stack/pull/2576.
  # - '! stack list-dependencies --license --no-include-base | egrep -v "BSD3|MIT|ghc-prim|hoff|integer-gmp|template-haskell"'

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

Disable license check for now
Disable license check for now

The cabal-dependency-licenses package does not work with Stack, so I
could *also* install all dependencies with Cabal, but that seems
excessive.

I submitted a pull request for Stack that adds a --license option to
stack list-dependencies, so if that gets accepted, it could be used
here. For now, just disable the check.
