|
| 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