Search code examples
haskelltestingconfigtravis-cisoftware-distribution

How do specify the resolver (and GHC) Travis should use to test my Haskell package?


I'm trying to test my Haskell package against several Stackage resolvers on Travis, but my --resolver environment variable is being ignored.

For example, if I specify

env:
- ARGS="--resolver lts-4.0"

in my .travis.yml, I still still seem to be using a different resolver (the one in my stack.yaml?) and GHC, as shown by lines like

Installing library in
/home/travis/build/orome/crypto-enigma-hs/.stack-work/install/x86_64-linux/lts-9.1/8.0.2/lib/x86_64-linux-ghc-8.0.2/crypto-enigma-0.0.2.9-6Cs7XSzJkwSDxsEMnLKb0X

in the corresponding build log, which indicates a different resolver (9.1), and corresponding GHC (8.0.2) being used.

How should my build (stack.yaml, .travis.yml, etc.) be configured to ensure that the resolvers (and corresponding GHC) I specify are used to preform my Travis builds and tests?


Solution

  • With env you just define environment variables. You still have to use them. stack on its own does not respect the ARGS variable, so use it in your script, e.g.

    install:
    # Build dependencies
    - stack $ARGS --no-terminal --install-ghc test --only-dependencies
    
    script:
    # Build the package, its tests, and its docs and run the tests
    - stack $ARGS --no-terminal --install-ghc test --haddock --no-haddock-deps
    

    You should probably use a better name, for example RESOLVER:

    env:
    - RESOLVER=lts-4.0
    - RESOLVER=lts-6.0
    - RESOLVER=lts-8.0
    
    install:
    # Build dependencies
    - stack --resolver $RESOLVER --no-terminal --install-ghc test --only-dependencies
    
    script:
    # Build the package, its tests, and its docs and run the tests
    - stack --resolver $RESOLVER --no-terminal --install-ghc test --haddock --no-haddock-deps
    

    Also keep in mind that it's usually a better idea to use multiple stack.yml to hold the configuration for that specific LTS variant.

    For more information, see stack's Travis documentation and Travis' environment variables documentation.