-
Notifications
You must be signed in to change notification settings - Fork 154
282 lines (237 loc) · 9.62 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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
name: CI
on:
push:
branches:
# PRs can only use caches from their target branch. We therefore need to
# make sure we run on 'master' too.
- master
pull_request:
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
build_mac_windows:
name: Build and run limited tests
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["macOS-13", "windows-latest"]
ghc: ["8.10", "9.0", "9.2", "9.4", "9.6", "9.8"]
exclude:
# Some tests fail with a mysterious -11 error code.
- os: macOS-13
ghc: 8.10
# GHC 9.0 fails to compile clash-cores due to a template haskell
# failure
- os: windows-latest
ghc: 9.0
# GHC/Clash starts extremely slowly, see
# https://github.com/clash-lang/clash-compiler/issues/2684
- os: windows-latest
ghc: 9.6
steps:
- uses: actions/checkout@v4
- uses: haskell-actions/setup@v2
id: setup-haskell
with:
enable-stack: true
stack-no-global: true
- name: Install IVerilog (macOS)
if: ${{ startsWith(matrix.os, 'macOS') }}
run: brew install icarus-verilog
- name: Install IVerilog (Windows)
if: ${{ startsWith(matrix.os, 'windows') }}
run: choco install --no-progress iverilog
- name: General Setup
shell: bash
run: |
cp .ci/stack-${{ matrix.ghc }}.yaml stack.yaml
# Print out stack.yaml for debugging purposes
cat stack.yaml
- name: Restore cache (Windows)
if: ${{ startsWith(matrix.os, 'windows') }}
uses: actions/cache/restore@v4
id: cache-win
with:
# On windows we have to use "\" as a path separator, otherwise caching fails
path: |
${{ steps.setup-haskell.outputs.stack-root }}\snapshots
key: ${{ matrix.os }}-${{ matrix.ghc }}-${{ hashFiles('stack.yaml', '**/*.cabal', '.github/workflows/ci.yml') }}
restore-keys: ${{ matrix.os }}-${{ matrix.ghc }}-
- name: Restore cache (non-Windows)
if: ${{ !startsWith(matrix.os, 'windows') }}
uses: actions/cache/restore@v4
id: cache-other
with:
path: |
${{ steps.setup-haskell.outputs.stack-root }}/snapshots
key: ${{ matrix.os }}-${{ matrix.ghc }}-${{ hashFiles('stack.yaml', '**/*.cabal', '.github/workflows/ci.yml') }}
restore-keys: ${{ matrix.os }}-${{ matrix.ghc }}-
# https://gitlab.haskell.org/haskell/ghcup-hs/-/issues/188
# https://github.com/commercialhaskell/stack/issues/4937
# - name: Use system GHC
# run: stack config set system-ghc --global true
# Retry Stack initialization, see:
# https://github.com/commercialhaskell/stack/issues/5770
- name: Initialize Stack
shell: bash
run: ./.ci/retry.sh stack build base
# Building 'happy' sometimes fails on Windows for some obscure reason
- name: Build happy with Stack
shell: bash
run: ./.ci/retry.sh stack build happy
- name: Build dependencies
run: stack build --only-dependencies
- name: Save cache (Windows)
uses: actions/cache/save@v4
# Trying to save over an existing cache gives distracting
# "Warning: Cache save failed." since they are immutable
if: ${{ startsWith(matrix.os, 'windows') && steps.cache-win.outputs.cache-hit != 'true' }}
with:
# On windows we have to use "\" as a path separator, otherwise caching fails
path: |
${{ steps.setup-haskell.outputs.stack-root }}\snapshots
key: ${{ matrix.os }}-${{ matrix.ghc }}-${{ hashFiles('stack.yaml', '**/*.cabal', '.github/workflows/ci.yml') }}
- name: Save cache (non-Windows)
uses: actions/cache/save@v4
# Trying to save over an existing cache gives distracting
# "Warning: Cache save failed." since they are immutable
if: ${{ !startsWith(matrix.os, 'windows') && steps.cache-other.outputs.cache-hit != 'true' }}
with:
path: |
${{ steps.setup-haskell.outputs.stack-root }}/snapshots
key: ${{ matrix.os }}-${{ matrix.ghc }}-${{ hashFiles('stack.yaml', '**/*.cabal', '.github/workflows/ci.yml') }}
# Note: the --pedantic switch adds -Wall -Werror to the options passed to
# GHC. Options specified in stack.yaml (like -Wcompat) are still passed;
# it is cumulative. Future versions of Stack might add behavior to
# --pedantic.
- name: Build with Stack
run: stack build --pedantic
- name: Run Vector testsuite
if: github.ref != 'refs/heads/master'
run: stack run -- clash-testsuite --hide-successes -p .Vector. --no-ghdl --no-verilator --no-modelsim --no-vivado
build_and_test:
# Only run for external PRs
if: github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
name: Build and Test
strategy:
fail-fast: false
matrix:
ghc: [ "8.10.7", "9.0.2", "9.6.4" ]
include:
- multiple_hidden: yes
- ghc: 8.10.7
multiple_hidden: no
workaround_ghc_mmap_crash: yes
- ghc: 9.0.2
workaround_ghc_mmap_crash: yes
# Run steps inside the clash CI docker image
container:
image: ghcr.io/clash-lang/clash-ci:${{ matrix.ghc }}-20240721
env:
THREADS: 2
CABAL_JOBS: 2
CI_COMMIT_BRANCH: ${{ github.base_ref }}
WORKAROUND_GHC_MMAP_CRASH: ${{ matrix.workaround_ghc_mmap_crash }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Setup CI
run: |
# Work around dubious owner error
git config --global --add safe.directory "$(pwd)"
export CABAL_DIR=$HOME/.cabal
./.ci/setup.sh
cabal v2-freeze
# We only want this for caching, and it makes the CI scripts way
# more brittle than is ideal.
mv cabal.project.freeze frozen
- name: Restore Cache
uses: actions/cache/restore@v4
id: cache
with:
path: |
dist-newstyle
~/.cabal/store
key: ${{ matrix.ghc }}-${{ hashFiles('frozen', 'cabal.project', '**/*.cabal', '.github/workflows/ci.yml') }}
restore-keys: ${{ matrix.ghc }}-
- name: Build Clash
run: |
export CABAL_DIR=$HOME/.cabal
./.ci/build.sh
- name: Save Cache
# Trying to save over an existing cache gives distracting
# "Warning: Cache save failed." since they are immutable
if: ${{ !cancelled() && steps.cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v4
with:
path: |
dist-newstyle
~/.cabal/store
key: ${{ matrix.ghc }}-${{ hashFiles('frozen', 'cabal.project', '**/*.cabal', '.github/workflows/ci.yml') }}
- name: Unit Tests
if: github.ref != 'refs/heads/master'
run: |
export CABAL_DIR=$HOME/.cabal
cabal v2-run clash-prelude:doctests
cabal v2-run clash-prelude:unittests -- --hide-successes
cabal v2-run clash-lib:doctests
cabal v2-run clash-lib:unittests -- --hide-successes
cabal v2-run clash-cores:doctests
cabal v2-run clash-cores:unittests -- --hide-successes
cabal v2-run clash-cosim:test -- --hide-successes
- name: Testsuite (VHDL)
if: github.ref != 'refs/heads/master'
run: |
export CABAL_DIR=$HOME/.cabal
cabal v2-run clash-testsuite -- -j$THREADS --hide-successes -p .VHDL --no-vivado
- name: Testsuite (Verilog)
if: github.ref != 'refs/heads/master'
run: |
export CABAL_DIR=$HOME/.cabal
cabal v2-run clash-testsuite -- -j$THREADS --hide-successes -p .Verilog --no-vivado
- name: Testsuite (SystemVerilog)
if: github.ref != 'refs/heads/master'
run: |
export CABAL_DIR=$HOME/.cabal
cabal v2-run clash-testsuite -- -j$THREADS --hide-successes -p .SystemVerilog --no-modelsim --no-vivado
all:
name: All jobs finished
if: ${{ !cancelled() }}
needs: [
build_mac_windows,
build_and_test,
]
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check dependencies for failures
run: |
# Test all dependencies for success/failure
set -x
success="${{ contains(needs.*.result, 'success') }}"
fail="${{ contains(needs.*.result, 'failure') }}"
set +x
# Test whether success/fail variables contain sane values
if [[ "${success}" != "true" && "${success}" != "false" ]]; then exit 1; fi
if [[ "${fail}" != "true" && "${fail}" != "false" ]]; then exit 1; fi
# We want to fail if one or more dependencies fail. For safety, we introduce
# a second check: if no dependencies succeeded something weird is going on.
if [[ "${fail}" == "true" || "${success}" == "false" ]]; then
echo "One or more dependency failed, or no dependency succeeded."
exit 1
fi
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get -y install python3-yaml
- name: Check that the 'all' job depends on all other jobs
run: |
.ci/all_check.py