Skip to content

Commit 33c82e5

Browse files
committed
Allow running cabal-docspec in constraint-sets
See https://github.com/ekmett/ad/runs/1953010049?check_suite_focus=true#step:27:89 for an example of this in action.
1 parent 2dd8dac commit 33c82e5

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

cabal.haskell-ci

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ constraint-set deepseq-1.4
101101

102102
-- tests: False
103103
-- run-tests: False
104+
-- docspec: False
104105
-- benchmarks: False
105106
haddock: True
106107

haskell-ci.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 2.2
22
name: haskell-ci
3-
version: 0.11.20210221
3+
version: 0.11.20210222
44
synopsis: Cabal package script generator for Travis-CI
55
description:
66
Script generator (@haskell-ci@) for [Travis-CI](https://travis-ci.org/) for continuous-integration testing of Haskell Cabal packages.

src/HaskellCI/Config/ConstraintSet.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ data ConstraintSet = ConstraintSet
1616
, csConstraints :: [String] -- we parse these simply as strings
1717
, csTests :: Bool
1818
, csRunTests :: Bool
19+
, csDocspec :: Bool
1920
, csBenchmarks :: Bool
2021
, csHaddock :: Bool
2122
}
2223
deriving (Show, Generic)
2324

2425
emptyConstraintSet :: String -> ConstraintSet
25-
emptyConstraintSet n = ConstraintSet n anyVersion [] False False False False
26+
emptyConstraintSet n = ConstraintSet n anyVersion [] False False False False False
2627

2728
-------------------------------------------------------------------------------
2829
-- Grammar
@@ -37,5 +38,6 @@ constraintSetGrammar name = ConstraintSet name
3738
<*> C.monoidalFieldAla "constraints" (C.alaList' C.CommaVCat NoCommas) (field @"csConstraints")
3839
<*> C.booleanFieldDef "tests" (field @"csTests") False
3940
<*> C.booleanFieldDef "run-tests" (field @"csRunTests") False
41+
<*> C.booleanFieldDef "docspec" (field @"csDocspec") False
4042
<*> C.booleanFieldDef "benchmarks" (field @"csBenchmarks") False
4143
<*> C.booleanFieldDef "haddock" (field @"csHaddock") False

src/HaskellCI/GitHub.hs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,11 +385,9 @@ makeGitHub _argv config@Config {..} gitconfig prj jobs@JobVersions {..} = do
385385

386386
-- docspec
387387
when docspecEnabled $ githubRun "docspec" $ do
388-
let docspecOptions = cfgDocspecOptions cfgDocspec
389-
let range = Range (cfgDocspecEnabled cfgDocspec)
390388
-- we need to rebuild, if tests screwed something.
391-
sh_if range "$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH all"
392-
sh_if range $ unwords $ "cabal-docspec $ARG_COMPILER" : docspecOptions
389+
sh_if docspecRange "$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH all"
390+
sh_if docspecRange cabalDocspec
393391

394392
-- hlint
395393
when (cfgHLintEnabled cfgHLint) $ githubRun "hlint" $ do
@@ -440,6 +438,8 @@ makeGitHub _argv config@Config {..} gitconfig prj jobs@JobVersions {..} = do
440438
let allFlags = unwords (testFlag : benchFlag : constraintFlags)
441439

442440
sh_cs $ "$CABAL v2-build $ARG_COMPILER " ++ allFlags ++ " all"
441+
when (docspecEnabled && csDocspec cs) $
442+
sh_cs' docspecRange cabalDocspec
443443
when (csRunTests cs) $
444444
sh_cs' hasTests $ "$CABAL v2-test $ARG_COMPILER " ++ allFlags ++ " all"
445445
when (hasLibrary && csHaddock cs) $
@@ -555,6 +555,14 @@ makeGitHub _argv config@Config {..} gitconfig prj jobs@JobVersions {..} = do
555555
withHaddock :: String
556556
withHaddock = "--with-haddock $HADDOCK"
557557

558+
cabalDocspec :: String
559+
cabalDocspec =
560+
let docspecOptions = cfgDocspecOptions cfgDocspec in
561+
unwords $ "cabal-docspec $ARG_COMPILER" : docspecOptions
562+
563+
docspecRange :: CompilerRange
564+
docspecRange = Range (cfgDocspecEnabled cfgDocspec)
565+
558566
postgresService :: GitHubService
559567
postgresService = GitHubService
560568
{ ghServImage = "postgres:10"

0 commit comments

Comments
 (0)