rickub/ci-benchpublic Fork 0
28dfdd85f941bb437ac07ec08870550bde4a53a3
Commits
Clone
git clone https://git.rickub.com/rickub/ci-bench.git
git clone ssh://git@rickub.com/rickub/ci-bench.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

ci-bench: cross-platform CI race scaffold (rickub CI vs GitHub Actions) 0baf736Unverified · on 28dfdd85f941bb437ac07ec08870550bde4a53a3 · Olivier Girardot · yesterday
collect.sh · 60 lines · 1.9 KBBash Blame HistoryRaw
 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
#!/usr/bin/env bash
# collect.sh — gather one run's results.jsonl into the results tree.
#
#   scripts/collect.sh PLATFORM RUN_ID SRC [SRC...]
#
#   PLATFORM  github | rickub | local
#   RUN_ID    the run's identifier (bench run_id / artifact run number)
#   SRC       one or more results.jsonl files (e.g. a downloaded artifact,
#             extracted anywhere; multiple are concatenated in order)
#
# Output: results/<platform>/<run-id>.json — a JSON array of the run's records,
# normalized (blank lines dropped). Refuses to overwrite an existing file: two
# collected runs with the same id are almost certainly a copy/paste mistake.

set -euo pipefail

usage() {
    sed -n '2,12p' "$0" >&2
    exit 2
}

[ $# -ge 3 ] || usage

platform=$1
run_id=$2
shift 2

out="results/$platform/$run_id.json"
if [ -e "$out" ]; then
    echo "collect: refusing to overwrite $out (delete it first if intentional)" >&2
    exit 1
fi

mkdir -p "results/$platform"

# Concatenate the sources, drop blanks, and re-emit as a JSON array via
# python3 (stdlib) so the output is valid JSON even from partial files.
python3 - "$out" "$@" <<'PY'
import json, sys

out_path, sources = sys.argv[1], sys.argv[2:]
records = []
for src in sources:
    with open(src, "r", encoding="utf-8", errors="replace") as fh:
        for line in fh:
            line = line.strip()
            if not line:
                continue
            try:
                records.append(json.loads(line))
            except json.JSONDecodeError:
                # A torn last line (job killed mid-write): keep it out but say so.
                print(f"collect: skipping unparseable line in {src}: {line[:80]!r}", file=sys.stderr)
if not records:
    sys.exit(f"collect: no records found in {sources}")
with open(out_path, "w", encoding="utf-8") as fh:
    json.dump(records, fh, indent=1)
    fh.write("\n")
print(f"collect: {len(records)} records -> {out_path}")
PY