Skip to content

Commit 972a63e

Browse files
authored
Merge pull request #4869 from unisonweb/topic/jit-error-detection
Check the exit code during native evaluation
2 parents 957ee53 + 500fb36 commit 972a63e

File tree

3 files changed

+67
-35
lines changed

3 files changed

+67
-35
lines changed

.github/workflows/ci.yaml

Lines changed: 50 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
with:
6565
commit_message: automatically run ormolu
6666
build-ucm:
67-
name: Build UCM ${{ matrix.os }}
67+
name: build ucm
6868
runs-on: ${{ matrix.os }}
6969
strategy:
7070
# Run each build to completion, regardless of if any have failed
@@ -207,7 +207,7 @@ jobs:
207207
cache-prefix: ci
208208

209209
transcripts:
210-
name: Run transcripts
210+
name: run transcripts
211211
needs: build-ucm
212212
runs-on: ${{ matrix.os }}
213213
strategy:
@@ -278,7 +278,7 @@ jobs:
278278
echo "passing=true" >> "${{env.transcript_test_results}}"
279279
280280
interpreter-tests:
281-
name: Run interpreter tests
281+
name: run interpreter tests
282282
needs: build-ucm
283283
runs-on: ${{ matrix.os }}
284284
strategy:
@@ -342,12 +342,13 @@ jobs:
342342
cat unison-src/builtin-tests/interpreter-tests.output.md
343343
git diff --exit-code unison-src/builtin-tests/interpreter-tests.output.md
344344
- name: mark interpreter tests as passing
345+
if: steps.cache-interpreter-test-results.outputs.cache-hit != 'true'
345346
run: |
346347
echo "passing=true" >> "${{env.interpreter_test_results}}"
347348
348349
generate-jit-source:
349350
if: always() && needs.build-ucm.result == 'success'
350-
name: Generate JIT source
351+
name: generate jit source
351352
needs: build-ucm
352353
runs-on: ubuntu-20.04
353354
steps:
@@ -433,7 +434,7 @@ jobs:
433434

434435
build-jit-binary:
435436
if: always() && needs.generate-jit-source.result == 'success'
436-
name: Build JIT binary ${{ matrix.os }}
437+
name: build jit binary
437438
needs: generate-jit-source
438439
runs-on: ${{ matrix.os }}
439440
strategy:
@@ -470,46 +471,75 @@ jobs:
470471
echo "jit_dist_exe=$jit_dist_exe" >> $GITHUB_ENV
471472
echo "ucm=$ucm" >> $GITHUB_ENV
472473
473-
- name: restore jit binaries
474-
id: restore-jit-binaries
474+
- name: cache jit binaries
475+
id: cache-jit-binaries
475476
uses: actions/cache@v4
476477
with:
477478
path: ${{ env.jit_dist }}
478-
key: jit_dist-racket_${{ env.racket_version }}.jit_${{ env.jit_version }}
479+
key: jit_dist-${{ matrix.os }}.racket_${{ env.racket_version }}.jit_${{ env.jit_version }}
479480

480481
- name: Cache Racket dependencies
481-
if: steps.restore-jit-binaries.outputs.cache-hit != 'true'
482+
if: steps.cache-jit-binaries.outputs.cache-hit != 'true'
482483
uses: actions/cache@v4
483484
with:
484485
path: |
485486
~/.cache/racket
486487
~/.local/share/racket
487-
key: ${{ runner.os }}-racket-${{env.racket_version}}
488+
key: ${{ matrix.os }}-racket-${{env.racket_version}}
489+
488490
- uses: Bogdanp/setup-racket@v1.11
489-
if: steps.restore-jit-binaries.outputs.cache-hit != 'true'
491+
if: steps.cache-jit-binaries.outputs.cache-hit != 'true'
490492
with:
491493
architecture: x64
492494
distribution: full
493495
variant: CS
494496
version: ${{env.racket_version}}
495-
- uses: awalsh128/cache-apt-pkgs-action@latest
496-
if: runner.os == 'Linux' && steps.restore-jit-binaries.outputs.cache-hit != 'true'
497+
498+
- uses: actions/checkout@v4
499+
with:
500+
sparse-checkout: |
501+
scripts/get-share-hash.sh
502+
scheme-libs
503+
unison-src/builtin-tests/jit-tests.tpl.md
504+
unison-src/transcripts-using-base/serialized-cases/case-00.v4.ser
505+
506+
- name: look up hash for runtime tests
507+
run: |
508+
echo "runtime_tests_causalhash=$(scripts/get-share-hash.sh ${{env.runtime_tests_version}})" >> $GITHUB_ENV
509+
510+
- name: cache jit test results
511+
id: cache-jit-test-results
512+
uses: actions/cache@v4
513+
with:
514+
path: ${{env.jit_test_results}}
515+
key: jit-test-results.${{ matrix.os }}.racket_${{ env.racket_version }}.jit_${{ env.jit_version }}.tests_${{env.runtime_tests_causalhash}}
516+
517+
- name: install libb2 (linux)
518+
uses: awalsh128/cache-apt-pkgs-action@latest
519+
if: |
520+
runner.os == 'Linux'
521+
&& steps.cache-jit-test-results.outputs.cache-hit != 'true'
497522
# read this if a package isn't installing correctly
498523
# https://github.com/awalsh128/cache-apt-pkgs-action#caveats
499524
with:
500525
packages: libb2-dev
501526
version: 1.0 # cache key version afaik
527+
528+
- name: install libb2 (macos)
529+
if: |
530+
runner.os == 'macOS'
531+
&& steps.cache-jit-test-results.outputs.cache-hit != 'true'
532+
run: brew install libb2
533+
502534
- name: download jit source
503-
if: steps.restore-jit-binaries.outputs.cache-hit != 'true'
535+
if: steps.cache-jit-binaries.outputs.cache-hit != 'true'
504536
uses: actions/download-artifact@v4
505537
with:
506538
name: jit-source
507539
path: ${{ env.jit_src_scheme }}
508540

509-
- uses: actions/checkout@v4 # checkout scheme-libs from unison repo
510-
511541
- name: build jit binary
512-
if: steps.restore-jit-binaries.outputs.cache-hit != 'true'
542+
if: steps.cache-jit-binaries.outputs.cache-hit != 'true'
513543
shell: bash
514544
run: |
515545
cp -R scheme-libs/racket/* "$jit_src_scheme"
@@ -523,25 +553,14 @@ jobs:
523553
name: jit-binary-${{ matrix.os }}
524554
path: ${{ env.jit_dist }}/**
525555

526-
- name: look up hash for runtime tests
527-
run: |
528-
echo "runtime_tests_causalhash=$(scripts/get-share-hash.sh ${{env.runtime_tests_version}})" >> $GITHUB_ENV
529-
530-
- name: cache jit test results
531-
id: cache-jit-test-results
532-
uses: actions/cache@v4
533-
with:
534-
path: ${{env.jit_test_results}}
535-
key: jit-test-results.racket_${{ env.racket_version }}.jit_${{ env.jit_version }}.tests_${{env.runtime_tests_causalhash}}
536-
537556
- name: cache testing codebase
538557
id: cache-testing-codebase
539558
if: steps.cache-jit-test-results.outputs.cache-hit != 'true'
540559
uses: actions/cache@v4
541560
with:
542561
path: ${{ env.runtime_tests_codebase }}
543-
key: runtime-tests-codebase-${{env.runtime_tests_causalhash}}
544-
restore-keys: runtime-tests-codebase-
562+
key: runtime-tests-codebase-${{ matrix.os }}-${{env.runtime_tests_causalhash}}
563+
restore-keys: runtime-tests-codebase-${{ matrix.os }}-
545564

546565
- name: download ucm
547566
if: steps.cache-jit-test-results.outputs.cache-hit != 'true'
@@ -565,6 +584,7 @@ jobs:
565584
git diff --exit-code unison-src/builtin-tests/jit-tests.output.md
566585
567586
- name: mark jit tests as passing
587+
if: runner.os != 'Windows' && steps.cache-jit-test-results.outputs.cache-hit != 'true'
568588
run: |
569589
echo "passing=true" >> "${{env.jit_test_results}}"
570590

.mergify.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
pull_request_rules:
22
- name: automatic merge on CI success and review
33
conditions:
4-
- status-success=ubuntu-20.04
5-
- status-success=macOS-12
6-
- status-success=windows-2019
4+
- check-success=build ucm (ubuntu-20.04)
5+
- check-success=build ucm (macOS-12)
6+
- check-success=build ucm (windows-2019)
7+
- check-success=run transcripts (ubuntu-20.04)
8+
- check-success=run transcripts (macOS-12)
9+
- check-success=run transcripts (windows-2019)
10+
- check-success=run interpreter tests (ubuntu-20.04)
11+
- check-success=run interpreter tests (macOS-12)
12+
# - check-success=run interpreter tests (windows-2019)
13+
- check-success=generate jit source
14+
- check-success=build jit binary (ubuntu-20.04)
15+
- check-success=build jit binary (macOS-12)
16+
- check-success=build jit binary (windows-2019)
717
- label=ready-to-merge
818
- "#approved-reviews-by>=1"
919
actions:

parser-typechecker/src/Unison/Runtime/Interface.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -835,8 +835,10 @@ nativeEvalInContext executable _ ctx codes base = do
835835
UnliftIO.hClose pin
836836
let unit = Data RF.unitRef 0 [] []
837837
sunit = Data RF.pairRef 0 [] [unit, unit]
838-
waitForProcess ph
839-
decodeResult $ Right sunit
838+
waitForProcess ph >>= \case
839+
ExitSuccess -> decodeResult $ Right sunit
840+
ExitFailure _ ->
841+
pure . Left $ "native evaluation failed"
840842
-- TODO: actualy receive output from subprocess
841843
-- decodeResult . deserializeValue =<< BS.hGetContents pout
842844
callout _ _ _ _ =

0 commit comments

Comments
 (0)