Files
obiskim/.crate-kit/scripts/deps-check.sh
T
Eric Coissac b2222afbe3
Release / create-release (push) Successful in 32s
Release / build-linux-x86_64 (push) Successful in 6m51s
Release / build-macos-arm64 (push) Failing after 40s
refactor: remove obipipeline crate and migrate dependencies
Delete the `obipipeline` crate and update all dependent crates to use the
published `obipipeline` version 0.2 from the `obi` registry. Migrate
specific pipeline logic into consuming crates: move error handling to
`obikindexer` and batch iteration logic to `obiskio`. Update build
scripts to support MSRV checking and improved dependency management.

- Delete `src/obipipeline/` entirely, removing the pipeline runtime,
  scheduler, macros, and throttle implementations.
- Move `fmt` (now `pipeline_error`) from `obipipeline` error handling to
  `src/obikindexer/src/graph_pipeline.rs` for graph building errors.
- Move `apply` (now `iter_canonical_kmer_batches_owned`) from
  `obipipeline` pipe logic to `src/obiskio/src/unitig_index/reader.rs`
  to provide lazy batch iteration for canonical kmers.
- Update `src/obikindexer`, `src/obikmerge`, `src/obikphylo`, and
  `src/obiskim` to depend on `obipipeline` version 0.2 from the `obi`
  registry instead of the local path.
- Refactor `src/obikindexer/src/graph_pipeline.rs` to use the new
  `pipeline_error` function and update `build_graph` to accept an
  iterator-returning `open` function.
- Refactor `src/obikmerge` to use `iter_canonical_kmer_batches_owned`
  for streaming batches in `merge_partition` and `run_pass2`, replacing
  previous pipeline stage logic.
- Refactor `src/obikphylo` to handle errors via `OKIError::InvalidData`
  in `build_layer_sibling_annex` and `scan_layer_families`.
- Refactor `src/obiskim` to use `.expect("pipeline error")` for batch
  processing in `query` and `superkmer` commands.
- Add `src/obiskio/src/unitig_index/reader.rs` method
  `iter_canonical_kmer_batches_owned` for lazy batch iteration.
- Add `.crate-kit/scripts/msrv-check.sh` to verify the declared
  `rust-version` builds successfully with the specified toolchain.
- Update `.crate-kit/scripts/deps-check.sh` and `deps-lib.sh` to
  support `cargo update` with specific arguments and improved lockfile
  handling.
- Update `.crate-kit/scripts/bump-version.sh` to use `sed -E` for
  robust version string replacement in `README.md`.
- Update `.crate-kit/scripts/publish-guard.sh` and `publish.sh` to
  enforce registry settings and exclude internal files from packages.
- Update `.gitea/workflows/release.yml` to pass the private cargo
  registry index environment variable during macOS binary builds.
- Remove `Cargo.lock` from the repository root and update
  `src/Cargo.lock` to reflect the new `obipipeline` dependency version.
- Update `src/Cargo.toml` workspace members to remove `obikseq` and
  add `obifastwrite`.
2026-12-02 16:16:40 +01:00

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 "$LOCKFILE" ]; 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: $LOCKFILE 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 "$LOCKFILE" ]; then
unused=$(awk '
/^\[\[patch.unused\]\]/ { u = 1; next }
/^\[/ { u = 0 }
u && /^name = / { gsub(/"/, "", $3); print $3 }
' "$LOCKFILE" | sort -u | paste -sd' ' -)
if [ -n "$unused" ] && [ "$mode" = check ]; then
bad "$LOCKFILE: 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 "$LOCKFILE: 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)"