Skip to content

Commit

Permalink
Merge #350
Browse files Browse the repository at this point in the history
350: Add coveralls to buildkite steps r=ruhatch a=ruhatch

This generates coverage information for `cardano-chain` (not binary or crypto yet) and uploads it to coveralls

Closes #262

Co-authored-by: Rupert Horlick <rupert.horlick@iohk.io>
  • Loading branch information
iohk-bors[bot] and ruhatch committed Mar 11, 2019
2 parents 1ae4b20 + 992c194 commit a88428b
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -6,6 +6,7 @@ The formal specifications and associated executable specifications can be found
in the [`specs`](specs/) directory.

[![Build status](https://badge.buildkite.com/92690086997996d4f9703ef752c0e918a02bb389b44d0659a0.svg?branch=master)](https://buildkite.com/input-output-hk/cardano-chain)
[![Coverage Status](https://coveralls.io/repos/github/input-output-hk/cardano-chain/badge.svg?branch=master)](https://coveralls.io/github/input-output-hk/cardano-chain?branch=master)

## Developing

Expand Down
5 changes: 4 additions & 1 deletion scripts/buildkite/default.nix
Expand Up @@ -10,13 +10,16 @@ with pkgs;
let
cache-s3 = callPackage ./cache-s3.nix {};

stack-hpc-coveralls = pkgs.haskell.lib.dontCheck
(haskell.packages.ghc844.callPackage ./stack-hpc-coveralls.nix {});

stackRebuild = runCommand "stack-rebuild" {} ''
${haskellPackages.ghcWithPackages (ps: [ps.turtle ps.safe ps.transformers])}/bin/ghc -o $out ${./rebuild.hs}
'';

in
writeScript "stack-rebuild-wrapped" ''
#!${stdenv.shell}
export PATH=${lib.makeBinPath ([ cache-s3 stack gnused coreutils ] ++ buildTools)}
export PATH=${lib.makeBinPath ([ cache-s3 stack gnused coreutils stack-hpc-coveralls ] ++ buildTools)}
exec ${stackRebuild} "$@"
''
22 changes: 21 additions & 1 deletion scripts/buildkite/rebuild.hs
Expand Up @@ -40,6 +40,8 @@ main = do

cacheUploadStep cacheConfig

when (buildResult == ExitSuccess) coverageUploadStep

exitWith buildResult
where
buildSubdir :: Turtle.FilePath -> IO ExitCode
Expand All @@ -60,7 +62,25 @@ buildStep testArgs = do
buildAndTest = stackBuild $ ["--tests"] ++ buildArgs
build = stackBuild $ ["--no-run-tests"] ++ buildArgs
test =
stackBuild $ ["--test", "--jobs", "1"] ++ maybe [] ("--ta" :) testArgs
stackBuild
$ ["--test", "--coverage", "--jobs", "1"]
++ maybe [] ("--ta" :) testArgs

-- | Upload coverage information to coveralls
coverageUploadStep :: IO ()
coverageUploadStep = do
echo "--- Uploading Coverage Information"
need "COVERALLS_REPO_TOKEN" >>= \case
Nothing -> printf
"Missing coverall repo token. Not uploading coverage information.\n"
Just repoToken -> do
result <- proc
"shc"
["--repo-token", repoToken, "cardano-chain", "cardano-chain-test"]
empty
case result of
ExitSuccess -> printf "Coverage information upload successful.\n"
ExitFailure _ -> printf "Coverage information upload failed.\n"

-- buildkite agents have S3 creds installed, but under different names
awsCreds :: IO ()
Expand Down
31 changes: 31 additions & 0 deletions scripts/buildkite/stack-hpc-coveralls.nix
@@ -0,0 +1,31 @@
{ mkDerivation, aeson, base, bytestring, containers, deepseq
, directory, docopt, fetchgit, filepath, hlint, hpc, hspec
, hspec-contrib, http-client, HUnit, lens, lens-aeson, process
, pureMD5, stdenv, text, time, unordered-containers, utf8-string
, wreq, yaml
}:
mkDerivation {
pname = "stack-hpc-coveralls";
version = "0.0.4.0";
src = fetchgit {
url = "https://github.com/input-output-hk/stack-hpc-coveralls";
rev = "347159869bc9af2de6c6fa16e247ae060e82b954";
sha256 = "0qsfxddbzvw3lkyvr0876vnlsm1901gy2mksbghg709wpip4xksp";
fetchSubmodules = true;
};
isLibrary = true;
isExecutable = true;
libraryHaskellDepends = [
aeson base bytestring containers directory filepath hpc http-client
lens lens-aeson process pureMD5 text unordered-containers
utf8-string wreq yaml
];
executableHaskellDepends = [ aeson base bytestring docopt ];
testHaskellDepends = [
aeson base containers deepseq hlint hpc hspec hspec-contrib HUnit
time
];
homepage = "http://github.com/rubik/stack-hpc-coveralls";
description = "Initial project template from stack";
license = stdenv.lib.licenses.isc;
}

0 comments on commit a88428b

Please sign in to comment.