-
Notifications
You must be signed in to change notification settings - Fork 154
240 lines (199 loc) · 7.48 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
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 }}-latest
strategy:
fail-fast: false
matrix:
os: ["macOS", "windows"]
ghc: ["8.6", "8.8", "8.10", "9.0", "9.2", "9.4", "9.6", "9.8"]
exclude:
# Some tests fail with a mysterious -11 error code.
- os: macOS
ghc: 8.10
# Windows gets non-deterministically gets stuck in infinite loops
# or segfaults while running the testcase.
- os: windows
ghc: 8.8
# GHC 9.0 fails to compile clash-cores due to a template haskell
# failure
- os: windows
ghc: 9.0
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: matrix.os == 'macOS'
run: brew install icarus-verilog
- name: Install IVerilog (Windows)
if: 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: Cache (Windows)
if: ${{ runner.os == 'Windows' }}
uses: actions/cache@v4
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: Cache (non-Windows)
if: ${{ runner.os != 'Windows' }}
uses: actions/cache@v4
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
# 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.6.5", "9.0.2", "9.6.6" ]
include:
- multiple_hidden: yes
- ghc: 8.6.5
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 }}-20241008
env:
THREADS: 2
CABAL_JOBS: 2
MULTIPLE_HIDDEN: ${{ matrix.multiple_hidden }}
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: |
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@v4
with:
path: |
dist-newstyle
~/.cabal/store
key: ${{ matrix.ghc }}-${{ hashFiles('frozen', 'cabal.project') }}
restore-keys: ${{ matrix.ghc }}-
- name: Build Clash
run: |
export CABAL_DIR=$HOME/.cabal
./.ci/build.sh
- name: Unit Tests
if: github.ref != 'refs/heads/master'
run: |
export CABAL_DIR=$HOME/.cabal
cabal v2-test clash-prelude
cabal v2-test clash-lib
cabal v2-test clash-cores
cabal v2-test clash-cosim
- 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: always()
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