|
| 1 | +# SPDX-License-Identifier: MPL-2.0 |
| 2 | +# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk> |
| 3 | + |
| 4 | +name: FFI Full Integration |
| 5 | + |
| 6 | +permissions: |
| 7 | + contents: read |
| 8 | + |
| 9 | +on: |
| 10 | + push: |
| 11 | + branches: [main] |
| 12 | + paths: |
| 13 | + - 'src/**' |
| 14 | + - 'ffi/zig/**' |
| 15 | + - 'proven-ffi.ipkg' |
| 16 | + - 'scripts/build-refc.sh' |
| 17 | + - '.github/workflows/ffi-full-integration.yml' |
| 18 | + pull_request: |
| 19 | + branches: [main] |
| 20 | + paths: |
| 21 | + - 'src/**' |
| 22 | + - 'ffi/zig/**' |
| 23 | + - 'proven-ffi.ipkg' |
| 24 | + - 'scripts/build-refc.sh' |
| 25 | + - '.github/workflows/ffi-full-integration.yml' |
| 26 | + workflow_dispatch: |
| 27 | + |
| 28 | +concurrency: |
| 29 | + group: ffi-full-integration-${{ github.ref }} |
| 30 | + cancel-in-progress: true |
| 31 | + |
| 32 | +jobs: |
| 33 | + idris-refc-zig: |
| 34 | + name: Idris -> RefC -> Zig |
| 35 | + runs-on: ubuntu-latest |
| 36 | + timeout-minutes: 45 |
| 37 | + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository |
| 38 | + |
| 39 | + env: |
| 40 | + IDRIS2_VERSION: '0.8.0' |
| 41 | + ZIG_VERSION: '0.15.2' |
| 42 | + |
| 43 | + steps: |
| 44 | + - name: Checkout proven |
| 45 | + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 |
| 46 | + with: |
| 47 | + persist-credentials: false |
| 48 | + |
| 49 | + - name: Check language-bridges credential |
| 50 | + id: bridge-token |
| 51 | + env: |
| 52 | + LANGUAGE_BRIDGES_TOKEN: ${{ secrets.LANGUAGE_BRIDGES_TOKEN }} |
| 53 | + run: | |
| 54 | + set -euo pipefail |
| 55 | + if [ -z "$LANGUAGE_BRIDGES_TOKEN" ]; then |
| 56 | + echo "available=false" >> "$GITHUB_OUTPUT" |
| 57 | + echo "::notice::LANGUAGE_BRIDGES_TOKEN is not configured; skipping private full FFI integration." |
| 58 | + else |
| 59 | + echo "available=true" >> "$GITHUB_OUTPUT" |
| 60 | + fi |
| 61 | +
|
| 62 | + - name: Checkout language-bridges |
| 63 | + if: steps.bridge-token.outputs.available == 'true' |
| 64 | + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 |
| 65 | + with: |
| 66 | + repository: nextgen-languages/language-bridges |
| 67 | + path: nextgen-languages/language-bridges |
| 68 | + token: ${{ secrets.LANGUAGE_BRIDGES_TOKEN }} |
| 69 | + persist-credentials: false |
| 70 | + |
| 71 | + - name: Install Idris 2 dependencies |
| 72 | + if: steps.bridge-token.outputs.available == 'true' |
| 73 | + run: | |
| 74 | + set -euo pipefail |
| 75 | + sudo apt-get update |
| 76 | + sudo apt-get install -y chezscheme libgmp-dev |
| 77 | +
|
| 78 | + - name: Cache Idris 2 |
| 79 | + if: steps.bridge-token.outputs.available == 'true' |
| 80 | + id: cache-idris2 |
| 81 | + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 |
| 82 | + with: |
| 83 | + path: | |
| 84 | + ~/.idris2 |
| 85 | + ~/idris2-${{ env.IDRIS2_VERSION }} |
| 86 | + key: idris2-refc-${{ env.IDRIS2_VERSION }}-${{ runner.os }} |
| 87 | + |
| 88 | + - name: Install Idris 2 |
| 89 | + if: steps.bridge-token.outputs.available == 'true' && steps.cache-idris2.outputs.cache-hit != 'true' |
| 90 | + run: | |
| 91 | + set -euo pipefail |
| 92 | + git clone --depth 1 --branch v${{ env.IDRIS2_VERSION }} https://github.com/idris-lang/Idris2.git ~/idris2-${{ env.IDRIS2_VERSION }} |
| 93 | + cd ~/idris2-${{ env.IDRIS2_VERSION }} |
| 94 | + make bootstrap SCHEME=chezscheme |
| 95 | + make install |
| 96 | +
|
| 97 | + - name: Add Idris 2 to PATH |
| 98 | + if: steps.bridge-token.outputs.available == 'true' |
| 99 | + run: echo "$HOME/.idris2/bin" >> "$GITHUB_PATH" |
| 100 | + |
| 101 | + - name: Setup Zig |
| 102 | + if: steps.bridge-token.outputs.available == 'true' |
| 103 | + uses: mlugg/setup-zig@e7d1537c378b83b8049f65dda471d87a2f7b2df2 # v1 |
| 104 | + with: |
| 105 | + version: ${{ env.ZIG_VERSION }} |
| 106 | + |
| 107 | + - name: Build Idris RefC output |
| 108 | + if: steps.bridge-token.outputs.available == 'true' |
| 109 | + run: scripts/build-refc.sh --verbose |
| 110 | + |
| 111 | + - name: Build and test libproven |
| 112 | + if: steps.bridge-token.outputs.available == 'true' |
| 113 | + run: | |
| 114 | + set -euo pipefail |
| 115 | + IDRIS2_PREFIX="$(idris2 --prefix)" |
| 116 | + REFC_RUNTIME="$(find "$IDRIS2_PREFIX" -path '*/support/refc' -type d 2>/dev/null | head -1)" |
| 117 | + C_SUPPORT="$(find "$IDRIS2_PREFIX" -path '*/support/c' -type d 2>/dev/null | head -1)" |
| 118 | + SUPPORT_LIB_FILE="$(find "$IDRIS2_PREFIX" -path '*/lib/libidris2_support.*' 2>/dev/null | head -1)" |
| 119 | +
|
| 120 | + test -n "$REFC_RUNTIME" |
| 121 | + test -n "$C_SUPPORT" |
| 122 | + test -n "$SUPPORT_LIB_FILE" |
| 123 | + SUPPORT_LIB="$(dirname "$SUPPORT_LIB_FILE")" |
| 124 | + test -d "$GITHUB_WORKSPACE/build/refc" |
| 125 | + test -d "$REFC_RUNTIME" |
| 126 | + test -d "$C_SUPPORT" |
| 127 | + test -d "$SUPPORT_LIB" |
| 128 | +
|
| 129 | + cd ffi/zig |
| 130 | + zig build \ |
| 131 | + -Didris-refc="$GITHUB_WORKSPACE/build/refc" \ |
| 132 | + -Didris-refc-runtime="$REFC_RUNTIME" \ |
| 133 | + -Didris-c-support="$C_SUPPORT" \ |
| 134 | + -Didris-support-lib="$SUPPORT_LIB" |
| 135 | + zig build test \ |
| 136 | + -Didris-refc="$GITHUB_WORKSPACE/build/refc" \ |
| 137 | + -Didris-refc-runtime="$REFC_RUNTIME" \ |
| 138 | + -Didris-c-support="$C_SUPPORT" \ |
| 139 | + -Didris-support-lib="$SUPPORT_LIB" |
| 140 | + ls -la zig-out/lib/libproven.* |
0 commit comments