Skip to content

Commit d0bdd55

Browse files
committed
Merge branch 'trunk' into transcripts-cleanup
2 parents ab75cc8 + 2f0c2e5 commit d0bdd55

40 files changed

+1339
-1027
lines changed

.github/workflows/bundle-ucm.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,15 @@ jobs:
159159
distribution: "full"
160160
variant: "CS"
161161
version: ${{env.racket_version}}
162-
- uses: awalsh128/cache-apt-pkgs-action@latest
163-
if: runner.os == 'Linux'
164-
with:
165-
packages: libb2-dev
166-
version: 1.0 # cache key version afaik
167162
- name: install unison racket lib
168163
if: steps.cache-racket-deps.outputs.cache-hit != 'true'
169164
run: raco pkg install --auto scheme-libs/racket/unison.zip
165+
- name: install libb2 (macos)
166+
if: runner.os == 'macOS'
167+
run: |
168+
brew install libb2
169+
ln -s "$(brew --prefix)"/lib/libb2.*.dylib \
170+
"$(dirname "$(readlink -f "$(which raco)")")"/../lib/
170171
- name: build unison-runtime
171172
run: |
172173
raco exe --embed-dlls --orig-exe scheme-libs/racket/unison-runtime.rkt
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: build jit binary
2+
3+
on:
4+
workflow_call:
5+
6+
defaults:
7+
run:
8+
shell: bash
9+
10+
env:
11+
jit_src: unison-jit-src/
12+
jit_dist: unison-jit-dist/
13+
racket_version: "8.7"
14+
15+
jobs:
16+
build-jit-binary:
17+
name: build jit binary
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
os: [ubuntu-20.04, macOS-12, windows-2019]
22+
runs-on: ${{matrix.os}}
23+
steps:
24+
- name: set up environment
25+
run: |
26+
jit_src="$GITHUB_WORKSPACE/${{ env.jit_src }}" # scheme source
27+
jit_exe="${jit_src}/unison-runtime" # initially built jit
28+
jit_dist="${{ runner.temp }}/${{ env.jit_dist }}" # jit binary with libraries destination
29+
jit_dist_exe="${jit_dist}/bin/unison-runtime" # jit binary itself
30+
ucm="${{ runner.temp }}/unison"
31+
32+
if [[ ${{runner.os}} = "Windows" ]]; then
33+
jit_src="${jit_src//\\//}"
34+
jit_dist="${jit_dist//\\//}"
35+
36+
jit_exe="${jit_exe//\\//}.exe"
37+
jit_dist_exe="${jit_dist//\\//}/unison-runtime.exe"
38+
ucm="${ucm//\\//}.exe"
39+
fi
40+
41+
echo "jit_src=$jit_src" >> $GITHUB_ENV
42+
echo "jit_exe=$jit_exe" >> $GITHUB_ENV
43+
echo "jit_dist=$jit_dist" >> $GITHUB_ENV
44+
echo "jit_dist_exe=$jit_dist_exe" >> $GITHUB_ENV
45+
echo "ucm=$ucm" >> $GITHUB_ENV
46+
47+
- name: get workflow files, for checking hashes
48+
uses: actions/checkout@v4
49+
with:
50+
sparse-checkout: .github
51+
52+
- name: download jit source
53+
uses: actions/download-artifact@v4
54+
with:
55+
name: jit-source
56+
path: ${{ env.jit_src }}
57+
58+
- name: cache/restore jit binaries
59+
id: cache-jit-binaries
60+
uses: actions/cache/restore@v4
61+
with:
62+
path: ${{ env.jit_dist }}
63+
key: jit-dist_${{matrix.os}}.racket_${{env.racket_version}}.jit-src_${{hashFiles(format('{0}/**.rkt',env.jit_src),format('{0}/**.ss',env.jit_src))}}.yaml_${{hashFiles('**/ci-build-jit-binary.yaml')}}
64+
65+
- name: cache racket dependencies
66+
if: steps.cache-jit-binaries.outputs.cache-hit != 'true'
67+
uses: actions/cache@v4
68+
with:
69+
path: |
70+
~/.cache/racket
71+
~/.local/share/racket
72+
key: ${{ matrix.os }}.racket_${{env.racket_version}}.yaml_${{hashFiles('**/ci-build-jit-binary.yaml')}}
73+
74+
- name: install racket
75+
if: steps.cache-jit-binaries.outputs.cache-hit != 'true'
76+
uses: unisonweb/actions/racket/install@buildjet-cache
77+
with:
78+
version: ${{env.racket_version}}
79+
80+
- name: set up redistributables (macos)
81+
if: runner.os == 'macOS' && steps.cache-jit-binaries.outputs.cache-hit != 'true'
82+
run: |
83+
brew install libb2
84+
racket_lib_dir="$(dirname "$(readlink -f "$(which raco)")")/../lib"
85+
ln -s "$(brew --prefix)"/lib/libb2.*.dylib "$racket_lib_dir/"
86+
87+
- name: build jit binary
88+
if: steps.cache-jit-binaries.outputs.cache-hit != 'true'
89+
shell: bash
90+
run: |
91+
if [[ ${{runner.os}} = "Windows" ]]; then
92+
raco pkg install --auto --skip-installed --scope installation x509-lib
93+
elif [[ ${{runner.os}} = "macOS" ]]; then
94+
raco pkg install --auto --skip-installed --scope installation x509-lib
95+
elif [[ ${{runner.os}} = "Linux" ]]; then
96+
sudo raco pkg install --auto --skip-installed --scope installation x509-lib
97+
fi
98+
raco pkg install --auto --skip-installed "$jit_src"/unison
99+
raco exe --embed-dlls "$jit_src"/unison-runtime.rkt
100+
raco distribute -v "$jit_dist" "$jit_exe"
101+
102+
- name: cache/save jit binaries
103+
if: steps.cache-jit-binaries.outputs.cache-hit != 'true'
104+
uses: actions/cache/save@v4
105+
with:
106+
path: ${{ env.jit_dist }}
107+
key: jit-dist_${{matrix.os}}.racket_${{env.racket_version}}.jit-src_${{hashFiles(format('{0}/**.rkt',env.jit_src),format('{0}/**.ss',env.jit_src))}}.yaml_${{hashFiles('**/ci-build-jit-binary.yaml')}}
108+
109+
- name: save jit binary
110+
uses: actions/upload-artifact@v4
111+
with:
112+
name: jit-binary-${{ matrix.os }}
113+
path: ${{ env.jit_dist }}/**
114+
115+
# - name: setup tmate session
116+
# uses: mxschmitt/action-tmate@v3

.github/workflows/ci-test-jit.yaml

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
name: test jit
2+
3+
on:
4+
workflow_call:
5+
6+
env:
7+
runtime_tests_version: "@unison/runtime-tests/main"
8+
# for best results, this should match the path in ci.yaml too; but GH doesn't make it easy to share them.
9+
runtime_tests_codebase: "~/.cache/unisonlanguage/runtime-tests.unison"
10+
11+
jit_src_rel: unison-jit-src
12+
jit_dist_rel: unison-jit-dist
13+
jit_test_results: jit-test-results
14+
15+
defaults:
16+
run:
17+
shell: bash
18+
19+
jobs:
20+
build-jit-binary:
21+
name: test jit
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
os:
26+
- ubuntu-20.04
27+
- macOS-12
28+
# - windows-2019
29+
runs-on: ${{matrix.os}}
30+
steps:
31+
- name: set up environment
32+
run: |
33+
jit_src="$GITHUB_WORKSPACE/${{ env.jit_src_rel }}" # scheme source, for hashing
34+
jit_dist="$GITHUB_WORKSPACE/${{ env.jit_dist_rel }}" # jit binary with libraries destination
35+
jit_dist_exe="${jit_dist}/bin/unison-runtime" # jit binary itself
36+
jit_dist_rel_exe="${jit_dist_rel}/bin/unison-runtime" # jit binary itself
37+
ucm="${{ runner.temp }}/unison"
38+
39+
if [[ ${{runner.os}} = "Windows" ]]; then
40+
jit_src="${jit_src//\\//}"
41+
jit_dist="${jit_dist//\\//}"
42+
43+
jit_dist_exe="${jit_dist//\\//}/unison-runtime.exe"
44+
jit_dist_rel_exe="${jit_dist_rel//\\//}/unison-runtime.exe"
45+
ucm="${ucm//\\//}.exe"
46+
fi
47+
48+
echo "jit_src=$jit_src" >> $GITHUB_ENV
49+
echo "jit_dist=$jit_dist" >> $GITHUB_ENV
50+
echo "jit_dist_exe=$jit_dist_exe" >> $GITHUB_ENV
51+
echo "jit_dist_rel_exe=$jit_dist_rel_exe" >> $GITHUB_ENV
52+
echo "ucm=$ucm" >> $GITHUB_ENV
53+
54+
- uses: actions/checkout@v4
55+
with:
56+
sparse-checkout: |
57+
.github
58+
scripts/get-share-hash.sh
59+
unison-src/builtin-tests/jit-tests.tpl.md
60+
unison-src/transcripts-using-base/serialized-cases/case-00.v4.ser
61+
62+
- name: download jit binaries
63+
uses: actions/download-artifact@v4
64+
with:
65+
name: jit-binary-${{ matrix.os }}
66+
path: ${{ env.jit_dist }}
67+
68+
- name: look up hash for runtime tests
69+
run: |
70+
echo "runtime_tests_causalhash=$(scripts/get-share-hash.sh ${{ env.runtime_tests_version }})" >> $GITHUB_ENV
71+
72+
- name: cache jit test results
73+
id: cache-jit-test-results
74+
uses: actions/cache@v4
75+
with:
76+
path: ${{env.jit_test_results}}
77+
key: jit-test-results.dist-exe_${{ hashFiles(env.jit_dist_rel_exe) }}.tests_${{ env.runtime_tests_causalhash }}.yaml_${{ hashFiles('**/ci-test-jit.yaml') }}
78+
79+
- name: install libb2 (linux)
80+
uses: awalsh128/cache-apt-pkgs-action@latest
81+
if: runner.os == 'Linux' && steps.cache-jit-test-results.outputs.cache-hit != 'true'
82+
with:
83+
packages: libb2-1
84+
version: 1.0 # cache key version afaik
85+
86+
- name: cache testing codebase
87+
id: cache-testing-codebase
88+
if: steps.cache-jit-test-results.outputs.cache-hit != 'true'
89+
uses: actions/cache@v4
90+
with:
91+
path: ${{ env.runtime_tests_codebase }}
92+
key: runtime-tests-codebase-${{ matrix.os }}-${{env.runtime_tests_causalhash}}
93+
restore-keys: runtime-tests-codebase-${{ matrix.os }}-
94+
95+
- name: download ucm
96+
if: steps.cache-jit-test-results.outputs.cache-hit != 'true'
97+
uses: actions/download-artifact@v4
98+
with:
99+
name: unison-${{ matrix.os }}
100+
path: ${{ runner.temp }}
101+
102+
- name: set ucm & runtime permissions
103+
if: steps.cache-jit-test-results.outputs.cache-hit != 'true'
104+
run: |
105+
chmod +x ${{ env.ucm }}
106+
chmod +x ${{ env.jit_dist_exe }}
107+
if [[ ${{runner.os}} = "Linux" ]]; then
108+
chmod +x ${{env.jit_dist}}/lib/plt/*
109+
fi
110+
111+
- name: jit integration test ${{ matrix.os }}
112+
if: steps.cache-jit-test-results.outputs.cache-hit != 'true'
113+
run: |
114+
envsubst '${runtime_tests_version}' \
115+
< unison-src/builtin-tests/jit-tests.tpl.md \
116+
> unison-src/builtin-tests/jit-tests.md
117+
${{ env.ucm }} transcript.fork --runtime-path ${{ env.jit_dist_exe }} -C ${{env.runtime_tests_codebase}} unison-src/builtin-tests/jit-tests.md
118+
cat unison-src/builtin-tests/jit-tests.output.md
119+
git diff --exit-code unison-src/builtin-tests/jit-tests.output.md
120+
121+
- name: mark jit tests as passing
122+
if: steps.cache-jit-test-results.outputs.cache-hit != 'true'
123+
run: |
124+
echo "passing=true" >> "${{env.jit_test_results}}"
125+
126+
# - name: Setup tmate session
127+
# uses: mxschmitt/action-tmate@v3
128+
# if: ${{ failure() }}
129+
# timeout-minutes: 15

0 commit comments

Comments
 (0)