From 4cf7cc88416716ea2d0a54d2284bc8e95fd40203 Mon Sep 17 00:00:00 2001 From: Dmitry Pogodin Date: Tue, 28 May 2019 22:39:00 +0300 Subject: [PATCH] Add support for GHC 8.6 (#1) * 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 --- .gitignore | 1 + .travis.yml | 73 ++++++++++++++++------------------ README.md | 2 +- codecov-haskell.cabal | 7 ++++ shell.nix | 14 +++++++ src/Trace/Hpc/Codecov.hs | 2 +- src/Trace/Hpc/Codecov/Paths.hs | 11 ++--- stack.yaml | 7 ++-- 8 files changed, 68 insertions(+), 49 deletions(-) create mode 100644 shell.nix diff --git a/.gitignore b/.gitignore index ce58721..e04596d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ dist/ *.json .cabal-sandbox/ cabal.sandbox.config +.stack-work/ diff --git a/.travis.yml b/.travis.yml index baecccb..369d89c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 \ No newline at end of file diff --git a/README.md b/README.md index 57a8c11..0e9d402 100644 --- a/README.md +++ b/README.md @@ -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/). diff --git a/codecov-haskell.cabal b/codecov-haskell.cabal index 1e0cfa7..ea0ce44 100644 --- a/codecov-haskell.cabal +++ b/codecov-haskell.cabal @@ -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 @@ -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, @@ -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, @@ -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, @@ -109,3 +113,6 @@ test-suite test-all codecov-haskell, HUnit ghc-options: -Wall + other-modules: + TestCodecovHaskellLix + TestCodecovHaskellUtil diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..109b34e --- /dev/null +++ b/shell.nix @@ -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 + ]; +} diff --git a/src/Trace/Hpc/Codecov.hs b/src/Trace/Hpc/Codecov.hs index 2f6063e..2a17db5 100644 --- a/src/Trace/Hpc/Codecov.hs +++ b/src/Trace/Hpc/Codecov.hs @@ -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 diff --git a/src/Trace/Hpc/Codecov/Paths.hs b/src/Trace/Hpc/Codecov/Paths.hs index 424da09..6cf9a1d 100644 --- a/src/Trace/Hpc/Codecov/Paths.hs +++ b/src/Trace/Hpc/Codecov/Paths.hs @@ -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 diff --git a/stack.yaml b/stack.yaml index 862639d..27c978a 100644 --- a/stack.yaml +++ b/stack.yaml @@ -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. @@ -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: []