Skip to content

Commit e2b8e89

Browse files
committed
Run cabal-docspec in CI
This allows us to include runnable examples in Haddock comments, which are tested in CI. We will be adding such a runnable example in the next commits.
1 parent 1b60c28 commit e2b8e89

File tree

2 files changed

+58
-2
lines changed

2 files changed

+58
-2
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,16 @@ jobs:
200200
run: |
201201
cabal test all -j1 --test-show-details=direct
202202
203+
- name: 🛠️ Setup cabal-docspec (Linux)
204+
if: ${{ runner.os == 'Linux' }}
205+
uses: jorisdral/actions/setup-cabal-docspec@main
206+
207+
- name: 🧪 Test with cabal-docspec (Linux)
208+
if: ${{ runner.os == 'Linux' }}
209+
run: ./scripts/test-cabal-docspec.sh
210+
env:
211+
SKIP_CABAL_BUILD: true
212+
203213
################################################################################
204214
# Lint with cabal-fmt
205215
################################################################################
@@ -211,7 +221,7 @@ jobs:
211221
uses: actions/checkout@v5
212222

213223
- name: 🛠️ Setup cabal-fmt
214-
uses: intersectMBO/lsm-tree/.github/actions/setup-cabal-fmt@main
224+
uses: jorisdral/actions/setup-cabal-fmt@main
215225
with:
216226
cabal-fmt-version: "0.1.12"
217227
ghc-version: "9.6"
@@ -277,7 +287,7 @@ jobs:
277287
uses: actions/checkout@v5
278288

279289
- name: 🛠️ Setup stylish-haskell
280-
uses: intersectMBO/lsm-tree/.github/actions/setup-stylish-haskell@main
290+
uses: jorisdral/actions/setup-stylish-haskell@main
281291
with:
282292
stylish-haskell-version: "0.15.1.0"
283293
ghc-version: "9.10"

scripts/test-cabal-docspec.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/sh
2+
3+
export LC_ALL=C.UTF-8
4+
5+
# POSIX compliant method for 'pipefail':
6+
warn=$(mktemp)
7+
8+
# Check cabal-docspec version
9+
cabal_docspec_expect_version="0.0.0.20240703"
10+
if [ "${cabal_docspec}" = "" ]; then
11+
cabal_docspec=$(which "cabal-docspec")
12+
if [ "${cabal_docspec}" = "" ]; then
13+
echo "Requires cabal-docspec ${cabal_docspec_expect_version}; no version found"
14+
exit 1
15+
fi
16+
fi
17+
cabal_docspec_actual_version="$(${cabal_docspec} --version | head -n 1)"
18+
if [ ! "${cabal_docspec_actual_version}" = "${cabal_docspec_expect_version}" ]; then
19+
echo "Expected cabal-docspec ${cabal_docspec_expect_version}; version ${cabal_docspec_actual_version} found"
20+
echo > "$warn"
21+
fi
22+
23+
# Test Haskell files with cabal-docspec
24+
echo "Testing Haskell files with cabal-docspec version ${cabal_docspec_actual_version}..."
25+
# shellcheck disable=SC2016
26+
if [ "${SKIP_CABAL_BUILD}" = "" ]; then
27+
if ! cabal build all; then
28+
exit 1
29+
fi
30+
fi
31+
${cabal_docspec} \
32+
-Wno-cpphs \
33+
-Wno-missing-module-file \
34+
-Wno-skipped-property \
35+
-XOverloadedStrings \
36+
--extra-package async \
37+
|| exit 1
38+
39+
# Check whether any warning was issued; on CI, warnings are errors
40+
if [ "${CI}" = "true" ] && [ -s "$warn" ]; then
41+
rm "$warn"
42+
exit 1
43+
else
44+
rm "$warn"
45+
exit 0
46+
fi

0 commit comments

Comments
 (0)