generated from serokell/metatemplates
-
Notifications
You must be signed in to change notification settings - Fork 2
258 lines (223 loc) · 7.37 KB
/
ci.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# SPDX-FileCopyrightText: 2020 Kowainik
# SPDX-FileCopyrightText: 2022 Serokell <https://serokell.io/>
#
# SPDX-License-Identifier: MPL-2.0
# Sources:
# • https://github.com/kowainik/validation-selective/blob/5b46cd4810bbaa09b704062ebbfa2bb47137425d/.github/workflows/ci.yml
# • https://kodimensional.dev/github-actions
# • https://github.com/serokell/tztime/blob/main/.github/workflows/ci.yml
name: CI
# Trigger the workflow on push or pull request
on:
pull_request:
push:
branches:
- master
schedule:
- cron: '5 4 * * 6'
jobs:
xrefcheck:
if: ${{ github.event_name != 'schedule' }}
name: Verify cross references
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: serokell/xrefcheck-action@v1
with:
xrefcheck-version: '0.2.2'
reuse:
if: ${{ github.event_name != 'schedule' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: REUSE Compliance Check
uses: fsfe/reuse-action@v1
hlint:
if: ${{ github.event_name != 'schedule' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: haskell-actions/hlint-setup@v2
with:
version: '3.5'
- uses: haskell-actions/hlint-run@v2
with:
path: '["src/", "test/"]'
fail-on: warning
stylish:
if: ${{ github.event_name != 'schedule' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache binaries
id: cache-stylish
uses: actions/cache@v3
with:
path: ~/.local/bin
key: bin-stylish
- name: Setup
if: steps.cache-stylish.outputs.cache-hit != 'true'
run: |
mkdir -p "$HOME/.local/bin"
wget https://github.com/haskell/stylish-haskell/releases/download/v0.14.3.0/stylish-haskell-v0.14.3.0-linux-x86_64.tar.gz
tar -zxf stylish-haskell-v0.14.3.0-linux-x86_64.tar.gz \
--strip-components 1 \
-C "$HOME/.local/bin" \
stylish-haskell-v0.14.3.0-linux-x86_64/stylish-haskell
chmod +x "$HOME/.local/bin"/stylish-haskell
- name: Stylish Haskell
run: |
echo "$HOME/.local/bin" >> $GITHUB_PATH
./scripts/validate-stylish.sh
whitespace:
if: ${{ github.event_name != 'schedule' }}
name: Find Trailing Whitespace
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: harupy/[email protected]
cabal:
if: ${{ github.event_name != 'schedule' }}
name: ${{ matrix.os }} / ghc ${{ matrix.ghc }}
runs-on: ${{ matrix.os }}
needs: collect-ghc-versions
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
cabal: ["3.6"]
ghc: ${{ fromJSON(needs.collect-ghc-versions.outputs.ghcvers) }}
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- uses: haskell-actions/setup@v2
id: setup-haskell-cabal
name: Setup Haskell
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}
- uses: actions/cache@v3
name: Cache cabal-store
with:
path: ${{ steps.setup-haskell-cabal.outputs.cabal-store }}
key: ${{ runner.os }}-${{ matrix.ghc }}-cabal
- name: Configure
shell: bash
run: |
cat > cabal.project <<EOF
packages:
./
package hsblst
ghc-options: -Werror
EOF
- name: Build
run: |
cabal update
cabal build --enable-tests --enable-benchmarks --write-ghc-environment-files=always
- name: Test
run: |
cabal test all --enable-tests
- name: Haddock
# Run haddock for all components
run: |
cabal haddock --haddock-all
- name: Install
# Check the package actually builds from sdist
run: |
cabal install --lib
collect-ghc-versions:
if: ${{ github.event_name != 'schedule' }}
name: Extract GHC versions from tested-with package.yaml field.
runs-on: ubuntu-latest
outputs:
ghcvers: ${{ steps.ghcvers.outputs.ghcvers }}
steps:
- uses: actions/checkout@v4
- id: ghcvers
run: |
echo -n "ghcvers=" >> "$GITHUB_OUTPUT"
yq -I0 '."tested-with" | map(sub("^GHC *== *";""))' package.yaml -o json >> "$GITHUB_OUTPUT"
stack:
name: stack / ${{ matrix.resolver }}
runs-on: ubuntu-latest
strategy:
matrix:
stack: ["2.13.1"]
# Remember to update the `tested-with` section of `package.yaml`.
resolver: ["lts-21", "lts", "nightly"]
steps:
- name: Get compiler version
id: ghcver
run: |
GHCVER=$(curl -L https://www.stackage.org/${{ matrix.resolver }}/ghc-major-version)
echo "ghcver=$GHCVER" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@v4
with:
submodules: 'true'
- name: Check tested-with contains current GHC version
run: |
export GHCVER=${{ steps.ghcver.outputs.ghcver }}
yq -e '."tested-with" | contains(["GHC == " + strenv(GHCVER)])' package.yaml
- uses: haskell-actions/setup@v2
name: Setup Haskell Stack
id: setup-haskell
with:
ghc-version: ${{ steps.ghcver.outputs.ghcver }}
stack-version: ${{ matrix.stack }}
- uses: actions/cache@v3
name: Cache ~/.stack and cabal store
with:
path: |
~/.stack
${{ steps.setup-haskell.outputs.cabal-store }}
key: ${{ runner.os }}-${{ steps.ghcver.outputs.ghcver }}-stack
- name: Set stack config
run: |
stack config set system-ghc --global true
stack config set install-ghc --global false
# this is a dirty hack because using short resolver name gets an old
# resolver for some reason
RESOLVER=$(curl -w '%{redirect_url}' https://www.stackage.org/${{ matrix.resolver }} | sed 's!.*/!!')
stack config set resolver $RESOLVER
- name: Configure for Weeder
run: |
echo 'ghc-options: { "$locals": -fwrite-ide-info }' >> stack.yaml
- name: Stack build
run: |
stack build \
--test --bench --no-run-tests --no-run-benchmarks \
--ghc-options '-Werror' \
--haddock --no-haddock-deps
- name: Weeder for GHC 9.6
if: ${{ startsWith(steps.ghcver.outputs.ghcver, '9.6') }}
run: |
cabal install --installdir "$PWD" weeder
./weeder
- name: Stack test
run: |
stack test
- name: Notify on scheduled failures
if: ${{ failure() && github.event_name == 'schedule' }}
run: |
curl -XPOST https://slack.com/api/chat.postMessage \
-H "Authorization: Bearer ${{ secrets.SLACK_TOKEN }}" \
-d "channel=libraries" \
-d "text=Scheduled job failed on hsblst with resolver ${{ matrix.resolver }} ghc ${{ steps.ghcver.outputs.ghcver }}"
validate-cabal-files:
if: ${{ github.event_name != 'schedule' }}
name: Validate cabal files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- name: Get hpack
run: |
wget https://github.com/lierdakil/hpack-static/releases/download/v0.34.4/hpack.gz
gunzip hpack.gz
chmod +x hpack
- name: Generate cabalfile
run: ./hpack -f
- run: git diff hsblst.cabal
- name: Fail if .cabal file was changed
run: git diff-files --quiet hsblst.cabal || exit 1