-
Notifications
You must be signed in to change notification settings - Fork 70
99 lines (85 loc) · 3.31 KB
/
markdown-doctest.yml
File metadata and controls
99 lines (85 loc) · 3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: DOCS
on:
workflow_dispatch:
pull_request:
jobs:
markdown-doctest:
name: "Verify haskell snippets in markdown docs"
env:
GHCVER: 9.8.4
GHCUP_VERSION: 0.1.50.2
runs-on: ubuntu-latest
steps:
# This should happen before cache restore.
- name: Remove ~/.ghcup symlink
run: |
rm -f ~/.ghcup
- name: Cache ghcup and ghc (non-Windows)
uses: actions/cache@v4
if: runner.os != 'Windows'
with:
path: |
~/.ghcup
key: ${{ runner.os }}-ghcup-${{ env.GHCUP_VERSION }}-${{ env.GHCVER }}
- name: Cache hackage package index (non-Windows)
uses: actions/cache@v4
if: runner.os != 'Windows'
with:
path: |
~/.cache/cabal/packages
# Bump the key version to clear the cache
key: cache-cabal-packages
# NOTE: we need the cabal state as well because the executable may depend
# on shared libraries in the cabal store.
- name: Cache markdown-doctest (non-Windows)
uses: actions/cache@v4
if: runner.os != 'Windows'
with:
path: |
~/.local/state/cabal
~/.local/bin
# Bump the key version to clear the cache
key: markdown-doctest-ghc-${{ env.GHCVER }}
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
# Use a sane PATH, especially to pick the right GHC
- name: Set PATH to add .local and .ghcup
run: echo "$HOME/.local/bin:$HOME/.ghcup/bin:/bin:/usr/bin" > $GITHUB_PATH
- name: Download ghc
run: |
if ! ghc --version 2>/dev/null | grep -q "$GHCVER"
then
curl -sL -o ./ghcup https://downloads.haskell.org/~ghcup/$GHCUP_VERSION/x86_64-linux-ghcup-$GHCUP_VERSION
chmod +x ./ghcup
export GHCUP_INSTALL_BASE_PREFIX=$HOME
./ghcup install ghc $GHCVER
./ghcup set ghc $GHCVER
./ghcup install cabal
fi
# XXX update only if not present
cabal update
- name: Run markdown-doctest
run: |
if [ ! -f $HOME/.local/bin/markdown-doctest ]; then
mkdir -p $HOME/.local/bin
echo "----------------------------------------------------------------"
echo "Build markdown-doctest"
echo "----------------------------------------------------------------"
echo
# IMPORTANT: do not replace $HOME with ~, tilde is not expanded by
# shell in the middle of a command string.
cabal install markdown-doctest --project-file=cabal.project.markdown-doctest --installdir=$HOME/.local/bin --overwrite-policy=always
fi
echo "----------------------------------------------------------------"
echo "Build streamly commit: $(git rev-parse HEAD)"
echo "----------------------------------------------------------------"
echo
cabal build streamly --write-ghc-environment-files=always
echo "----------------------------------------------------------------"
echo "Run markdown-doctest"
echo "----------------------------------------------------------------"
echo
find ./docs ./core/docs -type f -name "*.md" -print0 | while IFS= read -r -d '' file; do
echo "CMD: markdown-doctest $file" && markdown-doctest "$file" || exit 1
done