-
-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (71 loc) · 2.79 KB
/
Copy pathffi-seams.yml
File metadata and controls
79 lines (71 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# SPDX-License-Identifier: MPL-2.0
# Owner: Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>
# ffi-seams.yml — contract tests for the idris2 <-> zig token-buffer ABI.
#
# Runs `zig test` on idris2/ffi/zig/seams.zig, which exercises the @ptrCast
# NUL-sentinel invariant + integer/bool marshalling + i32<->usize clamping
# across the C-ABI seam (see the header of idris2/ffi/zig/seams.zig).
#
# Convention (per the estate CI rule): NO workflow-level `on.*.paths` on a
# gate — a path-filtered required check is reported "Expected" forever and
# strands PRs as blocked. Instead an always-run `changes` job decides whether
# the heavy `test` job runs; a job skipped via `if:` counts as a passing
# required check.
name: FFI Seam Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
changes:
name: Detect relevant changes
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
run: ${{ steps.detect.outputs.run }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- id: detect
env:
EVENT: ${{ github.event_name }}
BASE: ${{ github.base_ref }}
BEFORE: ${{ github.event.before }}
run: |
# Fail-safe: default to running; only set run=false when a successful
# diff shows nothing under idris2/ffi/zig/ changed.
set -uo pipefail
run=true
if [ "$EVENT" = pull_request ]; then
git fetch --no-tags --depth=200 origin "$BASE" 2>/dev/null \
&& changed=$(git diff --name-only "origin/${BASE}...HEAD" 2>/dev/null) \
&& { printf '%s\n' "$changed" | grep -qE '^idris2/ffi/zig/' && run=true || run=false; }
elif [ "$EVENT" = push ] && [ -n "$BEFORE" ] && [ "$BEFORE" != 0000000000000000000000000000000000000000 ]; then
changed=$(git diff --name-only "${BEFORE}...${GITHUB_SHA}" 2>/dev/null) \
&& { printf '%s\n' "$changed" | grep -qE '^idris2/ffi/zig/' && run=true || run=false; }
fi
printf 'run=%s\n' "$run" >> "$GITHUB_OUTPUT"
echo "relevant=$run"
test:
name: Zig FFI seam tests
needs: changes
if: needs.changes.outputs.run == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Zig
uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2
with:
version: 0.15.2
- name: Run token-buffer seam tests
# -lc: tokbuf.zig allocates via std.heap.c_allocator.
run: zig test -lc idris2/ffi/zig/seams.zig