-
Notifications
You must be signed in to change notification settings - Fork 0
243 lines (209 loc) · 7.31 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
# The matrix feature is overused because it lets us do globals and interpolation
# in more places (where we're for some reason forbidden from using workflow
# environment variables).
#
# TODO
#
# * Uploading executables by running `cabal install`, because that saves them
# to a known place. Not ideal, and we guess that "known" place.
# * `cabal build` and `cabal install` have bugs and inconsistencies, stripping
# may not work, our flags might get thrown away between `cabal` calls.
name: CI
on:
push:
branches:
- main
pull_request:
types:
- synchronize
- opened
- reopened
# If env.exe exists, jobs will build and upload the specified executable with
# optimizations (-O2). If it doesn't exist, jobs will build without
# optimizations (-O0).
#env:
# exe: bytepatch
jobs:
ubuntu-cabal-test:
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} / test / GHC ${{ matrix.ghc }}, Cabal
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
cabal: [latest]
ghc:
- 9.2.2
include:
- ghc: 9.2.2
build: release
steps:
# TODO: GHC decides to recompile based on timestamp, so cache isn't used
# Preferably GHC would work via hashes instead. Stack had this feature
# merged in Aug 2020.
# Upstream GHC issue: https://gitlab.haskell.org/ghc/ghc/-/issues/16495
# My issue on haskell/actions: https://github.com/haskell/actions/issues/41
# This also requires us to do a deep fetch, else we don't get the Git commit
# history we need to rewrite mod times.
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set all tracked file modification times to the time of their last commit
run: |
rev=HEAD
IFS=$'\n'
for f in $(git ls-tree -r -t --full-name --name-only "$rev") ; do
touch -d $(git log --pretty=format:%cI -1 "$rev" -- "$f") "$f";
done
- name: Setup Haskell build environment
id: setup-haskell-build-env
uses: haskell/actions/setup@v1
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}
- run: cabal freeze
- name: Cache Cabal build artifacts
uses: actions/cache@v2
with:
path: |
${{ steps.setup-haskell-build-env.outputs.cabal-store }}
dist-newstyle
key: test-cabal-build-artifacts-${{ runner.os }}-ghc_${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
restore-keys: test-cabal-build-artifacts-${{ runner.os }}-ghc_${{ matrix.ghc }}
- name: Build (exe)
if: "env.exe != 0 && matrix.build == 'release'"
run: cabal build -O2
- name: Build (skip exe)
if: "env.exe != 0 && matrix.build != 'release'"
run: cabal build -O0
- name: Build (no exe)
if: "env.exe == 0"
run: cabal build -O0
- name: Test
run: cabal test --test-show-details=streaming
env:
HSPEC_OPTIONS: --color
- name: Install
if: "env.exe != 0 && matrix.build == 'release'"
run: cabal install
# note that Cabal uses symlinks -- actions/upload-artifact@v2 apparently
# dereferences for us
- name: Upload executable
if: "env.exe != 0 && matrix.build == 'release'"
uses: actions/upload-artifact@v2
with:
path: ~/.cabal/bin/${{ env.exe }}
name: ${{ env.exe }}-${{ runner.os }}-ghc_${{ matrix.ghc }}-cabal-${{ github.sha }}
if-no-files-found: error
mac-cabal-test:
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} / test / GHC ${{ matrix.ghc }}, Cabal
strategy:
fail-fast: false
matrix:
os: [macos-latest]
cabal: [latest]
ghc:
- 9.2.2
include:
- ghc: 9.2.2
build: release
steps:
# TODO figure out timestamp fixer on Mac (no Mac available to test)
- uses: actions/checkout@v2
- name: Setup Haskell build environment
id: setup-haskell-build-env
uses: haskell/actions/setup@v1
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}
- run: cabal freeze
- name: Cache Cabal build artifacts
uses: actions/cache@v2
with:
path: |
${{ steps.setup-haskell-build-env.outputs.cabal-store }}
dist-newstyle
key: test-cabal-build-artifacts-${{ runner.os }}-ghc_${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
restore-keys: test-cabal-build-artifacts-${{ runner.os }}-ghc_${{ matrix.ghc }}
- name: Build (exe)
if: "env.exe != 0 && matrix.build == 'release'"
run: cabal build -O2
- name: Build (skip exe)
if: "env.exe != 0 && matrix.build != 'release'"
run: cabal build -O0
- name: Build (no exe)
if: "env.exe == 0"
run: cabal build -O0
- name: Test
run: cabal test --test-show-details=streaming
env:
HSPEC_OPTIONS: --color
- name: Install
if: "env.exe != 0 && matrix.build == 'release'"
run: cabal install
# note that Cabal uses symlinks -- actions/upload-artifact@v2 apparently
# dereferences for us
- name: Upload executable
if: "env.exe != 0 && matrix.build == 'release'"
uses: actions/upload-artifact@v2
with:
path: ~/.cabal/bin/${{ env.exe }}
name: ${{ env.exe }}-${{ runner.os }}-ghc_${{ matrix.ghc }}-cabal-${{ github.sha }}
if-no-files-found: error
windows-cabal-test:
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} / test / GHC ${{ matrix.ghc }}, Cabal
strategy:
fail-fast: false
matrix:
os: [windows-latest]
cabal: [latest]
ghc:
- 9.2.2
include:
- ghc: 9.2.2
build: release
steps:
# TODO can't do cache fixer on Windows b/c it's a Bash script...
- uses: actions/checkout@v2
- name: Setup Haskell build environment
id: setup-haskell-build-env
uses: haskell/actions/setup@v1
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}
- run: cabal freeze
- name: Cache Cabal build artifacts
uses: actions/cache@v2
with:
path: |
${{ steps.setup-haskell-build-env.outputs.cabal-store }}
dist-newstyle
key: test-cabal-build-artifacts-${{ runner.os }}-ghc_${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
restore-keys: test-cabal-build-artifacts-${{ runner.os }}-ghc_${{ matrix.ghc }}
- name: Build (exe)
if: "env.exe != 0 && matrix.build == 'release'"
run: cabal build -O2
- name: Build (skip exe)
if: "env.exe != 0 && matrix.build != 'release'"
run: cabal build -O0
- name: Build (no exe)
if: "env.exe == 0"
run: cabal build -O0
- name: Test
run: cabal test --test-show-details=streaming
env:
HSPEC_OPTIONS: --color
- name: Install
if: "env.exe != 0 && matrix.build == 'release'"
run: cabal install
# note that Cabal uses symlinks -- actions/upload-artifact@v2 apparently
# dereferences for us
- name: Upload executable
if: "env.exe != 0 && matrix.build == 'release'"
uses: actions/upload-artifact@v2
with:
path: C:/cabal/bin/${{ env.exe }}.exe
name: ${{ env.exe }}-${{ runner.os }}-ghc_${{ matrix.ghc }}-cabal-${{ github.sha }}
if-no-files-found: error