diff --git a/.github/workflows/abi-ffi-gate.yml b/.github/workflows/abi-ffi-gate.yml index f8bd0d4..64be656 100644 --- a/.github/workflows/abi-ffi-gate.yml +++ b/.github/workflows/abi-ffi-gate.yml @@ -44,3 +44,66 @@ jobs: echo "/tmp/zig-linux-x86_64-0.14.0" >> "$GITHUB_PATH" - name: zig test FFI run: zig test src/interface/ffi/src/main.zig -lc + + idris2-check: + name: Idris2 ABI type-check (Idris2 0.8.0, total) + runs-on: ubuntu-latest + timeout-minutes: 45 + steps: + - uses: actions/checkout@v7.0.1 + - name: Install Idris2 0.8.0 from the pinned upstream commit + env: + # Exact commit referenced by the upstream v0.8.0 tag. + IDRIS2_REVISION: 15a3e4e70843f7a34100f6470c04b791330788df + run: | + set -euo pipefail + sudo apt-get update -qq + sudo apt-get install -y chezscheme make libgmp-dev + git clone --filter=blob:none --no-checkout \ + https://github.com/idris-lang/Idris2.git /tmp/idris2 + git -C /tmp/idris2 checkout --detach "$IDRIS2_REVISION" + make -C /tmp/idris2 bootstrap SCHEME=scheme + make -C /tmp/idris2 install PREFIX="$HOME/.idris2" + echo "$HOME/.idris2/bin" >> "$GITHUB_PATH" + - name: Every ABI module is listed in the package + working-directory: src/interface/abi + run: | + set -euo pipefail + # A module missing from the .ipkg is never type-checked here. + files=$(find . -name '*.idr' -not -path './build/*' \ + | sed 's|^\./||; s|\.idr$||; s|/|.|g' | sort) + # Comments are dropped first: a module named only after -- is not built. + listed=$(sed -n '/^modules/,/^[a-z]/p' mylangiser-abi.ipkg \ + | sed 's/--.*$//' \ + | grep -oE '[A-Z][A-Za-z0-9_.]+' | sort -u) + missing=$(comm -23 <(echo "$files") <(echo "$listed")) + if [ -n "$missing" ]; then + echo "::error::Idris2 modules not listed in mylangiser-abi.ipkg: $missing" + exit 1 + fi + - name: No holes or escape hatches in the ABI proofs + working-directory: src/interface/abi + run: | + set -euo pipefail + # Idris2 accepts a ?hole and these escape hatches even under + # --total, so a green type-check alone would not show the proofs + # are complete. + pattern='(^|[^A-Za-z0-9_])\?[a-z_][A-Za-z0-9_]*|believe_me|assert_total|assert_smaller|idris_crash|%default[[:space:]]+(partial|covering)|^[[:space:]]*(partial|covering)[[:space:]]' + hits=$(find . -name '*.idr' -not -path './build/*' -print0 \ + | xargs -0 grep -nE "$pattern" \ + | grep -vE '^[^:]+:[0-9]+:[[:space:]]*(--|\|\|\|)' || true) + if [ -n "$hits" ]; then + echo "::error::Holes or escape hatches in the ABI proofs:" + echo "$hits" + exit 1 + fi + - name: Type-check with totality enforced + working-directory: src/interface/abi + run: | + set -euo pipefail + idris2 --version + # Totality comes from opts in the .ipkg. Given --total here, Idris2 + # 0.8.0 prints an options error, checks nothing and exits 0. + grep -Eq '^opts[[:space:]]*=[[:space:]]*".*--total' mylangiser-abi.ipkg \ + || { echo "::error::mylangiser-abi.ipkg must set opts = \"--total\""; exit 1; } + idris2 --typecheck mylangiser-abi.ipkg diff --git a/src/interface/abi/mylangiser-abi.ipkg b/src/interface/abi/mylangiser-abi.ipkg index 7bbc742..05367b3 100644 --- a/src/interface/abi/mylangiser-abi.ipkg +++ b/src/interface/abi/mylangiser-abi.ipkg @@ -7,3 +7,11 @@ modules = Mylangiser.ABI.Types , Mylangiser.ABI.Layout , Mylangiser.ABI.Foreign , Mylangiser.ABI.Proofs + , Mylangiser.ABI.Semantics + , Mylangiser.ABI.Invariants + , Mylangiser.ABI.FfiSeam + , Mylangiser.ABI.Capstone + +-- Totality is set here: Idris2 0.8.0 refuses --total as a command-line +-- override for package commands and then checks nothing. +opts = "--total"