Skip to content

Commit e3433ab

Browse files
committed
Add Blacksmith mactop diagnostics
1 parent 7d7902b commit e3433ab

2 files changed

Lines changed: 87 additions & 0 deletions

File tree

.github/scripts/probe-mactop.sh

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env bash
2+
# Diagnose whether a macOS runner exposes mactop/IOReport counters.
3+
set -euo pipefail
4+
5+
seconds="${MLXFAST_MACTOP_PROBE_SECONDS:-3}"
6+
interval_ms="${MLXFAST_MACTOP_PROBE_INTERVAL_MS:-100}"
7+
8+
if ! command -v mactop >/dev/null 2>&1; then
9+
if ! command -v brew >/dev/null 2>&1; then
10+
echo "probe-mactop: Homebrew is required to install mactop" >&2
11+
exit 1
12+
fi
13+
echo "probe-mactop: installing mactop"
14+
brew install mactop
15+
fi
16+
17+
mactop_bin="$(command -v mactop)"
18+
echo "probe-mactop: mactop=${mactop_bin}"
19+
echo "probe-mactop: user=$(id)"
20+
echo "probe-mactop: sw_vers"
21+
sw_vers || true
22+
echo "probe-mactop: uname=$(uname -a)"
23+
echo "probe-mactop: cpu=$(sysctl -n machdep.cpu.brand_string 2>/dev/null || true)"
24+
25+
run_mactop_probe() {
26+
local label="$1"
27+
shift
28+
local stdout_path
29+
local stderr_path
30+
local status
31+
stdout_path="$(mktemp "${TMPDIR:-/tmp}/mlxfast-mactop-${label}.out.XXXXXX")"
32+
stderr_path="$(mktemp "${TMPDIR:-/tmp}/mlxfast-mactop-${label}.err.XXXXXX")"
33+
34+
echo "probe-mactop: ${label} start command=$*"
35+
set +e
36+
"$@" --headless --interval "${interval_ms}" --format json >"${stdout_path}" 2>"${stderr_path}" &
37+
local pid="$!"
38+
sleep "${seconds}"
39+
if kill -0 "${pid}" 2>/dev/null; then
40+
kill "${pid}" 2>/dev/null
41+
fi
42+
wait "${pid}"
43+
status="$?"
44+
set -e
45+
46+
echo "probe-mactop: ${label} status=${status}"
47+
echo "probe-mactop: ${label} stdout_bytes=$(wc -c < "${stdout_path}" | tr -d ' ')"
48+
echo "probe-mactop: ${label} stderr_bytes=$(wc -c < "${stderr_path}" | tr -d ' ')"
49+
echo "probe-mactop: ${label} stdout_head"
50+
sed -n '1,5p' "${stdout_path}" || true
51+
echo "probe-mactop: ${label} stderr"
52+
cat "${stderr_path}" || true
53+
}
54+
55+
run_mactop_probe "plain" "${mactop_bin}"
56+
57+
if sudo -n true 2>/dev/null; then
58+
run_mactop_probe "sudo" sudo -n "${mactop_bin}"
59+
else
60+
echo "probe-mactop: sudo passwordless unavailable"
61+
fi
62+
63+
if command -v sandbox-exec >/dev/null 2>&1 && [[ -f tools/deny-network.sb ]]; then
64+
run_mactop_probe "deny-network-sandbox" sandbox-exec -f tools/deny-network.sb "${mactop_bin}"
65+
else
66+
echo "probe-mactop: sandbox-exec or tools/deny-network.sb unavailable"
67+
fi
68+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: mactop-diagnostics
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
probe:
11+
runs-on: blacksmith-12vcpu-macos-26
12+
timeout-minutes: 15
13+
steps:
14+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
15+
with:
16+
persist-credentials: false
17+
18+
- name: Probe mactop
19+
run: .github/scripts/probe-mactop.sh

0 commit comments

Comments
 (0)