Skip to content

Commit 6c80daa

Browse files
Implement coveralls support
1 parent 2b68967 commit 6c80daa

File tree

5 files changed

+75
-9
lines changed

5 files changed

+75
-9
lines changed

.github/workflows/haskell-ci.yml

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
name: Haskell-CI
2+
permissions:
3+
contents: read
24

35
on:
46
push:
@@ -15,13 +17,13 @@ concurrency:
1517
cancel-in-progress: true
1618

1719
jobs:
18-
linux:
19-
name: Haskell-CI - Linux - ${{ matrix.ghc-version }}
20+
test-with-cabal:
21+
name: Haskell-CI - Linux - cabal - ${{ matrix.ghc-version }}
2022

2123
strategy:
2224
matrix:
2325
ghc-version: [latest, 9.12, "9.10", 9.8, 9.6]
24-
os: [ubuntu-24.04]
26+
os: [ubuntu-latest]
2527
fail-fast: false
2628

2729
runs-on: ${{ matrix.os }}
@@ -43,3 +45,45 @@ jobs:
4345
with:
4446
key: ${{ matrix.os }}-${{ matrix.ghc-version }}-${{ github.sha }}
4547
path: ~/.cabal/store
48+
49+
test-with-stack:
50+
name: Stack
51+
runs-on: ubuntu-latest
52+
steps:
53+
- uses: actions/checkout@v4
54+
55+
- uses: haskell-actions/setup@v2
56+
id: setup-haskell-stack
57+
name: Setup Haskell
58+
with:
59+
enable-stack: true
60+
stack-version: latest
61+
ghc-version: 9.6.7
62+
63+
- name: Cache
64+
id: cache
65+
uses: actions/cache@v4
66+
with:
67+
path: |
68+
${{ steps.setup-haskell-stack.outputs.stack-root }}
69+
.stack-work
70+
key: ${{ runner.os }}-stack-${{ github.sha }}
71+
restore-keys: ${{ runner.os }}-stack
72+
73+
- name: Test
74+
run: stack test --coverage --flag constrained-generators:devel
75+
76+
- uses: actions/cache/save@v4
77+
with:
78+
path: |
79+
${{ steps.setup-haskell-stack.outputs.stack-root }}
80+
.stack-work
81+
key: ${{ runner.os }}-stack-${{ github.sha }}
82+
83+
- name: Upload coverage report
84+
env:
85+
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
86+
run: |
87+
[ -n "${COVERALLS_REPO_TOKEN}" ]
88+
curl -L https://github.com/rubik/stack-hpc-coveralls/releases/download/v0.0.7.0/shc-Linux-X64.tar.bz2 | tar xj shc
89+
./shc --repo-token="$COVERALLS_REPO_TOKEN" --partial-coverage --fetch-coverage combined all

constrained-generators.cabal

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ library examples
121121
prettyprinter,
122122
random,
123123

124-
test-suite constrained
124+
test-suite constrained-tests
125125
type: exitcode-stdio-1.0
126126
main-is: Tests.hs
127127
hs-source-dirs: test
@@ -141,9 +141,12 @@ test-suite constrained
141141
QuickCheck,
142142
base,
143143
constrained-generators,
144-
constrained-generators:examples,
145144
containers,
146-
hspec,
145+
hspec
146+
147+
if !flag(devel)
148+
build-depends:
149+
constrained-generators:examples
147150

148151
benchmark bench
149152
type: exitcode-stdio-1.0

stack.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
snapshot: lts-22.44
2+
packages:
3+
- .
4+
system-ghc: true

stack.yaml.lock

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This file was autogenerated by Stack.
2+
# You should not edit this file by hand.
3+
# For more information, please see the documentation at:
4+
# https://docs.haskellstack.org/en/stable/topics/lock_files
5+
6+
packages: []
7+
snapshots:
8+
- completed:
9+
sha256: 238fa745b64f91184f9aa518fe04bdde6552533d169b0da5256670df83a0f1a9
10+
size: 721141
11+
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/22/44.yaml
12+
original: lts-22.44

test/Constrained/Tests.hs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{-# LANGUAGE AllowAmbiguousTypes #-}
2+
{-# LANGUAGE CPP #-}
23
{-# LANGUAGE ConstraintKinds #-}
34
{-# LANGUAGE DataKinds #-}
45
{-# LANGUAGE FlexibleContexts #-}
@@ -59,6 +60,9 @@ testAll = hspec $ tests False
5960
tests :: Bool -> Spec
6061
tests nightly =
6162
describe "constrained" . modifyMaxSuccess (\ms -> if nightly then ms * 10 else ms) $ do
63+
testSpec "setOfPairLetSpec" setOfPairLetSpec
64+
testSpec "setPair" setPair
65+
testSpec "mapElemSpec" mapElemSpec
6266
testSpec "complicatedEither" complicatedEither
6367
testSpec "pairCant" pairCant
6468
-- TODO: figure out why this doesn't shrink
@@ -70,7 +74,6 @@ tests nightly =
7074
testSpec "assertRealMultiple" assertRealMultiple
7175
testSpec "setSpec" setSpec
7276
testSpec "leqPair" leqPair
73-
testSpec "setPair" setPair
7477
testSpecNoShrink "listEmpty" listEmpty
7578
testSpec "compositionalSpec" compositionalSpec
7679
testSpec "simplePairSpec" simplePairSpec
@@ -80,7 +83,6 @@ tests nightly =
8083
testSpec "maybeSpec" maybeSpec
8184
testSpecNoShrink "eitherSetSpec" eitherSetSpec
8285
testSpec "fooSpec" fooSpec
83-
testSpec "mapElemSpec" mapElemSpec
8486
testSpec "mapElemKeySpec" mapElemKeySpec
8587
-- TODO: figure out why this doesn't shrink
8688
testSpecNoShrink "mapIsJust" mapIsJust
@@ -95,7 +97,6 @@ tests nightly =
9597
-- more detailed shrinking of `SuspendedSpec`s
9698
testSpecNoShrink "setPairSpec" setPairSpec
9799
testSpec "fixedSetSpec" fixedSetSpec
98-
testSpec "setOfPairLetSpec" setOfPairLetSpec
99100
testSpecNoShrink "emptyEitherSpec" emptyEitherSpec
100101
testSpecNoShrink "emptyEitherMemberSpec" emptyEitherMemberSpec
101102
testSpec "setSingletonSpec" setSingletonSpec
@@ -315,11 +316,13 @@ testSpec' withShrink n s = do
315316
checkCoverage' $
316317
prop_constrained_explained s
317318

319+
#if MIN_VERSION_QuickCheck(2, 16, 0)
318320
when withShrink $
319321
prop "prop_shrink_sound" $
320322
discardAfter 100_000 $
321323
checkCoverage' $
322324
prop_shrink_sound s
325+
#endif
323326

324327
------------------------------------------------------------------------
325328
-- Test properties of the instance Num (NumSpec Integer)

0 commit comments

Comments
 (0)