Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add coverage support #6

Merged
merged 1 commit into from
Jun 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,8 @@ jobs:
keys:
- v1-test-{{ checksum "nix/nixpkgs.json" }}
- run:
name: test
command: make test
- run:
name: Upload coverage
command: /bin/bash -c 'bash <(curl -s https://codecov.io/bash)'
name: test and coverage report
command: make coverage
- save_cache:
key: v1-test-{{ checksum "nix/nixpkgs.json" }}
paths:
Expand Down
20 changes: 0 additions & 20 deletions .codecov.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.orig
*.tix
.ghc.environment.*
dist
dist-*
Expand Down
18 changes: 17 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
all:
all: build

.PHONY: build
build:
nix-build nix/release.nix

.PHONY: build-static
build-static:
nix-build nix/static.nix

define nix-shell
nix-shell nix/shell.nix --pure $(1)
endef
Expand All @@ -17,6 +24,15 @@ cabal2nix:
clean:
$(call nix-shell-run,git clean -fdx)

.PHONY: coverage
coverage:
nix-shell nix/shell.nix --run \
"cabal configure --enable-tests --enable-coverage &&\
cabal test &&\
hpc-coveralls performabot-test \
-r ehCDKUtRSiNfht5xyC580BaZqCCjSBICz \
--exclude-dir=test"

.PHONY: doc
doc:
$(call nix-shell-run,cabal new-haddock)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# performabot

[![CircleCI](https://circleci.com/gh/saschagrunert/performabot.svg?style=shield)](https://circleci.com/gh/saschagrunert/performabot)
[![Coverage](https://codecov.io/gh/saschagrunert/performabot/branch/master/graph/badge.svg)](https://codecov.io/gh/saschagrunert/performabot)
[![Coverage](https://coveralls.io/repos/github/saschagrunert/performabot/badge.svg?branch=master)](https://coveralls.io/github/saschagrunert/performabot?branch=master)
[![Doc](https://img.shields.io/badge/doc-performabot-orange.svg)](https://saschagrunert.github.io/performabot)
[![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/saschagrunert/performabot/blob/master/LICENSE)
5 changes: 3 additions & 2 deletions nix/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{ mkDerivation, base, heavy-logger, mtl, stdenv, text-format-heavy
{ mkDerivation, base, heavy-logger, mtl, stdenv, tasty, tasty-hspec
, tasty-quickcheck, text-format-heavy
}:
mkDerivation {
pname = "performabot";
Expand All @@ -10,6 +11,6 @@ mkDerivation {
executableHaskellDepends = [
base heavy-logger mtl text-format-heavy
];
testHaskellDepends = [ base ];
testHaskellDepends = [ base tasty tasty-hspec tasty-quickcheck ];
license = stdenv.lib.licenses.mit;
}
6 changes: 3 additions & 3 deletions nix/nixpkgs.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"url": "https://github.com/nixos/nixpkgs",
"rev": "1a28cf89432d5f3c06134c20f866570a2594e149",
"date": "2019-06-03T05:52:47-07:00",
"sha256": "18prhyilncrmrh6n4bprzs37g8q5bfa68n39d3pc1cm77p67zma5",
"rev": "741d20c900025c4e5bc6f14a5703bd9340461640",
"date": "2019-06-04T17:02:45+02:00",
"sha256": "07qfbd7hlzncyv0bxyyqy5ifchmvfw0rfrf0g9zc8jq71810rqx9",
"fetchSubmodules": false
}
1 change: 1 addition & 0 deletions nix/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pkgs.stdenv.mkDerivation {
cabal-install
cabal2nix
git
haskellPackages.hpc-coveralls
hlint
nix-prefetch-git
];
Expand Down
15 changes: 15 additions & 0 deletions nix/static.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
let
pkgs = (import ./nixpkgs.nix { }).pkgsMusl;
in
(pkgs.haskellPackages.callPackage ./default.nix { }).overrideAttrs(old: {
enableSharedExecutables = false;
enableSharedLibraries = false;
configureFlags = [
"--ghc-option=-optl=-static"
"--extra-lib-dirs=${pkgs.gmp6.override { withStatic = true; }}/lib"
"--extra-lib-dirs=${pkgs.zlib.static}/lib"
"--extra-lib-dirs=${pkgs.libffi.overrideAttrs
(old: { dontDisableStatic = true; })}/lib"
"--disable-executable-stripping"
];
})
11 changes: 6 additions & 5 deletions performabot.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ source-repository head
library
build-depends: base
default-language: Haskell2010
exposed-modules: Lib
exposed-modules: Parser
ghc-options:
-Werror
-Weverything
Expand Down Expand Up @@ -49,10 +49,10 @@ executable performabot
-with-rtsopts=-N
hs-source-dirs: src
main-is: Main.hs
other-modules: Lib
other-modules: Parser

test-suite test-performabot
build-depends: base, performabot
test-suite performabot-test
build-depends: base, performabot, tasty, tasty-hspec, tasty-quickcheck
ghc-options:
-Werror
-Weverything
Expand All @@ -69,5 +69,6 @@ test-suite test-performabot
-threaded
-with-rtsopts=-N
hs-source-dirs: test
main-is: Test.hs
main-is: Main.hs
other-modules: ParserSpec
type: exitcode-stdio-1.0
2 changes: 1 addition & 1 deletion src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Control.Monad.Trans ( liftIO )

import Data.Text.Format.Heavy ( Single(Single) )

import Lib ( parse )
import Parser ( parse )

import System.IO
( BufferMode(LineBuffering), hSetBuffering, stdout )
Expand Down
4 changes: 2 additions & 2 deletions src/Lib.hs → src/Parser.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- | The main library interface
module Lib ( parse ) where
-- | All parser relevant implementations
module Parser ( parse ) where

-- | Parse the provided string and return True on success
parse :: String -> Bool
Expand Down
25 changes: 25 additions & 0 deletions test/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
-- | The main test module
--
-- @since 0.1.0
module Main ( main ) where

import ParserSpec ( parserSpec )

import Test.Tasty
( TestTree, defaultMain, localOption, testGroup )
import Test.Tasty.Hspec ( testSpec )
import Test.Tasty.QuickCheck ( QuickCheckTests(QuickCheckTests) )

-- The main test routine
main :: IO ()
main = do
uTests <- unitTests
defaultMain . opts $ testGroup "Tests" [ uTests ]
where
opts = localOption $ QuickCheckTests 5000

-- Unit tests based on hspec
unitTests :: IO TestTree
unitTests = do
parserUnitTests <- testSpec "Parser.hs" parserSpec
return $ testGroup "Unit" [ parserUnitTests ]
13 changes: 13 additions & 0 deletions test/ParserSpec.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- | The parser tests
--
-- @since 0.1.0
module ParserSpec ( parserSpec ) where

import Parser ( parse )

import Test.Tasty.Hspec ( Spec, it, parallel, shouldBe )

-- Parser.hs related unit tests
parserSpec :: Spec
parserSpec = parallel $ it "should succeed" $ parse "test" `shouldBe` True

10 changes: 0 additions & 10 deletions test/Test.hs

This file was deleted.