-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (126 loc) · 4.55 KB
/
main.yml
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: "main"
on:
pull_request:
branches:
- "main"
jobs:
generate-matrix:
name: "Generate matrix from cabal"
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Extract the tested GHC versions
id: set-matrix
uses: kleidukos/[email protected]
with:
cabal-file: os-string-aeson.cabal
ubuntu-version: "latest"
windows-version: "latest"
version: 0.1.7.1
run:
name: ${{ matrix.ghc }} on ${{ matrix.os }}
needs: generate-matrix
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
steps:
- name: "Checkout repository"
uses: actions/checkout@v4
- name: "Setup Haskell environment"
id: setup
uses: haskell-actions/[email protected]
with:
ghc-version: "${{ matrix.ghc }}"
cabal-update: true
- name: "Install doctest"
id: install-doctest
shell: bash
run: |
if [[ "${RUNNER_TEMP}" == '' ]]; then
echo 'Expected $RUNNER_TEMP to be defined'
exit 1
fi
if [[ "${RUNNER_TOOL_CACHE}" == '' ]]; then
echo 'Expected $RUNNER_TOOL_CACHE to be defined'
exit 1
fi
doctest="doctest-${{ steps.setup.outputs.ghc-version }}"
if [[ "${{ runner.os }}" == 'Windows' ]]; then
doctest="${doctest}.exe"
fi
result="${RUNNER_TOOL_CACHE}/${doctest}"
if [[ ! -x "${result}" ]]; then
tmpdir="$(mktemp -d "${RUNNER_TEMP}/doctest.XXXX")"
cabal install --ignore-project --installdir "${tmpdir}" --install-method copy doctest
installed="${tmpdir}/doctest"
if [[ "${{ runner.os }}" == 'Windows' ]]; then
installed="${installed}.exe"
fi
cp "${installed}" "${result}"
fi
"${result}" --version
echo "path=${result}" >> "${GITHUB_OUTPUT}"
- name: "Configure the build"
run: |
cabal configure --enable-tests --enable-benchmarks --disable-documentation
cabal freeze
cabal build all --dry-run
- name: "Restore cached dependencies"
id: cache
uses: actions/cache/restore@v4
env:
key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }}
with:
path: ${{ steps.setup.outputs.cabal-store }}
key: ${{ env.key }}-plan-${{ hashFiles('dist-newstyle/cache/plan.json') }}
restore-keys: ${{ env.key }}-plan-
- name: "Install dependencies"
# If we had an exact cache hit, the dependencies will be up to date.
if: steps.cache.outputs.cache-hit != 'true'
run: |
cabal build all --only-dependencies
cabal build all --only-dependencies --enable-documentation
- name: "Save cached dependencies"
# Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail.
# If we had an exact cache hit, trying to save the cache would error because of key clash.
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ${{ steps.setup.outputs.cabal-store }}
key: ${{ steps.cache.outputs.cache-primary-key }}
- name: "Build"
run: cabal build all
- name: "Run tests"
run: cabal test all
- name: "Run doctests"
shell: bash
run: |
targets=(
'os-string-aeson:lib:os-string-aeson-internal'
'os-string-aeson:lib:os-string-aeson'
)
for target in "${targets[@]}"; do
cabal repl --with-compiler "${{ steps.install-doctest.outputs.path }}" --build-depends aeson "${target}"
done
- name: "Check cabal file"
run: cabal check
- name: "Build documentation"
run: cabal haddock all
# See https://github.com/orgs/community/discussions/26822#discussioncomment-8285141
# If you read this and know a better way to accomplish this: Please, file an issue!
results:
if: ${{ always() }}
runs-on: ubuntu-latest
name: "Final Results"
needs: [run]
steps:
- name: "Matrix builds succeed"
if: >-
${{
contains(needs.*.result, 'failure')
|| contains(needs.*.result, 'cancelled')
|| contains(needs.*.result, 'skipped')
}}
run: exit 1