Skip to content

Commit 6d9696b

Browse files
committed
ci: add AffineScript compile-verification workflow
Verifies changed .affine files against the canonical compiler (hyperpolymath/affinescript, pinned by commit SHA) via `affinescript check`. Runs only when .affine files change. https://claude.ai/code/session_01GTo7dz32ZgxuHXefv8BGqn
1 parent eba80d2 commit 6d9696b

1 file changed

Lines changed: 95 additions & 0 deletions

File tree

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# SPDX-License-Identifier: PMPL-1.0-or-later
2+
name: AffineScript Verify
3+
on: [push, pull_request]
4+
5+
permissions:
6+
contents: read
7+
8+
# Compile-verifies changed `.affine` files with the canonical AffineScript
9+
# compiler (hyperpolymath/affinescript). The compiler is pinned to a commit
10+
# SHA for reproducibility; bump COMPILER_REF deliberately.
11+
env:
12+
COMPILER_REPO: hyperpolymath/affinescript
13+
COMPILER_REF: d2875a552f1d389b4a60c4adfdc02ae53e36aca3
14+
15+
jobs:
16+
verify:
17+
name: AffineScript Verify
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
steps:
22+
- name: Checkout standards
23+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Determine changed .affine files
28+
id: changed
29+
run: |
30+
if [ "${{ github.event_name }}" = "pull_request" ]; then
31+
BASE="${{ github.event.pull_request.base.sha }}"
32+
else
33+
BASE="${{ github.event.before }}"
34+
fi
35+
if [ -z "$BASE" ] || ! git cat-file -e "$BASE^{commit}" 2>/dev/null \
36+
|| printf '%s' "$BASE" | grep -qE '^0+$'; then
37+
BASE="$(git rev-parse HEAD^ 2>/dev/null || git rev-parse HEAD)"
38+
fi
39+
FILES="$(git diff --name-only --diff-filter=ACMR "$BASE" HEAD -- '*.affine' || true)"
40+
if [ -z "$FILES" ]; then
41+
echo "any=false" >> "$GITHUB_OUTPUT"
42+
echo "No changed .affine files — nothing to verify."
43+
else
44+
echo "any=true" >> "$GITHUB_OUTPUT"
45+
echo "Changed .affine files:"
46+
echo "$FILES"
47+
{ echo 'files<<EOF'; echo "$FILES"; echo 'EOF'; } >> "$GITHUB_OUTPUT"
48+
fi
49+
50+
- name: Checkout AffineScript compiler
51+
if: steps.changed.outputs.any == 'true'
52+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
53+
with:
54+
repository: ${{ env.COMPILER_REPO }}
55+
ref: ${{ env.COMPILER_REF }}
56+
path: .affinescript-compiler
57+
58+
- name: Set up OCaml
59+
if: steps.changed.outputs.any == 'true'
60+
uses: ocaml/setup-ocaml@e32b06a3e831ff2fbc6f08cf35be2085e3918014 # v3
61+
with:
62+
ocaml-compiler: "5.1"
63+
64+
- name: Build compiler
65+
if: steps.changed.outputs.any == 'true'
66+
working-directory: .affinescript-compiler
67+
run: |
68+
opam install . --deps-only
69+
opam exec -- dune build
70+
71+
- name: Verify changed .affine files
72+
if: steps.changed.outputs.any == 'true'
73+
working-directory: .affinescript-compiler
74+
run: |
75+
set -u
76+
rc=0
77+
while IFS= read -r f; do
78+
[ -z "$f" ] && continue
79+
abs="$GITHUB_WORKSPACE/$f"
80+
echo "::group::check $f"
81+
if opam exec -- dune exec affinescript -- check "$abs"; then
82+
echo "✅ $f"
83+
else
84+
echo "❌ $f failed AffineScript check"
85+
rc=1
86+
fi
87+
echo "::endgroup::"
88+
done <<'EOF'
89+
${{ steps.changed.outputs.files }}
90+
EOF
91+
if [ "$rc" -ne 0 ]; then
92+
echo "AffineScript verification failed."
93+
exit 1
94+
fi
95+
echo "All changed .affine files passed AffineScript verification."

0 commit comments

Comments
 (0)