build-test-release / release (push) Successful in 5m47s
Ran the code-review-harness (four parallel reviewers: correctness, reliability, performance, test-coverage) over the GUI crate and fixed every Critical/High finding, plus grew the test + microbenchmark suite that gates the pipeline. Correctness / reliability fixes: - IP column sorted lexically, not numerically. The default view is IP-ascending but Column::Ip fell through to the generic lowercase-string sort key, so 10.255.1.10 sorted before 10.255.1.2 on every launch. Add a numeric IP sort key (u32, exact in f64) and switch view() to decorate-sort-undecorate so a sort key is computed once per row, not twice per comparison. - Scans had no cancellation. Stop/Apply/Play only dropped the receiver, leaving the background thread probing dead hosts (each waits out an asic-rs timeout), and Play could spawn a second concurrent scan + tokio runtime. Add a ScanHandle with an Arc<AtomicBool> cancel flag the loop checks each iteration, a begin_scan() helper that stops the in-flight scan before starting a new one, and Stop now signals cancellation. - Native column drag never rebuilt the control: column_reordered mutated view.order but skipped rebuild_table(), so the store's creation order diverged from display_columns() and cells rendered under the wrong headers on the next scan tick. Rebuild after applying the reorder. - format_si rounding rolled a mantissa up to "1000" without advancing the SI prefix (999.9 W -> "1000 W", a 4-digit result). Round first, then roll over; [99.95,100) drops its decimal. - start_scan used .expect() on thread spawn, which would panic across the wx FFI boundary; it now sends ScanMsg::Failed and returns the handle. Tests / benchmarks (the pipeline's regression gate): - Unit tests 24 -> 41: format_si/format_uptime boundaries, numeric IP sort, upsert-new-IP, Light three-state + pool-slot-out-of-range cells, filter AND/OR, reorder non-permutation guard; scan.rs parse_cidr/prefix_mask, single-host /32, empty/whitespace, short-range single/reversed, parse_targets aggregate cap + error propagation, validate_ranges, targets_to_cidrs non-contiguous, auto-rescan-secs round-trip. - Microbenchmarks 2 -> 9: view default-sort, sort-by-each-column, filtered view, upsert cold-start, parse_line near MAX_ADDRS, parse_targets many ranges, targets_to_cidrs large range. Floors are 5-10x above local numbers. - New ci/test-compute-version.sh: 9 cases for the X.Y.Z logic (first release, pre-bumped X, backend/UI bumps, docs-only no-op, major-wins-over-UI, backend-wins-over-UI, nested ci/ and thirdparty/wx-rs paths). Wired in as a fast-fail CI step. CI: install libssl-dev + pkg-config (openssl-sys); add xauth so the headless self-test actually launches under xvfb (was aborting on "xauth not found"). Deferred (documented in code-review-report.md, guarded by benches): Cow cells, an ip->index map for upsert. Local: 41 tests + 9 benches + 9 shell tests green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y8h447BPyJR4fioYZvQ9bh
102 lines
4.4 KiB
Bash
Executable File
102 lines
4.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Tests for ci/compute-version.sh (the X.Y.Z versioning logic). Each case builds
|
|
# a throwaway git repo in a scratch tmp dir (never inside this repo / the Ultron
|
|
# mount), lays out a scenario, runs compute-version.sh inside it, and asserts the
|
|
# emitted KEY=VALUE lines. Run: bash ci/test-compute-version.sh
|
|
set -euo pipefail
|
|
|
|
SCRIPT="$(cd "$(dirname "$0")" && pwd)/compute-version.sh"
|
|
[ -f "$SCRIPT" ] || { echo "cannot find compute-version.sh at $SCRIPT"; exit 2; }
|
|
|
|
pass=0
|
|
fail=0
|
|
|
|
# new_repo: fresh git repo in a scratch dir, echoes its path.
|
|
new_repo() {
|
|
local r
|
|
r="$(mktemp -d "${TMPDIR:-/tmp}/alkane-cv-XXXXXX")"
|
|
git -C "$r" init -q
|
|
git -C "$r" config user.email t@t
|
|
git -C "$r" config user.name t
|
|
echo "$r"
|
|
}
|
|
|
|
commit() { # commit <repo> <msg>
|
|
git -C "$1" add -A
|
|
git -C "$1" commit -q -m "$2"
|
|
}
|
|
|
|
# run_case: <name> <repo> then key=value expectations as remaining args.
|
|
run_case() {
|
|
local name="$1" repo="$2"; shift 2
|
|
local out get k v ok=1
|
|
out="$(cd "$repo" && bash "$SCRIPT")"
|
|
get() { echo "$out" | grep "^$1=" | cut -d= -f2-; }
|
|
for kv in "$@"; do
|
|
k="${kv%%=*}"; v="${kv#*=}"
|
|
if [ "$(get "$k")" != "$v" ]; then
|
|
echo "FAIL [$name]: expected $k=$v, got $k=$(get "$k")"
|
|
ok=0
|
|
fi
|
|
done
|
|
if [ "$ok" = 1 ]; then echo "PASS [$name]"; pass=$((pass + 1)); else fail=$((fail + 1)); fi
|
|
rm -rf "$repo"
|
|
}
|
|
|
|
# 1. First release, no tag, X=0 -> 0.1.0
|
|
R="$(new_repo)"; mkdir -p "$R/ci"; printf '0' > "$R/ci/version-x.txt"
|
|
printf 'x' > "$R/README.md"; commit "$R" init
|
|
run_case first_release "$R" version=0.1.0 tag=v0.1.0 bump=initial release=true last_tag=none
|
|
|
|
# 2. First release with a pre-bumped major (X=2, no tag) -> 2.0.0
|
|
R="$(new_repo)"; mkdir -p "$R/ci"; printf '2' > "$R/ci/version-x.txt"
|
|
printf 'x' > "$R/README.md"; commit "$R" init
|
|
run_case first_release_prebumped_x "$R" version=2.0.0 bump=initial release=true
|
|
|
|
# 3. Backend path change bumps Y
|
|
R="$(new_repo)"; mkdir -p "$R/ci" "$R/crates/alkane-gui/src"; printf '0' > "$R/ci/version-x.txt"
|
|
printf 'x' > "$R/README.md"; commit "$R" init; git -C "$R" tag v1.2.3
|
|
printf 'fn x(){}' > "$R/crates/alkane-gui/src/scan.rs"; commit "$R" backend
|
|
run_case backend_bump "$R" version=1.3.0 tag=v1.3.0 bump=backend release=true last_tag=v1.2.3
|
|
|
|
# 4. UI path change bumps Z
|
|
R="$(new_repo)"; mkdir -p "$R/ci" "$R/crates/alkane-gui/src"; printf '0' > "$R/ci/version-x.txt"
|
|
printf 'x' > "$R/README.md"; commit "$R" init; git -C "$R" tag v1.2.3
|
|
printf 'fn x(){}' > "$R/crates/alkane-gui/src/fixtures.rs"; commit "$R" ui
|
|
run_case ui_bump "$R" version=1.2.4 bump=ui release=true
|
|
|
|
# 5. Docs-only change -> no release
|
|
R="$(new_repo)"; mkdir -p "$R/ci"; printf '0' > "$R/ci/version-x.txt"
|
|
printf 'x' > "$R/README.md"; commit "$R" init; git -C "$R" tag v1.2.3
|
|
printf 'more docs' > "$R/README.md"; commit "$R" docs
|
|
run_case no_release_docs_only "$R" version=1.2.3 bump=none release=false
|
|
|
|
# 6. Manual major bump wins over a simultaneous UI change
|
|
R="$(new_repo)"; mkdir -p "$R/ci" "$R/crates/alkane-gui/src"; printf '0' > "$R/ci/version-x.txt"
|
|
printf 'x' > "$R/README.md"; commit "$R" init; git -C "$R" tag v1.2.3
|
|
printf '2' > "$R/ci/version-x.txt"; printf 'fn x(){}' > "$R/crates/alkane-gui/src/fixtures.rs"; commit "$R" bumpx
|
|
run_case manual_major_wins_over_ui "$R" version=2.0.0 bump=major release=true
|
|
|
|
# 7. Backend wins over UI when both change in the same diff
|
|
R="$(new_repo)"; mkdir -p "$R/ci" "$R/crates/alkane-gui/src"; printf '0' > "$R/ci/version-x.txt"
|
|
printf 'x' > "$R/README.md"; commit "$R" init; git -C "$R" tag v1.2.3
|
|
printf 'a' > "$R/crates/alkane-gui/src/scan.rs"
|
|
printf 'b' > "$R/crates/alkane-gui/src/fixtures.rs"; commit "$R" both
|
|
run_case backend_wins_over_ui "$R" version=1.3.0 bump=backend release=true
|
|
|
|
# 8. Nested ci/ path classified as backend (also covers editing compute-version.sh)
|
|
R="$(new_repo)"; mkdir -p "$R/ci"; printf '0' > "$R/ci/version-x.txt"
|
|
printf 'x' > "$R/README.md"; commit "$R" init; git -C "$R" tag v1.2.3
|
|
printf '# tweak' >> "$R/ci/compute-version.sh"; commit "$R" ci
|
|
run_case ci_nested_is_backend "$R" version=1.3.0 bump=backend release=true
|
|
|
|
# 9. Nested thirdparty/wx-rs path classified as UI
|
|
R="$(new_repo)"; mkdir -p "$R/ci" "$R/thirdparty/wx-rs/src/deep"; printf '0' > "$R/ci/version-x.txt"
|
|
printf 'x' > "$R/README.md"; commit "$R" init; git -C "$R" tag v1.2.3
|
|
printf 'x' > "$R/thirdparty/wx-rs/src/deep/nested.rs"; commit "$R" wx
|
|
run_case wx_rs_nested_is_ui "$R" version=1.2.4 bump=ui release=true
|
|
|
|
echo "----"
|
|
echo "compute-version tests: $pass passed, $fail failed"
|
|
[ "$fail" -eq 0 ]
|