Skip to content

Commit bcf60c3

Browse files
committed
added doctests
1 parent 8adb1f8 commit bcf60c3

File tree

9 files changed

+273
-111
lines changed

9 files changed

+273
-111
lines changed

.github/workflows/haskell-ci.yml

Lines changed: 33 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1+
name: build
12
on: [push]
2-
name: haskell-ci
3+
4+
# INFO: The following configuration block ensures that only one build runs per branch,
5+
# which may be desirable for projects with a costly build process.
6+
# Remove this block from the CI workflow to let each CI job run to completion.
7+
concurrency:
8+
group: build-${{ github.ref }}
9+
cancel-in-progress: true
10+
311
jobs:
412
hlint:
513
runs-on: ubuntu-latest
614
steps:
7-
- uses: actions/checkout@v3
15+
- uses: actions/checkout@v4
816
- uses: haskell-actions/hlint-setup@v2
917
- uses: haskell-actions/hlint-run@v2
1018
with:
@@ -13,94 +21,70 @@ jobs:
1321
ormolu:
1422
runs-on: ubuntu-latest
1523
steps:
16-
- uses: actions/checkout@v3
17-
- uses: haskell-actions/run-ormolu@v14
18-
19-
cabal:
24+
- uses: actions/checkout@v4
25+
- uses: haskell-actions/run-ormolu@v16
26+
build:
2027
name: GHC ${{ matrix.ghc-version }} on ${{ matrix.os }}
2128
runs-on: ${{ matrix.os }}
2229
strategy:
2330
fail-fast: false
2431
matrix:
2532
os: [ubuntu-latest]
26-
ghc-version: ['9.6', '9.4', '9.2', '8.10']
27-
docspec: [false]
28-
experimental: [false]
33+
ghc-version: ['9.10', '9.8', '9.6']
2934

3035
include:
3136
- os: windows-latest
32-
ghc-version: '9.6'
37+
ghc-version: '9.8'
3338
- os: macos-latest
34-
ghc-version: '9.6'
35-
- os: ubuntu-latest
36-
ghc-version: '9.6'
37-
docspec: true
38-
experimental: true
39-
name: docspec
39+
ghc-version: '9.8'
4040

4141
steps:
42-
- uses: actions/checkout@v3
42+
- uses: actions/checkout@v4
4343

4444
- name: Set up GHC ${{ matrix.ghc-version }}
45-
uses: haskell/actions/setup@v2
45+
uses: haskell-actions/setup@v2
4646
id: setup
4747
with:
4848
ghc-version: ${{ matrix.ghc-version }}
4949

50-
- name: Installed minor versions of GHC and Cabal
51-
shell: bash
52-
run: |
53-
GHC_VERSION=$(ghc --numeric-version)
54-
CABAL_VERSION=$(cabal --numeric-version)
55-
echo "GHC_VERSION=${GHC_VERSION}" >> "${GITHUB_ENV}"
56-
echo "CABAL_VERSION=${CABAL_VERSION}" >> "${GITHUB_ENV}"
57-
5850
- name: Configure the build
5951
run: |
6052
cabal configure --enable-tests --enable-benchmarks --disable-documentation
6153
cabal build --dry-run
6254
# The last step generates dist-newstyle/cache/plan.json for the cache key.
6355

6456
- name: Restore cached dependencies
65-
uses: actions/cache/restore@v3
57+
uses: actions/cache/restore@v4
6658
id: cache
59+
env:
60+
key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }}
6761
with:
6862
path: ${{ steps.setup.outputs.cabal-store }}
69-
key: ${{ runner.os }}-ghc-${{ env.GHC_VERSION }}-cabal-${{ env.CABAL_VERSION }}-plan-${{ hashFiles('**/plan.json') }}
70-
restore-keys: |
71-
${{ runner.os }}-ghc-${{ env.GHC_VERSION }}-cabal-${{ env.CABAL_VERSION }}-
63+
key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
64+
restore-keys: ${{ env.key }}-
7265

7366
- name: Install dependencies
67+
# If we had an exact cache hit, the dependencies will be up to date.
68+
if: steps.cache.outputs.cache-hit != 'true'
7469
run: cabal build all --only-dependencies
7570

7671
# Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail.
7772
- name: Save cached dependencies
78-
uses: actions/cache/save@v3
79-
# Caches are immutable, trying to save with the same key would error.
80-
if: ${{ !steps.cache.outputs.cache-hit
81-
|| steps.cache.outputs.cache-primary-key != steps.cache.outputs.cache-matched-key }}
73+
uses: actions/cache/save@v4
74+
# If we had an exact cache hit, trying to save the cache would error because of key clash.
75+
if: steps.cache.outputs.cache-hit != 'true'
8276
with:
8377
path: ${{ steps.setup.outputs.cabal-store }}
8478
key: ${{ steps.cache.outputs.cache-primary-key }}
8579

8680
- name: Build
8781
run: cabal build all
8882

89-
- name: Run tests
90-
run: cabal test all
83+
- if: ${{ matrix.os == 'ubuntu-latest' && matrix.ghc-version == '9.8'}}
84+
name: doctests
85+
run: |
86+
cabal run doctests
87+
cabal run markup-parse-diff
9188
9289
- name: Check cabal file
9390
run: cabal check
94-
95-
- if: matrix.docspec
96-
name: cabal-docspec
97-
run: |
98-
mkdir -p $HOME/.cabal/bin
99-
echo "$HOME/.cabal/bin" >> $GITHUB_PATH
100-
curl -sL https://github.com/phadej/cabal-extras/releases/download/cabal-docspec-0.0.0.20230406/cabal-docspec-0.0.0.20230406-x86_64-linux.xz > cabal-docspec.xz
101-
echo '68fa9addd5dc453d533a74a763950499d4593b1297c9a05c3ea5bd1acc04c9dd cabal-docspec.xz' | sha256sum -c -
102-
xz -d < cabal-docspec.xz > $HOME/.cabal/bin/cabal-docspec
103-
rm -f cabal-docspec.xz
104-
chmod a+x $HOME/.cabal/bin/cabal-docspec
105-
$HOME/.cabal/bin/cabal-docspec --version
106-
cabal-docspec

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ cabal.project.local*
66
/.hie/
77
.ghc.environment.*
88
/.hkgr/
9+
/checklist.org

cabal.project

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
packages: markup-parse.cabal
22

3+
write-ghc-environment-files: always

markup-parse.cabal

Lines changed: 20 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 3.0
22
name: markup-parse
3-
version: 0.1.1
3+
version: 0.1.1.1
44
license: BSD-3-Clause
55
license-file: LICENSE
66
copyright: Copyright, Tony Day, 2023-
@@ -13,12 +13,15 @@ synopsis: A markup parser.
1313
description:
1414
A markup parser and printer, from and to strict bytestrings, optimised for speed.
1515
build-type: Simple
16-
tested-with: GHC == 9.6.2
16+
tested-with:
17+
, GHC == 9.10.1
18+
, GHC == 9.6.5
19+
, GHC == 9.8.2
1720
extra-doc-files:
1821
ChangeLog.md
1922
other/*.html
2023
other/*.svg
21-
readme.org
24+
readme.md
2225

2326
source-repository head
2427
type: git
@@ -40,69 +43,16 @@ common ghc-options-stanza
4043
-Wredundant-constraints
4144

4245
common ghc2021-stanza
43-
if impl ( ghc >= 9.2 )
44-
default-language: GHC2021
45-
46-
if impl ( ghc < 9.2 )
47-
default-language: Haskell2010
48-
default-extensions:
49-
BangPatterns
50-
BinaryLiterals
51-
ConstrainedClassMethods
52-
ConstraintKinds
53-
DeriveDataTypeable
54-
DeriveFoldable
55-
DeriveFunctor
56-
DeriveGeneric
57-
DeriveLift
58-
DeriveTraversable
59-
DoAndIfThenElse
60-
EmptyCase
61-
EmptyDataDecls
62-
EmptyDataDeriving
63-
ExistentialQuantification
64-
ExplicitForAll
65-
FlexibleContexts
66-
FlexibleInstances
67-
ForeignFunctionInterface
68-
GADTSyntax
69-
GeneralisedNewtypeDeriving
70-
HexFloatLiterals
71-
ImplicitPrelude
72-
InstanceSigs
73-
KindSignatures
74-
MonomorphismRestriction
75-
MultiParamTypeClasses
76-
NamedFieldPuns
77-
NamedWildCards
78-
NumericUnderscores
79-
PatternGuards
80-
PolyKinds
81-
PostfixOperators
82-
RankNTypes
83-
RelaxedPolyRec
84-
ScopedTypeVariables
85-
StandaloneDeriving
86-
StarIsType
87-
TraditionalRecordSyntax
88-
TupleSections
89-
TypeApplications
90-
TypeOperators
91-
TypeSynonymInstances
92-
93-
if impl ( ghc < 9.2 ) && impl ( ghc >= 8.10 )
94-
default-extensions:
95-
ImportQualifiedPost
96-
StandaloneKindSignatures
46+
default-language: GHC2021
9747

9848
library
9949
import: ghc-options-stanza
10050
import: ghc2021-stanza
10151
hs-source-dirs: src
10252
build-depends:
103-
, base >=4.7 && <5
53+
, base >=4.14 && <5
10454
, bytestring >=0.11.3 && <0.13
105-
, containers >=0.6 && <0.7
55+
, containers >=0.6 && <0.8
10656
, deepseq >=1.4.4 && <1.6
10757
, flatparse >=0.3.5 && <0.6
10858
, string-interpolate >=0.3 && <0.4
@@ -115,19 +65,28 @@ library
11565
MarkupParse.FlatParse
11666
MarkupParse.Patch
11767

68+
test-suite doctests
69+
import: ghc2021-stanza
70+
main-is: doctests.hs
71+
hs-source-dirs: test
72+
build-depends:
73+
, base >=4.14 && <5
74+
, doctest-parallel >=0.3 && <0.4
75+
ghc-options: -threaded
76+
type: exitcode-stdio-1.0
77+
11878
test-suite markup-parse-diff
11979
import: ghc-options-exe-stanza
12080
import: ghc-options-stanza
12181
import: ghc2021-stanza
12282
main-is: diff.hs
12383
hs-source-dirs: app
12484
build-depends:
125-
, base >=4.7 && <5
85+
, base >=4.14 && <5
12686
, bytestring >=0.11.3 && <0.13
12787
, markup-parse
12888
, string-interpolate >=0.3 && <0.4
12989
, tasty >=1.2 && <1.6
13090
, tasty-golden >=2.3.1.1 && <2.4
13191
, tree-diff >=0.3 && <0.4
13292
type: exitcode-stdio-1.0
133-
File renamed without changes.

0 commit comments

Comments
 (0)