Change: Both JustAPP and JustAPIApp both will work

swadhinbiswas committed 2 months ago
19b8875
1 parent ebc90d9
commit 19b8875
3 files changed
+34 -19
▼.github/workflows/ci.yml
+1-1
69
69
- name: Install Rust nightly + Miri
70
70
uses: dtolnay/rust-toolchain@nightly
71
71
with:
72
- components: miri
72
+ components: miri, rust-src
73
73
74
74
- name: Cache cargo registry
75
75
uses: actions/cache@v4
76
76
▼.github/workflows/wheels.yml
+1-1
40
40
- uses: actions/checkout@v4
41
41
- uses: dtolnay/rust-toolchain@nightly
42
42
with:
43
- components: miri
43
+ components: miri, rust-src
44
44
- name: Run memory-safety gate
45
45
# Fast: ASan on the full core suite + targeted Miri on the only
46
46
# unsafe module (memory.rs). See scripts/sanitize.sh.
47
47
▼scripts/sanitize.sh
+32-17
11
11
# 2. A targeted Miri run on just memory.rs's unsafe (via its #[cfg(miri)]
12
12
# test) — covers the only UB-sensitive code path.
13
13
#
14
-# Prereqs: rustup nightly with miri, zig not needed. ASan needs
15
-# `-Zbuild-std` (builds std instrumented) because of proc-macro crates
16
-# (time) that break under blanket RUSTFLAGS sanitizer.
14
+# Prereqs: rustup nightly with miri + rust-src (added automatically below).
15
+# ASan needs `-Zbuild-std` (builds std instrumented) because of proc-macro
16
+# crates (time) that break under blanket RUSTFLAGS sanitizer.
17
17
#
18
18
# Usage:
19
19
# bash scripts/sanitize.sh # ASan + targeted miri
28
28
MODE="${1:-all}"
29
29
ASAN_TARGET_DIR="${ASAN_TARGET_DIR:-/tmp/justapi-asan-target}"
30
30
MIRI_TARGET_DIR="${MIRI_TARGET_DIR:-/tmp/justapi-miri-target}"
31
+ASAN_LOG="$(mktemp /tmp/justapi-asan.XXXXXX.log)"
32
+MIRI_LOG="$(mktemp /tmp/justapi-miri.XXXXXX.log)"
33
+
34
+# -Zbuild-std needs the std source for the target. Idempotent; harmless if
35
+# already installed.
36
+rustup component add rust-src --toolchain nightly >/dev/null 2>&1 || true
37
+
38
+run_step() {
39
+ local name="$1" log="$2"; shift 2
40
+ echo "[sanitize] $name..."
41
+ if ! "$@" >"$log" 2>&1; then
42
+ echo "[sanitize] $name FAILED (exit $?) — last 25 lines:" >&2
43
+ tail -25 "$log" >&2
44
+ exit 1
45
+ fi
46
+ # Surface the summary line if present, then confirm pass.
47
+ grep -E "test result:" "$log" | tail -1 || true
48
+ echo "[sanitize] $name: PASS"
49
+}
31
50
32
51
if [[ "$MODE" == "all" || "$MODE" == "--asan" ]]; then
33
- echo "[sanitize] AddressSanitizer on justapi-core (lib, features=db)..."
34
- PATH="$HOME/.cargo/bin:$PATH" \
35
- CARGO_TARGET_DIR="$ASAN_TARGET_DIR" \
36
- RUSTFLAGS="-Zsanitizer=address" \
52
+ run_step "AddressSanitizer on justapi-core (lib, features=db)" "$ASAN_LOG" \
53
+ env PATH="$HOME/.cargo/bin:$PATH" \
54
+ CARGO_TARGET_DIR="$ASAN_TARGET_DIR" \
55
+ RUSTFLAGS="-Zsanitizer=address" \
37
56
rustup run nightly cargo test -p justapi-core --lib --features db \
38
- -Zbuild-std --target x86_64-unknown-linux-gnu 2>&1 | \
39
- grep -E "test result:|error\[|UndefinedBehavior" | tail -5
40
- echo "[sanitize] ASan: PASS"
57
+ -Zbuild-std --target x86_64-unknown-linux-gnu
41
58
fi
42
59
43
60
if [[ "$MODE" == "all" || "$MODE" == "--miri" ]]; then
44
- echo "[sanitize] Miri on the only unsafe module (memory.rs, targeted)..."
45
61
# The #[cfg(miri)] test in memory.rs exercises the arena's
46
62
# from_utf8_unchecked under stacked-borrows provenance rules.
47
- PATH="$HOME/.cargo/bin:$PATH" \
48
- CARGO_TARGET_DIR="$MIRI_TARGET_DIR" \
49
- MIRIFLAGS="-Zmiri-disable-isolation" \
50
- rustup run nightly cargo miri test -p justapi-core --lib memory 2>&1 | \
51
- grep -E "test result:|error|Undefined Behavior" | tail -5
52
- echo "[sanitize] Miri (targeted): PASS"
63
+ run_step "Miri on the only unsafe module (memory.rs, targeted)" "$MIRI_LOG" \
64
+ env PATH="$HOME/.cargo/bin:$PATH" \
65
+ CARGO_TARGET_DIR="$MIRI_TARGET_DIR" \
66
+ MIRIFLAGS="-Zmiri-disable-isolation" \
67
+ rustup run nightly cargo miri test -p justapi-core --lib memory
53
68
fi
54
69
55
70
echo "[sanitize] done — memory-safety gate green"
56
71