Skip to content

Commit

Permalink
Add support for GHC 8.6 (killy971#1)
Browse files Browse the repository at this point in the history
* remove support for GHC 7.x
* build project with Stack and Nix
* fix some Cabal warnings
* robust path to mix/tix files generation
* use Stack coverage reports
  • Loading branch information
lunaticare authored May 28, 2019
1 parent 36686ce commit 4cf7cc8
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 49 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ dist/
*.json
.cabal-sandbox/
cabal.sandbox.config
.stack-work/
73 changes: 34 additions & 39 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,42 @@
language: nix
env:
- GHCVER=7.6.3
- GHCVER=7.8.3
- GHCVER=8.2.2
# GHC 7.10.3
# - STACK_RESOLVER=lts-6.35
# GHC 8.0.2
# - STACK_RESOLVER=9.21
# GHC 8.2.2
- STACK_RESOLVER=lts-11.22
# GHC 8.4.4
- STACK_RESOLVER=lts-12.26
# GHC 8.6.4
- STACK_RESOLVER=lts-13.18

before_install:
- travis_retry sudo add-apt-repository -y ppa:hvr/ghc
- travis_retry sudo apt-get update
- travis_retry sudo apt-get install cabal-install-1.20 ghc-$GHCVER happy
- export PATH=/opt/ghc/$GHCVER/bin:$PATH

install:
- cabal-1.20 update
- travis_retry sudo apt-get -q -y install hlint || cabal-1.20 install hlint
- cabal-1.20 install --only-dependencies --enable-tests --enable-benchmarks
# configure Nix https://nixos.wiki/wiki/Nix_on_Travis
- sudo mkdir -p /etc/nix
- echo "substituters = https://cache.nixos.org/ file://$HOME/nix.store" | sudo tee -a /etc/nix/nix.conf > /dev/null
- echo 'require-sigs = false' | sudo tee -a /etc/nix/nix.conf > /dev/null
- echo 'sandbox = true' | sudo tee -a /etc/nix/nix.conf > /dev/null
# Download and unpack the stack executable https://docs.haskellstack.org/en/stable/travis_ci/#installing-stack
- mkdir -p ~/.local/bin
- export PATH=$HOME/.local/bin:$PATH
- travis_retry curl -L https://get.haskellstack.org/stable/linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'

script:
- hlint . --ignore="Parse error"
- cabal-1.20 configure --enable-tests --enable-benchmarks --enable-library-coverage -v2
- cabal-1.20 build
- |
if [ $GHCVER = "7.8.3" ]; then
cabal-1.20 test --show-details=always
else
dist/build/run-cabal-test/run-cabal-test --cabal-name=cabal-1.20 --show-details=always
fi
- cabal-1.20 check
- cabal-1.20 sdist
- export SRC_TGZ=$(cabal-1.20 info . | awk '{print $2 ".tar.gz";exit}') ;
(cd dist/;
if [ -f "$SRC_TGZ" ]; then
cabal-1.20 install "$SRC_TGZ";
else
echo "expected '$SRC_TGZ' not found";
exit 1;
fi)
- stack build --test --copy-bins --prefetch --coverage --resolver $STACK_RESOLVER

after_script:
- dist/build/codecov-haskell/codecov-haskell test-all --exclude-dir=test --display-report --print-response
- export PACKAGE_NAME=codecov-haskell
- export MIX_DIR="$(stack path --dist-dir)/hpc/"
- export TIX_DIR="$(stack path --local-hpc-root)/$PACKAGE_NAME/"
- codecov-haskell test-all --exclude-dir=test --display-report --print-response --combined=false --exclude-dir test --mix-dir $MIX_DIR --tix-dir $TIX_DIR --token=$CODECOV_TOKEN

cache:
directories:
- $HOME/nix.store
- $HOME/.stack

notifications:
webhooks:
urls:
- https://webhooks.gitter.im/e/3ff64a7879ffa1a444b6
on_success: change
on_failure: always
on_start: false
before_cache:
# cache Nix store https://nixos.wiki/wiki/Nix_on_Travis
- mkdir -p $HOME/nix.store
- nix copy --to file://$HOME/nix.store -f default.nix buildInputs
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
codecov-haskell [![Build Status](http://img.shields.io/travis/guillaume-nargeot/codecov-haskell/master.svg)](https://travis-ci.org/guillaume-nargeot/codecov-haskell) [![Gitter chat](http://img.shields.io/badge/gitter-chat--room-brightgreen.svg)](https://gitter.im/guillaume-nargeot/codecov-haskell) [![BSD3 License](http://img.shields.io/badge/license-BSD3-brightgreen.svg)](https://tldrlegal.com/license/bsd-3-clause-license-%28revised%29) [![Version on Hackage](http://img.shields.io/hackage/v/codecov-haskell.svg)](http://hackage.haskell.org/package/codecov-haskell)
codecov-haskell [![Build Status](http://img.shields.io/travis/lunaticare/codecov-haskell/master.svg)](https://travis-ci.org/lunaticare/codecov-haskell) [![Gitter chat](http://img.shields.io/badge/gitter-chat--room-brightgreen.svg)](https://gitter.im/guillaume-nargeot/codecov-haskell) [![BSD3 License](http://img.shields.io/badge/license-BSD3-brightgreen.svg)](https://tldrlegal.com/license/bsd-3-clause-license-%28revised%29) [![Version on Hackage](http://img.shields.io/hackage/v/codecov-haskell.svg)](http://hackage.haskell.org/package/codecov-haskell)
===============

codecov-haskell converts and sends Haskell projects hpc code coverage to [codecov.io](http://codecov.io/).
Expand Down
7 changes: 7 additions & 0 deletions codecov-haskell.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ library
Trace.Hpc.Codecov.Util
other-modules:
CodecovHaskellCmdLine,
Paths_codecov_haskell,
Trace.Hpc.Codecov.Config,
Trace.Hpc.Codecov.Curl,
Trace.Hpc.Codecov.Paths
Expand All @@ -59,6 +60,7 @@ library
containers >= 0.5,
cmdargs >= 0.10,
curl >= 1.3.8,
filepath,
hpc >= 0.6,
retry >= 0.7,
safe >= 0.3,
Expand All @@ -69,6 +71,7 @@ executable codecov-haskell
main-is: CodecovHaskellMain.hs
other-modules:
CodecovHaskellCmdLine,
Paths_codecov_haskell,
Trace.Hpc.Codecov.Config,
Trace.Hpc.Codecov.Curl,
Trace.Hpc.Codecov.Paths,
Expand All @@ -83,6 +86,7 @@ executable codecov-haskell
containers >= 0.5,
cmdargs >= 0.10,
curl >= 1.3.8,
filepath,
hpc >= 0.6,
retry >= 0.5,
safe >= 0.3,
Expand All @@ -109,3 +113,6 @@ test-suite test-all
codecov-haskell,
HUnit
ghc-options: -Wall
other-modules:
TestCodecovHaskellLix
TestCodecovHaskellUtil
14 changes: 14 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{ ghc }:
let pkgs = (import (fetchTarball {
url = https://github.com/NixOS/nixpkgs-channels/archive/a7e559a5504572008567383c3dc8e142fa7a8633.tar.gz;
sha256 = "16j95q58kkc69lfgpjkj76gw5sx8rcxwi3civm0mlfaxxyw9gzp6";
}) {});

in pkgs.haskell.lib.buildStackProject {
inherit ghc;
name = "myEnv";
buildInputs = [
pkgs.curl
pkgs.zlib
];
}
2 changes: 1 addition & 1 deletion src/Trace/Hpc/Codecov.hs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ readCoverageData :: Config -- ^ codecov-haskell configuration
-> [String] -- ^ excluded source folders
-> IO TestSuiteCoverageData -- ^ coverage data list
readCoverageData config testSuiteName excludeDirPatterns = do
tixPath <- getTixPath config testSuiteName
tixPath <- return $ getTixPath config testSuiteName
mtix <- readTix tixPath
case mtix of
Nothing -> error ("Couldn't find the file " ++ tixPath) >> exitFailure
Expand Down
11 changes: 6 additions & 5 deletions src/Trace/Hpc/Codecov/Paths.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,24 @@ module Trace.Hpc.Codecov.Paths where

import Trace.Hpc.Tix
import Trace.Hpc.Codecov.Config
import System.FilePath

defaultHpcDir :: FilePath
defaultHpcDir = "dist/hpc/"

defaultTixDir :: FilePath
defaultTixDir = defaultHpcDir ++ "tix/"
defaultTixDir = defaultHpcDir </> "tix/"

defaultMixDir :: FilePath
defaultMixDir = defaultHpcDir ++ "mix/"
defaultMixDir = defaultHpcDir </> "mix/"

getMixPaths :: Config -> String -> TixModule -> [FilePath]
getMixPaths config testSuiteName tix = do _dirName <- dirName
return $ mixDir config ++ _dirName ++ "/"
return $ mixDir config </> _dirName </> ""
where dirName = case span (/= '/') modName of
(_, []) -> [ testSuiteName ]
(packageId, _) -> [ "", packageId ]
TixModule modName _ _ _ = tix

getTixPath :: Config -> String -> IO FilePath
getTixPath config testSuiteName = return $ tixDir config ++ testSuiteName ++ "/" ++ getTixFileName testSuiteName
getTixPath :: Config -> String -> FilePath
getTixPath config testSuiteName = tixDir config ++ testSuiteName </> getTixFileName testSuiteName
7 changes: 4 additions & 3 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
# resolver:
# name: custom-snapshot
# location: "./custom-snapshot.yaml"
resolver: lts-10.3
#resolver: lts-13.10
resolver: lts-13.18

nix:
enable: true
packages:
- curl
shell-file: shell.nix

# User packages to be built.
# Various formats can be used as shown in the example below.
Expand Down Expand Up @@ -48,6 +48,7 @@ extra-deps: []

# Override default flag values for local packages and extra-deps
flags: {}
# - -fhpc

# Extra package databases containing global packages
extra-package-dbs: []
Expand Down

0 comments on commit 4cf7cc8

Please sign in to comment.