vouchington-tooling 0.9.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vouchington-tooling",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Vouchington CLI and extractable tooling libraries.",
|
|
5
5
|
"homepage": "https://github.com/vouchington/vouchington-tooling/tree/main/packages/vouchington-tooling#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
# Guards against a `it.runIf(...)` (or equivalent conditional test) silently
|
|
5
|
+
# degrading to a skip: `--reporter=json` records every test's status, and a
|
|
6
|
+
# skipped or absent test must fail the job, not report green. A CI job whose
|
|
7
|
+
# only assertion is "did the suite exit 0" cannot tell "ran and passed" apart
|
|
8
|
+
# from "never ran at all".
|
|
9
|
+
|
|
10
|
+
report_path="${1:?usage: assert-vitest-test-passed.sh <report-json-path> <full-test-name>}"
|
|
11
|
+
full_name="${2:?usage: assert-vitest-test-passed.sh <report-json-path> <full-test-name>}"
|
|
12
|
+
|
|
13
|
+
if [ ! -r "$report_path" ]; then
|
|
14
|
+
echo "::error::vitest report not found at $report_path"
|
|
15
|
+
exit 1
|
|
16
|
+
fi
|
|
17
|
+
|
|
18
|
+
status=$(jq -r --arg name "$full_name" '
|
|
19
|
+
[.testResults[].assertionResults[] | select(.fullName == $name) | .status] | first // "absent"
|
|
20
|
+
' "$report_path")
|
|
21
|
+
|
|
22
|
+
echo "test \"$full_name\": $status"
|
|
23
|
+
|
|
24
|
+
if [ "$status" != passed ]; then
|
|
25
|
+
echo "::error::required test did not pass (status: $status) -- a skipped or absent test must not report green"
|
|
26
|
+
exit 1
|
|
27
|
+
fi
|
|
@@ -10,6 +10,26 @@ section() {
|
|
|
10
10
|
printf '\n== %s ==\n' "$1"
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
is_number() {
|
|
14
|
+
[[ "$1" =~ ^[0-9]+(\.[0-9]+)?$ ]]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
show_load_per_cpu() {
|
|
18
|
+
load1=$1
|
|
19
|
+
load5=$2
|
|
20
|
+
load15=$3
|
|
21
|
+
cpu_count=$4
|
|
22
|
+
printf 'load average: %s %s %s\n' "${load1:-unavailable}" "${load5:-unavailable}" "${load15:-unavailable}"
|
|
23
|
+
ratio=''
|
|
24
|
+
if is_number "$load1" && is_number "$cpu_count" && [ "$cpu_count" != '0' ]; then
|
|
25
|
+
# Capture rather than let awk print directly: a forked subprocess can
|
|
26
|
+
# fail or be killed under host pressure -- the exact condition this
|
|
27
|
+
# script exists to diagnose -- and produce no output on either branch.
|
|
28
|
+
ratio=$(awk -v load="$load1" -v cpus="$cpu_count" 'BEGIN { printf "%.2f", load / cpus }' 2>/dev/null || true)
|
|
29
|
+
fi
|
|
30
|
+
printf 'load1 per cpu: %s\n' "${ratio:-unavailable}"
|
|
31
|
+
}
|
|
32
|
+
|
|
13
33
|
show_meminfo_field() {
|
|
14
34
|
field=$1
|
|
15
35
|
if [ -r /proc/meminfo ]; then
|
|
@@ -54,14 +74,24 @@ show_oom_lines() {
|
|
|
54
74
|
|
|
55
75
|
show_top_rss_processes() {
|
|
56
76
|
if have ps && have sort && have sed; then
|
|
57
|
-
ps ax -o pid= -o rss= -o comm= 2>/dev/null | sort -k2,2nr | sed -n '1,15p'
|
|
77
|
+
output=$(ps ax -o pid= -o rss= -o comm= 2>/dev/null | sort -k2,2nr | sed -n '1,15p')
|
|
78
|
+
else
|
|
79
|
+
output=''
|
|
80
|
+
fi
|
|
81
|
+
if [ -n "$output" ]; then
|
|
82
|
+
printf '%s\n' "$output"
|
|
58
83
|
else
|
|
59
|
-
printf 'unavailable\n'
|
|
84
|
+
printf 'unavailable: top rss processes\n'
|
|
60
85
|
fi
|
|
61
86
|
}
|
|
62
87
|
|
|
63
88
|
show_runner_counts() {
|
|
64
|
-
ps ax -o comm= 2>/dev/null
|
|
89
|
+
process_list=$(ps ax -o comm= 2>/dev/null)
|
|
90
|
+
if [ -z "$process_list" ]; then
|
|
91
|
+
printf 'unavailable: process list\n'
|
|
92
|
+
return
|
|
93
|
+
fi
|
|
94
|
+
printf '%s\n' "$process_list" | awk '
|
|
65
95
|
{
|
|
66
96
|
command = $0
|
|
67
97
|
sub(/^[[:space:]]+/, "", command)
|
|
@@ -137,18 +167,21 @@ case "$platform" in
|
|
|
137
167
|
done
|
|
138
168
|
|
|
139
169
|
section 'load and cpu'
|
|
170
|
+
loadavg_line=''
|
|
140
171
|
if [ -r /proc/loadavg ]; then
|
|
141
|
-
|
|
142
|
-
awk '{ print $1, $2, $3 }' /proc/loadavg 2>/dev/null || printf 'unavailable\n'
|
|
143
|
-
else
|
|
144
|
-
printf 'load average unavailable\n'
|
|
172
|
+
loadavg_line=$(awk '{ print $1, $2, $3 }' /proc/loadavg 2>/dev/null || true)
|
|
145
173
|
fi
|
|
174
|
+
load1=$(printf '%s' "$loadavg_line" | awk '{ print $1 }')
|
|
175
|
+
load5=$(printf '%s' "$loadavg_line" | awk '{ print $2 }')
|
|
176
|
+
load15=$(printf '%s' "$loadavg_line" | awk '{ print $3 }')
|
|
146
177
|
printf 'nproc: '
|
|
147
178
|
if have nproc; then
|
|
148
|
-
nproc 2>/dev/null ||
|
|
179
|
+
cpu_count=$(nproc 2>/dev/null || true)
|
|
149
180
|
else
|
|
150
|
-
getconf _NPROCESSORS_ONLN 2>/dev/null ||
|
|
181
|
+
cpu_count=$(getconf _NPROCESSORS_ONLN 2>/dev/null || true)
|
|
151
182
|
fi
|
|
183
|
+
printf '%s\n' "${cpu_count:-unavailable}"
|
|
184
|
+
show_load_per_cpu "$load1" "$load5" "$load15" "$cpu_count"
|
|
152
185
|
|
|
153
186
|
section 'kernel OOM evidence'
|
|
154
187
|
show_oom_lines
|
|
@@ -160,13 +193,69 @@ case "$platform" in
|
|
|
160
193
|
Darwin)
|
|
161
194
|
section 'system basics'
|
|
162
195
|
uptime 2>/dev/null || printf 'uptime unavailable\n'
|
|
163
|
-
printf 'hw.ncpu: '
|
|
164
|
-
sysctl -n hw.ncpu 2>/dev/null || printf 'unavailable\n'
|
|
165
196
|
printf 'hw.memsize: '
|
|
166
197
|
sysctl -n hw.memsize 2>/dev/null || printf 'unavailable\n'
|
|
167
198
|
section 'swap and vm'
|
|
168
199
|
vm_stat 2>/dev/null || printf 'vm_stat unavailable\n'
|
|
169
200
|
sysctl vm.swapusage 2>/dev/null || printf 'vm.swapusage unavailable\n'
|
|
201
|
+
|
|
202
|
+
section 'load and cpu'
|
|
203
|
+
loadavg_raw=$(sysctl -n vm.loadavg 2>/dev/null || true)
|
|
204
|
+
load1=$(printf '%s' "$loadavg_raw" | awk '{ print $2 }')
|
|
205
|
+
load5=$(printf '%s' "$loadavg_raw" | awk '{ print $3 }')
|
|
206
|
+
load15=$(printf '%s' "$loadavg_raw" | awk '{ print $4 }')
|
|
207
|
+
printf 'hw.logicalcpu: '
|
|
208
|
+
logicalcpu=$(sysctl -n hw.logicalcpu 2>/dev/null || true)
|
|
209
|
+
printf '%s\n' "${logicalcpu:-unavailable}"
|
|
210
|
+
printf 'hw.physicalcpu: '
|
|
211
|
+
sysctl -n hw.physicalcpu 2>/dev/null || printf 'unavailable\n'
|
|
212
|
+
printf 'hw.ncpu: '
|
|
213
|
+
sysctl -n hw.ncpu 2>/dev/null || printf 'unavailable\n'
|
|
214
|
+
show_load_per_cpu "$load1" "$load5" "$load15" "$logicalcpu"
|
|
215
|
+
# Apple-Silicon performance/efficiency core split. These sysctls do not
|
|
216
|
+
# exist on Intel Macs and must degrade to unavailable there. On some
|
|
217
|
+
# runners the OID resolves with exit 0 but zero bytes of output rather
|
|
218
|
+
# than failing outright -- capture and fall back on emptiness, not just
|
|
219
|
+
# on a non-zero exit, or that case silently swallows the trailing
|
|
220
|
+
# newline and glues the next section onto this line.
|
|
221
|
+
perflevel0=$(sysctl -n hw.perflevel0.logicalcpu 2>/dev/null || true)
|
|
222
|
+
printf 'hw.perflevel0.logicalcpu: %s\n' "${perflevel0:-unavailable}"
|
|
223
|
+
perflevel1=$(sysctl -n hw.perflevel1.logicalcpu 2>/dev/null || true)
|
|
224
|
+
printf 'hw.perflevel1.logicalcpu: %s\n' "${perflevel1:-unavailable}"
|
|
225
|
+
# iostat -c 2 is the closest PSI analogue on Darwin: a since-boot row plus
|
|
226
|
+
# a 1-second live row with us/sy/id and 1m/5m/15m load. Do not gate this on
|
|
227
|
+
# `have timeout` -- base macOS ships no timeout binary (only gtimeout via
|
|
228
|
+
# coreutils/Homebrew), and `-c 2` is self-bounding at ~1s regardless.
|
|
229
|
+
if have iostat; then
|
|
230
|
+
if have timeout; then
|
|
231
|
+
timeout 5 iostat -c 2 2>/dev/null || printf 'iostat unavailable\n'
|
|
232
|
+
else
|
|
233
|
+
iostat -c 2 2>/dev/null || printf 'iostat unavailable\n'
|
|
234
|
+
fi
|
|
235
|
+
else
|
|
236
|
+
printf 'iostat unavailable\n'
|
|
237
|
+
fi
|
|
238
|
+
|
|
239
|
+
section 'memory pressure'
|
|
240
|
+
if have memory_pressure; then
|
|
241
|
+
memory_pressure -Q 2>/dev/null || printf 'memory_pressure unavailable\n'
|
|
242
|
+
else
|
|
243
|
+
printf 'memory_pressure unavailable\n'
|
|
244
|
+
fi
|
|
245
|
+
printf 'kern.memorystatus_vm_pressure_level: '
|
|
246
|
+
pressure_level=$(sysctl -n kern.memorystatus_vm_pressure_level 2>/dev/null || true)
|
|
247
|
+
case "$pressure_level" in
|
|
248
|
+
1) printf 'normal (1)\n' ;;
|
|
249
|
+
2) printf 'warning (2)\n' ;;
|
|
250
|
+
4) printf 'critical (4)\n' ;;
|
|
251
|
+
'') printf 'unavailable\n' ;;
|
|
252
|
+
*) printf 'unknown (%s)\n' "$pressure_level" ;;
|
|
253
|
+
esac
|
|
254
|
+
printf 'vm.compressor_bytes_used: '
|
|
255
|
+
sysctl -n vm.compressor_bytes_used 2>/dev/null || printf 'unavailable\n'
|
|
256
|
+
# No jetsam/OOM-kill log scrape here (unlike Linux show_oom_lines): `log
|
|
257
|
+
# show` is unbounded and slow, with no cheap bounded equivalent on macOS.
|
|
258
|
+
|
|
170
259
|
section 'top rss processes'
|
|
171
260
|
show_top_rss_processes
|
|
172
261
|
section 'runner worker/listener counts'
|