Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/abi-ffi-gate.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This workflow is managed by gh actions-lock.

Check warning on line 1 in .github/workflows/abi-ffi-gate.yml

View workflow job for this annotation

GitHub Actions / Hypatia neurosymbolic scan

[hypatia] Job `zig-build` in abi-ffi-gate.yml has no `timeout-minutes:` declaration. Default is 6 hours — a stuck codeload fetch or runner hang can burn budget. Add `timeout-minutes: 10` (or proportional).

Check warning on line 1 in .github/workflows/abi-ffi-gate.yml

View workflow job for this annotation

GitHub Actions / Hypatia neurosymbolic scan

[hypatia] Job `conformance` in abi-ffi-gate.yml has no `timeout-minutes:` declaration. Default is 6 hours — a stuck codeload fetch or runner hang can burn budget. Add `timeout-minutes: 10` (or proportional).
# SPDX-License-Identifier: MPL-2.0
# abi-ffi-gate.yml — enforce that the Zig FFI conforms to the Idris2 ABI.
#
Expand Down Expand Up @@ -44,3 +44,66 @@
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
8 changes: 8 additions & 0 deletions src/interface/abi/mylangiser-abi.ipkg
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Loading