-
Notifications
You must be signed in to change notification settings - Fork 0
199 lines (174 loc) · 6.29 KB
/
ci.yaml
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
name: CI
on:
push:
branches:
- main
pull_request:
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
# Stack
stack:
name: Stack / GHC ${{ matrix.ghc }}
runs-on: ubuntu-latest
strategy:
matrix:
ghc: ["8.6", "8.8", "8.10", "9.0", "9.2", "9.4", "9.6"]
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
with:
show-progress: false
- name: Setup Haskell
uses: haskell-actions/setup@v2
id: setup-haskell
with:
enable-stack: true
stack-no-global: true
- name: General Setup
run: |
cp .ci/stack-${{ matrix.ghc }}.yaml stack.yaml
# Print out some information for debugging purposes
ghc --version
stack --version
cat stack.yaml
- name: Restore cached dependencies
uses: actions/cache/restore@v3
id: cache
with:
path: ${{ steps.setup-haskell.outputs.stack-root }}/snapshots
key:
${{ runner.os }}-stack-${{ matrix.ghc }}-${{
hashFiles('prettyprinter-interp.cabal', 'stack.yaml') }}
restore-keys: ${{ runner.os }}-stack-${{ matrix.ghc }}-
- name: Install dependencies
run: stack build --test --only-dependencies
# Cache dependencies already at this point, so that we do not have to
# rebuild them should the subsequent steps fail
- name: Save cached dependencies
uses: actions/cache/save@v3
# Trying to save over an existing cache gives distracting
# "Warning: Cache save failed." since they are immutable
if: steps.cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.setup-haskell.outputs.stack-root }}/snapshots
key: ${{ steps.cache.outputs.cache-primary-key }}
- name: Build
# 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.
run : stack build --pedantic
- name: Test
run : stack test
# Cabal
cabal:
name: Cabal / GHC ${{ matrix.ghc }} ${{ matrix.project-variant }}
runs-on: ubuntu-latest
strategy:
matrix:
ghc: ["8.6.5", "8.8.4", "8.10.7", "9.0.2", "9.2.8", "9.4.7", "9.6.3"]
project-variant: [""]
include:
- ghc: 8.6.5
project-variant: -lower
- ghc: 9.8.1
project-variant: -upper
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
with:
show-progress: false
- name: Setup Haskell
uses: haskell-actions/setup@v2
id: setup-haskell
with:
ghc-version: ${{ matrix.ghc }}
cabal-update: false
- name: General Setup
run: |
cp .ci/cabal.project.local${{ matrix.project-variant}} \
cabal.project.local
# Print out some information for debugging purposes
ghc --version
cabal --version
cat cabal.project.local
- name: Setup CI
# This generates dist-newstyle/cache/plan.json with hashes for all
# dependencies, for cache invalidation.
run: |
cabal v2-update
cabal v2-build all --enable-tests --dry-run
- name: Restore cached dependencies
uses: actions/cache/restore@v3
id: cache
env:
key:
${{ runner.os }}-ghc-${{ matrix.ghc }}-cabal-${{
steps.setup-haskell.outputs.cabal-version }}${{
matrix.project-variant }}
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key:
${{ env.key }}-${{ hashFiles('cabal.project.local',
'dist-newstyle/cache/plan.json') }}
restore-keys: ${{ env.key }}-
- name: Install dependencies
run: cabal v2-build all --enable-tests --only-dependencies
# Cache dependencies already at this point, so that we do not have to
# rebuild them should the subsequent steps fail
- name: Save cached dependencies
uses: actions/cache/save@v3
# Trying to save over an existing cache gives distracting
# "Warning: Cache save failed." since they are immutable
if: steps.cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key: ${{ steps.cache.outputs.cache-primary-key }}
- name: Build
run: cabal v2-build all --enable-tests
- name: Test
run: cabal v2-test --test-show-details=direct
# Mechanism copied from https://github.com/clash-lang/clash-compiler/
all:
name: All jobs finished
if: ${{ !cancelled() }}
needs:
- cabal
- stack
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
show-progress: false
- name: Check dependencies for failures
run: |
# Test all dependencies for success/failure
set -x
# True if at least one dependency succeeded
success="${{ contains(needs.*.result, 'success') }}"
# True if at least one dependency failed
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
# Currently, ubuntu-latest already has it installed, but keep it around in
# case they ever change that
#
# - 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