-
Notifications
You must be signed in to change notification settings - Fork 273
441 lines (405 loc) · 17.9 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
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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
name: CI
defaults:
run:
shell: bash
on:
# Build on every pull request (and new PR commit)
pull_request:
# Build on new pushes to trunk (E.g. Merge commits)
# Without the branch filter, each commit on a branch with a PR is triggered twice.
# See: https://github.community/t/how-to-trigger-an-action-on-push-or-pull-request-but-not-both/16662
push:
branches:
- trunk
tags:
- release/*
workflow_dispatch:
env:
ormolu_version: "0.5.0.1"
racket_version: "8.7"
jit_version: "@unison/internal/releases/0.0.10"
jit_src_scheme: "unison-jit-src/scheme-libs/racket"
jit_bin: "unison-jit-bin"
jit_generator_os: ubuntu-20.04
jobs:
ormolu:
runs-on: ubuntu-20.04
# Only run formatting on trunk commits
# This is because the job won't have permission to push back to
# contributor forks on contributor PRs.
if: github.ref_name == 'trunk'
steps:
- uses: actions/checkout@v4
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v41
with:
# globs copied from default settings for run-ormolu
files: |
**/*.hs
**/*.hs-boot
separator: "\n"
- uses: haskell-actions/run-ormolu@v14
with:
version: ${{ env.ormolu_version }}
mode: inplace
pattern: ${{ steps.changed-files.outputs.all_changed_files }}
- name: apply formatting changes
uses: stefanzweifel/git-auto-commit-action@v4
if: ${{ always() }}
with:
commit_message: automatically run ormolu
build-ucm:
name: Build UCM ${{ matrix.os }}
runs-on: ${{ matrix.os }}
if: ${{ always() }}
needs: ormolu
strategy:
# Run each build to completion, regardless of if any have failed
fail-fast: false
matrix:
os:
# While iterating on this file, you can disable one or more of these to speed things up
- ubuntu-20.04
- macOS-12
- windows-2019
steps:
- uses: actions/checkout@v4
# The number towards the beginning of the cache keys allow you to manually avoid using a previous cache.
# GitHub will automatically delete caches that haven't been accessed in 7 days, but there is no way to
# purge one manually.
- id: stackage-resolver
name: record stackage resolver
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#environment-files
# looks for `resolver: nightly-yyyy-mm-dd` or `resolver: lts-xx.yy` in `stack.yaml` and splits it into
# `nightly` or `lts-xx`. the whole resolver string is put into resolver_long as a backup cache key
# ${{ steps.stackage-resolver.outputs.resolver_short }}
# ${{ steps.stackage-resolver.outputs.resolver_long }}
run: |
grep resolver stack.yaml | awk '{ x="resolver_short="; if (split($2,a,"-") > 2) print x a[1]; else {split($2,b,"."); print x b[1]}}' >> "$GITHUB_OUTPUT"
grep resolver stack.yaml | awk '{print "resolver_long="$2}' >> "$GITHUB_OUTPUT"
# Cache ~/.stack, keyed by the contents of 'stack.yaml'.
- uses: actions/cache@v4
name: cache ~/.stack (unix)
if: runner.os != 'Windows'
with:
path: ~/.stack
key: stack-1_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_long }}-${{hashFiles('**/stack.yaml')}}-${{github.sha}}
# Fall-back to use the most recent cache for the stack.yaml, or failing that the OS
restore-keys: |
stack-1_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_long }}-${{hashFiles('**/stack.yaml')}}-
stack-1_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_long }}-
stack-1_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_short }}-
stack-1_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_short }}.
stack-1_${{matrix.os}}-
# Cache ~/.stack, keyed by the contents of 'stack.yaml'.
- uses: actions/cache@v4
name: cache ~/.stack (Windows)
if: runner.os == 'Windows'
with:
save-always: true
path: |
C:\Users\runneradmin\AppData\Roaming\stack
C:\Users\runneradmin\AppData\Local\Programs\stack
key: stack-1_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_long }}-${{hashFiles('**/stack.yaml')}}-${{github.sha}}
# Fall-back to use the most recent cache for the stack.yaml, or failing that the OS
restore-keys: |
stack-1_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_long }}-${{hashFiles('**/stack.yaml')}}-
stack-1_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_long }}-
stack-1_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_short }}-
stack-1_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_short }}.
stack-1_${{matrix.os}}-
# Cache each local package's ~/.stack-work for fast incremental builds in CI.
- uses: actions/cache@v4
name: cache .stack-work
with:
save-always: true
path: |
**/.stack-work
# Main cache key: commit hash. This should always result in a cache miss...
# So when loading a cache we'll always fall back to the restore-keys,
# which should load the most recent cache via a prefix search on the most
# recent branch cache.
# Then it will save a new cache at this commit sha, which should be used by
# the next build on this branch.
key: stack-work-4_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_short }}-${{hashFiles('**/stack.yaml')}}-${{github.sha}}
restore-keys: |
stack-work-4_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_long }}-${{hashFiles('**/stack.yaml')}}-
stack-work-4_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_long }}-
stack-work-4_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_short }}-
stack-work-4_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_short }}.
stack-work-4_${{matrix.os}}-
# Install stack by downloading the binary from GitHub.
# The installation process differs by OS.
- name: install stack (Linux)
if: runner.os == 'Linux'
working-directory: ${{ runner.temp }}
run: |
mkdir stack && cd stack
curl -L https://github.com/commercialhaskell/stack/releases/download/v2.9.1/stack-2.9.1-linux-x86_64.tar.gz | tar -xz
echo "$PWD/stack-"* >> $GITHUB_PATH
- name: install stack (macOS)
working-directory: ${{ runner.temp }}
if: runner.os == 'macOS'
run: |
mkdir stack && cd stack
curl -L https://github.com/commercialhaskell/stack/releases/download/v2.9.1/stack-2.9.1-osx-x86_64.tar.gz | tar -xz
echo "$PWD/stack-"* >> $GITHUB_PATH
- name: install stack (windows)
working-directory: ${{ runner.temp }}
if: runner.os == 'Windows'
run: |
mkdir stack && cd stack
curl -L https://github.com/commercialhaskell/stack/releases/download/v2.9.1/stack-2.9.1-windows-x86_64.tar.gz | tar -xz
echo "$PWD/stack-"* >> $GITHUB_PATH
# One of the transcripts fails if the user's git name hasn't been set.
- name: set git user info
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
- name: remove ~/.stack/setup-exe-cache on macOS
if: runner.os == 'macOS'
run: rm -rf ~/.stack/setup-exe-cache
# Build deps, then build local code. Splitting it into two steps just allows us to see how much time each step
# takes.
- name: build dependencies
# Run up to 5 times in a row before giving up.
# It's very unlikely that our build-dependencies step will fail on most builds,
# so if it fails its almost certainly due to a race condition on the Windows
# file-system API that stack runs into. Since any successful packages are
# cached within a single build, it should get further along on each re-start
# and should hopefully finish!
run: |
stack --version
tries=1
if [[ ${{matrix.os}} = "windows-"* ]]; then
tries=5
fi
for (( i = 0; i < $tries; i++ )); do
stack --no-terminal build --fast --only-dependencies && break;
done
- name: build
run: stack --no-terminal build --fast --no-run-tests --test
- name: output ucm path
id: ucm-path
run: |
echo "ucm-path=$(stack exec -- which unison)" >> $GITHUB_OUTPUT
cp "$(stack exec -- which unison)" .
# Run each test suite (tests and transcripts)
# - name: check disk space before
# if: ${{ always() }}
# run: df -h
# - name: unison-cli test
# run: stack --no-terminal build --fast --test unison-cli
# - name: check disk space after
# if: ${{ always() }}
# run: df -h
# - name: unison-core tests
# run: stack --no-terminal build --fast --test unison-core
# - name: unison-parser-typechecker tests
# run: stack --no-terminal build --fast --test unison-parser-typechecker
# - name: unison-sqlite tests
# run: stack --no-terminal build --fast --test unison-sqlite
# - name: unison-syntax tests
# run: stack --no-terminal build --fast --test unison-syntax
# - name: unison-util-bytes tests
# run: stack --no-terminal build --fast --test unison-util-bytes
# - name: unison-util-cache tests
# run: stack --no-terminal build --fast --test unison-util-cache
# - name: unison-util-relation tests
# run: stack --no-terminal build --fast --test unison-util-relation
# - name: round-trip-tests
# run: |
# stack --no-terminal exec unison transcript unison-src/transcripts-round-trip/main.md
# git add unison-src/transcripts-round-trip/main.output.md
# # Fail if any transcripts cause git diffs.
# git diff --cached --ignore-cr-at-eol --exit-code
# stack --no-terminal exec unison transcript unison-src/transcripts-manual/rewrites.md
# git add unison-src/transcripts-manual/rewrites.output.md
# # Fail if any transcripts cause git diffs.
# git diff --cached --ignore-cr-at-eol --exit-code
# - name: transcripts
# run: |
# stack --no-terminal exec transcripts
# # Add all changes to the index for when we diff.
# git add --all
# # Fail if any transcripts cause git diffs.
# git diff --cached --ignore-cr-at-eol --exit-code
# - name: cli-integration-tests
# run: stack --no-terminal exec cli-integration-tests
# - name: verify stack ghci startup
# if: runner.os == 'macOS'
# run: echo | stack ghci
- name: debug check ucm artifact
run: ls -l ${{ steps.ucm-path.outputs.ucm-path }}
- name: save ucm artifact
uses: actions/upload-artifact@v4
with:
name: unison-${{ matrix.os }}
path: ${{ steps.ucm-path.outputs.ucm-path }}
if-no-files-found: error
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
# if: ${{ always() }}
generate-jit-source:
name: Generate JIT source
needs: build-ucm
runs-on: ubuntu-20.04
steps:
- name: set up environment
run: |
echo "jit_src_scheme=${{ runner.temp }}/${{ env.jit_src_scheme }}" >> $GITHUB_ENV
echo "ucm=${{ runner.temp }}/unison-${{ matrix.os }}" >> $GITHUB_ENV
- uses: actions/cache@v4
name: cache jit source
if: runner.os == 'Linux'
with:
path: ${{ env.jit_src_scheme }}
key: jit_src_scheme.racket_${{env.racket_version}}.jit_${{env.jit_src_scheme}}.${{github.sha}}
restore-keys: jit_src_scheme.racket_${{env.racket_version}}.jit_${{env.jit_src_scheme}}.
- name: check source exists
id: jit_src_exists
uses: thebinaryfelix/check-file-existence-action@v1
with:
files: "${{ env.jit_src_scheme }}/unison/{data-info,boot-generated,simple-wrappers,builtin-generated,compound-wrappers}.ss"
- name: create transcript
if: steps.jit_src_exists.outputs.exists == 'false'
uses: 1arp/[email protected]
with:
file: 'setup-jit.md'
content: |
```ucm
.> project.create-empty jit-setup
jit-setup/main> pull ${{ env.jit_version }} lib.jit
```
```unison
generateSchemeBoot dir = do
saveDataInfoFile dir dataInfos
saveBaseFile dir bootSpec
saveWrapperFile dir simpleWrapperSpec
saveBaseFile dir builtinSpec
saveWrapperFile dir compoundWrapperSpec
go = generateSchemeBoot "${{ env.jit_src_scheme }}"
```
```ucm
jit-setup/main> run go
```
- name: download ucm artifact
if: steps.jit_src_exists.outputs.exists == 'false'
uses: actions/download-artifact@v4
with:
name: unison-${{ env.jit_generator_os }}
path: ${{ runner.temp }}
- name: generate source
if: steps.jit_src_exists.outputs.exists == 'false'
run: |
cp -R scheme-libs/racket/* ${{ env.jit_src_scheme }}
chmod +x ${{ env.ucm }}
${{ env.ucm }} transcript setup-jit.md
- name: save jit source
if: steps.jit_src_exists.outputs.exists == 'false'
uses: actions/upload-artifact@v4
with:
name: jit-source
path: ${{ env.jit_src_scheme }}/**
build-jit-binary:
name: Build JIT binary ${{ matrix.os }}
needs: [build-ucm, generate-jit-source]
runs-on: ${{ matrix.os }}
strategy:
# Run each build to completion, regardless of if any have failed
fail-fast: false
matrix:
os:
# While iterating on this file, you can disable one or more of these to speed things up
- ubuntu-20.04
- macOS-12
- windows-2019
steps:
- name: set up environment
run: |
echo "jit_src_scheme=${{ runner.temp }}/${{ env.jit_src_scheme }}" >> $GITHUB_ENV
echo "jit_bin=${{ runner.temp }}/${{ env.jit_bin }}" >> $GITHUB_ENV
echo "ucm=${{ runner.temp }}/unison-${{ matrix.os }}" >> $GITHUB_ENV
- name: cache jit binaries
uses: actions/cache@v4
with:
path: ${{ env.jit_bin }}
key: jit_bin.racket_${{ env.racket_version }}.jit_${{ env.jit_src_scheme }}.${{ github.sha }}
restore-keys: jit_bin.racket_${{ env.racket_version }}.jit_${{ env.jit_src_scheme }}.
- name: check binary exists
id: jit_bin_exists
uses: thebinaryfelix/check-file-existence-action@v1
with:
files: "${{ env.jit_bin }}/unison-runtime"
- name: Cache Racket dependencies
if: steps.jit_bin_exists.outputs.exists == 'false'
uses: actions/cache@v4
with:
path: |
~/.cache/racket
~/.local/share/racket
key: ${{ runner.os }}-racket-${{env.racket_version}}
- uses: Bogdanp/[email protected]
# if: steps.jit_bin_exists.outputs.exists == 'false'
with:
architecture: 'x64'
distribution: 'full'
variant: 'CS'
version: ${{env.racket_version}}
- uses: awalsh128/cache-apt-pkgs-action@latest
# read this if a package isn't installing correctly
# https://github.com/awalsh128/cache-apt-pkgs-action#caveats
with:
packages: libb2-dev
version: 1.0 # cache key version afaik
- name: download jit source
# if: steps.jit_src_exists.outputs.exists == 'false'
uses: actions/download-artifact@v4
with:
name: jit-source
path: ${{ env.jit_src_scheme }}
- uses: actions/checkout@v4 # checkout scheme-libs from unison repo
# if: steps.jit_src_exists.outputs.exists == 'false'
- name: download ucm
# if: steps.jit_bin_exists.outputs.exists == 'false'
uses: actions/download-artifact@v4
with:
name: unison-${{ matrix.os }}
path: ${{ runner.temp }}
- run: |
chmod +x ${{ env.ucm }}
${{ env.ucm }} transcript setup-jit.md
- name: build jit binary
# if: steps.jit_bin_exists.outputs.exists == 'false'
run: |
cp -R scheme-libs/racket/* ${{ env.jit_src_scheme }}
raco pkg install --auto ${{ env.jit_src_scheme }}/unison
raco exe ${{ env.jit_src_scheme }}/unison-runtime.rkt
raco distribute ${{ env.jit_bin }} ${{ env.jit_src_scheme }}
- name: save jit binary
# if: steps.jit_bin_exists.outputs.exists == 'false'
uses: actions/upload-artifact@v4
with:
name: jit-binary-${{ matrix.os }}
path: ${{ env.jit_bin }}/**
- name: jit tests ${{ matrix.os }}
# if: steps.jit_bin_exists.outputs.exists == 'false'
run: |
time ${{ env.ucm }} transcript unison-src/builtin-tests/jit-tests.md
cat unison-src/builtin-tests/jit-tests.output.md
CHANGE=$(git diff unison-src/builtin-tests/jit-tests.output.md)
if [ -n "$CHANGE" ]; then
echo "The jit-tests output has changed"
exit 1
fi
- name: interpreter tests
# if: steps.jit_bin_exists.outputs.exists == 'false'
run: |
time ${{ env.ucm }} transcript unison-src/builtin-tests/interpreter-tests.md
cat unison-src/builtin-tests/interpreter-tests.output.md
CHANGE=$(git diff unison-src/builtin-tests/interpreter-tests.output.md)
if [ -n "$CHANGE" ]; then
echo "The interpreter-tests output has changed"
exit 1
fi