Release / release (push) Successful in 1m11s
The pipeline scheduler is refactored to use a shared worker pool instead of dedicated threads per stage, and `PipeIter` now yields `Result` items to propagate errors as the last element. The change introduces a new state machine for scheduling, updates error handling types, and reorganizes tests to cover scheduling and shutdown behaviors separately. - Update package version to 0.2.0, Rust MSRV to 1.100, and add `crossbeam-channel` dependency in `Cargo.toml` and `Cargo.lock`. - Refactor `src/scheduler/pipe.rs` to yield `Result<Out, PipelineError>` from `PipeIter`, adding cancellation support and moving `finish` to `pool.rs` as `wait`. - Introduce `src/scheduler/state.rs` with `State`, `Job`, and `Outcome` types, moving `dispatch` from `runner.rs` to `pick` in the new module. - Rewrite `src/scheduler/runner.rs` to use shared state and signals, removing `dispatch` and `transform_runner` while adding worker and source/sink runners with lock-based synchronization. - Add `src/scheduler/pool.rs` methods `start` and `wait` to manage thread lifecycle, replacing the previous handle-based approach in `WorkerPool`. - Replace `WorkerPanic` with `Panicked` and add `NeverFails` error types in `src/scheduler/error.rs` for clearer error reporting. - Update `src/scheduler/macros.rs` to use fallible variants for source, transform, flat, and sink macros, ensuring proper error propagation. - Remove `WorkerTask` from `src/scheduler/types.rs` and add `SharedFlatFn` alias for 1->N transform functions returning lazy sequences. - Update `src/lib.rs` documentation to reflect the new scheduler behavior and expose `NeverFails` and `Stage` publicly. - Enhance `src/throttle.rs` documentation to clarify slot acquisition rules and guard behavior in flat stages to prevent deadlocks. - Add `tests/scheduling.rs` with tests for deadlock prevention and scheduling priority, moving `fallible_flat_stage_error_is_returned_and_does_not_hang` from `tests/errors.rs`. - Add `tests/shutdown.rs` with tests for early drop and panic message preservation, moving `worker_panic_is_returned_and_does_not_hang` from `tests/errors.rs`. - Refactor `tests/errors.rs` to focus on error propagation as the last iterator item, adding comprehensive tests for panics and type mismatches. - Update `tests/pipe.rs` to use `.collect::<Result<_, _>>()` for handling fallible iterators in existing tests. - Add `figures/pipeline.svg` visualizing the parallel scheduler logic. - Add API documentation snapshots for version 0.2.0 in `api/`. - Update `.crate-kit/` scripts to support MSRV checking and improved dependency update logic, adding `msrv-check.sh` and refining `publish-guard.sh`.
165 lines
7.1 KiB
Bash
Executable File
165 lines
7.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Freshness of the dependencies between crates of the private registry: we must never keep running with an
|
|
# old version of a registry crate when a new one is published. Fails (code 1) at the slightest discrepancy.
|
|
#
|
|
# For each dependency `name = { version = "x.y", registry = "<registry>" }` declared by the project
|
|
# (same reading as dev-patch.sh), it checks:
|
|
# 1. the requirement accepts the latest version published on the registry (for a 0.x, `0.1` never
|
|
# accepts 0.2: Cargo says nothing);
|
|
# 2. Cargo.lock is on that latest version (if it points to the registry);
|
|
# 3. the neighbouring folder ../<name>, which replaces the dependency in joint development, is not
|
|
# behind the registry (otherwise we build against stale code);
|
|
# 4. Cargo.lock contains no [[patch.unused]] (ignored local patch: requirement too low);
|
|
# 5. no registry crate appears in several versions in Cargo.lock (two copies in the build).
|
|
# A neighbour newer than the registry (pending publication) is reported without failing.
|
|
#
|
|
# deps-check.sh check (read-only, except for the network)
|
|
# deps-check.sh bump fixes the outdated requirements (rewrites the Cargo.toml) then `cargo update -p`
|
|
#
|
|
# Network: the sparse index of the registry ($REGISTRY_INDEX), public. Without network, the check
|
|
# fails; DEPS_CHECK_OFFLINE=1 explicitly ignores it (warning).
|
|
# shellcheck disable=SC2154 # index_url and manifests come from deps-lib.sh
|
|
set -euo pipefail
|
|
. "$(dirname "$0")/common.sh"
|
|
[ -n "$REGISTRY" ] || { err "✗ no registry: declare the kit extension (KIT_OVERLAY in the Makefile, org.mk) or set REGISTRY = crates-io"; exit 1; }
|
|
[ "$REGISTRY" != crates-io ] || { info " (crates.io registry: dependencies checked by deps-check-external)"; exit 0; }
|
|
|
|
mode="${1:-check}"
|
|
case "$mode" in check | bump) ;; *)
|
|
err "usage: deps-check.sh [check|bump]"
|
|
exit 2
|
|
;;
|
|
esac
|
|
|
|
[ -f "$CARGO_TOML" ] || exit 0
|
|
|
|
fail=0
|
|
bad() {
|
|
err " ✗ $*"
|
|
fail=1
|
|
}
|
|
|
|
. "$(dirname "$0")/deps-lib.sh"
|
|
|
|
decl=""
|
|
for m in "${manifests[@]}"; do
|
|
lines=$(grep -E "^[A-Za-z0-9_-]+[[:space:]]*=[[:space:]]*\{[^}]*registry[[:space:]]*=[[:space:]]*\"$REGISTRY\"" "$m" || true)
|
|
[ -n "$lines" ] && decl+="$(printf '%s\n' "$lines" | sed "s|^|$m |")"$'\n'
|
|
done
|
|
|
|
if [ -z "$decl" ]; then
|
|
ok "✓ No dependency on registry $REGISTRY to check"
|
|
exit 0
|
|
fi
|
|
|
|
info "→ Freshness of the registry dependencies (registry $REGISTRY)..."
|
|
count=0
|
|
updates=""
|
|
offline=0
|
|
while IFS=$'\t' read -r manifest line; do
|
|
[ -n "$manifest" ] || continue
|
|
name=${line%%[[:space:]=]*}
|
|
req=$(printf '%s' "$line" | sed -nE 's/.*version[[:space:]]*=[[:space:]]*"([^"]*)".*/\1/p')
|
|
count=$((count + 1))
|
|
if [ -z "$req" ]; then
|
|
bad "$name ($manifest): no \"version\" in the declaration"
|
|
continue
|
|
fi
|
|
|
|
rc=0
|
|
latest=$(latest_published "$name") || rc=$?
|
|
if [ "$rc" -eq 2 ]; then
|
|
offline=1
|
|
continue
|
|
fi
|
|
if [ "$rc" -eq 1 ] || [ -z "$latest" ]; then
|
|
bad "$name ($manifest): no version published on registry $REGISTRY"
|
|
continue
|
|
fi
|
|
|
|
acc=0
|
|
req_accepts "$req" "$latest" || acc=$?
|
|
case "$acc" in
|
|
2) bad "$name ($manifest): requirement \"$req\" cannot be parsed (write x.y, or x for a version ≥ 1)" ;;
|
|
1)
|
|
if [ "$(printf '%s\n%s\n' "$req" "$latest" | sort -V | tail -n 1)" = "$latest" ]; then
|
|
if [ "$mode" = bump ]; then
|
|
new=$(req_for "$latest")
|
|
sed -E "/^${name}[[:space:]]*=.*registry[[:space:]]*=[[:space:]]*\"$REGISTRY\"/ s/(version[[:space:]]*=[[:space:]]*\")[^\"]*/\1$new/" "$manifest" >"$manifest.tmp" &&
|
|
mv "$manifest.tmp" "$manifest"
|
|
info " $name ($manifest): \"$req\" → \"$new\" (latest published version: $latest)"
|
|
updates+="$name@$latest "
|
|
else
|
|
bad "$name ($manifest): the requirement \"$req\" does not accept the latest published version $latest → $name = { version = \"$(req_for "$latest")\", registry = \"$REGISTRY\" } (make deps-bump)"
|
|
fi
|
|
else
|
|
bad "$name ($manifest): the requirement \"$req\" is newer than the latest published version $latest (publication pending?)"
|
|
fi
|
|
;;
|
|
esac
|
|
|
|
# Cargo.lock: on the latest version if the dependency comes from the registry.
|
|
if [ -f Cargo.lock ]; then
|
|
locked=$(lock_entries | awk -v n="$name" -v r="/api/packages/$REGISTRY/" '$1 == n && index($3, r) { print $2 }' | sort -V | tail -n 1)
|
|
if [ -n "$locked" ] && [ "$locked" != "$latest" ] && [ "$acc" -eq 0 ]; then
|
|
if [ "$mode" = bump ]; then
|
|
updates+="$name@$latest "
|
|
else
|
|
bad "$name: Cargo.lock is on $locked, the latest published version is $latest → cargo update $(lock_update_args "$name" "$latest" "/api/packages/$REGISTRY/") (make deps-bump)"
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
# Neighbouring folder: replaces the dependency in joint development.
|
|
if [ -f "../$name/Cargo.toml" ]; then
|
|
neighbor=$(sed -n 's/^version = "\(.*\)"/\1/p' "../$name/Cargo.toml" | head -n 1)
|
|
if [ -n "$neighbor" ] && [ "$neighbor" != "$latest" ]; then
|
|
if [ "$(printf '%s\n%s\n' "$neighbor" "$latest" | sort -V | tail -n 1)" = "$latest" ]; then
|
|
bad "$name: the neighbouring folder ../$name is at $neighbor, the registry at $latest → update the neighbour (jj git fetch)"
|
|
else
|
|
warn " ⚠ $name: the neighbouring folder ../$name ($neighbor) is newer than the published version ($latest): publication pending"
|
|
fi
|
|
fi
|
|
fi
|
|
done <<<"$decl"
|
|
|
|
if [ "$offline" -eq 1 ]; then
|
|
if [ "${DEPS_CHECK_OFFLINE:-}" = 1 ]; then
|
|
warn " ⚠ registry unreachable: freshness of the dependencies not verified (DEPS_CHECK_OFFLINE=1)"
|
|
else
|
|
bad "registry $REGISTRY unreachable ($index_url): freshness cannot be verified (DEPS_CHECK_OFFLINE=1 to ignore)"
|
|
fi
|
|
fi
|
|
|
|
# Cargo.lock: ignored patch and duplicates.
|
|
if [ -f Cargo.lock ]; then
|
|
unused=$(awk '
|
|
/^\[\[patch.unused\]\]/ { u = 1; next }
|
|
/^\[/ { u = 0 }
|
|
u && /^name = / { gsub(/"/, "", $3); print $3 }
|
|
' Cargo.lock | sort -u | paste -sd' ' -)
|
|
if [ -n "$unused" ] && [ "$mode" = check ]; then
|
|
bad "Cargo.lock: local patch ignored for $unused — the project's requirement does not accept the version of the neighbouring folder"
|
|
fi
|
|
dups=$(lock_entries | awk -v r="/api/packages/$REGISTRY/" '
|
|
{ c[$1]++; vs[$1] = vs[$1] " " $2; if ($3 == "-" || index($3, r)) p[$1] = 1 }
|
|
END { for (n in c) if (c[n] > 1 && p[n]) print n ":" vs[n] }
|
|
')
|
|
if [ -n "$dups" ]; then
|
|
while IFS= read -r d; do
|
|
bad "Cargo.lock: several versions of ${d%%:*} in the build (${d#*: }) — align the requirements of the crates that depend on it"
|
|
done <<<"$dups"
|
|
fi
|
|
fi
|
|
|
|
if [ "$mode" = bump ] && [ -n "$updates" ]; then
|
|
# shellcheck disable=SC2086 # list of words
|
|
lock_update "/api/packages/$REGISTRY/" $updates
|
|
fi
|
|
|
|
if [ "$fail" -ne 0 ]; then
|
|
err "✗ Registry dependencies stale or inconsistent (see above)"
|
|
exit 1
|
|
fi
|
|
ok "✓ Registry dependencies up to date ($count checked)"
|