Introduce the `.crate-kit` infrastructure to standardize build, testing, and release workflows using Jujutsu and Cargo. Add CeCILL-2.1 license files and update all workspace crate manifests with license and repository metadata. - Add `.crate-kit/` directory with `VERSION`, `crate.mk`, `dev-patch.mk`, `jj.mk`, and `org.mk` to define build targets, Jujutsu helpers, and registry configuration for the workspace. - Add 21 shell scripts in `.crate-kit/scripts/` for API tracking, dependency checking, version bumping, publishing, tagging, and wiki generation, including `common.sh` with shared utility functions. - Add `scripts/jj-tag.sh` to support tagging commits with version strings derived from the current crate version. - Add `LICENSE` and `LICENSE.en` files containing the CeCILL-2.1 free software license agreement in French and English. - Update `Makefile` with new targets for building, testing, formatting, CI, and releasing, integrating with `.crate-kit` scripts and updating the wiki directory path to `obiskim`. - Update `.gitignore` to ignore `.cargo/config.toml` files generated by the development patch system. - Add `license = "CECILL-2.1"` and `repository = "https://forge.metabarcoding.org/obi/obiskim"` to all `Cargo.toml` files in the workspace, including `obicompactvec`, `obidebruinj`, `obifastwrite`, `obikalgorithm`, `obikdump`, `obikentropy`, `obikfilter`, `obikidxcache`, `obikindex`, `obikindexer`, `obikmer`, `obikmerge`, `obikphylo`, `obikquery`, `obikrebuild`, `obikrope`, `obikselect`, `obikseq`, `obiksession`, `obikstats`, `obipipeline`, `obiread`, `obiskbuilder`, `obiskio`, `obisys`, and `obitaxonomy`. - Update `src/obikrope/Cargo.toml` to use `criterion2` version 3 with the `cargo_bench_support` feature. - Update `src/obikseq/Cargo.toml` to replace the "OnceLock-based params" feature with a new feature description involving thread-local storage. - Update `src/Cargo.lock` to reflect the version bump of `obikmer` from 1.4.7 to 1.4.8.
97 lines
3.6 KiB
Bash
Executable File
97 lines
3.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Compares the current public API to the last snapshot and prints on standard output:
|
|
# initial no snapshot: first tracked version
|
|
# unchanged no change in the public API
|
|
# additive additions only (nothing removed or modified)
|
|
# breaking break: element removed/modified, or break seen by cargo-semver-checks
|
|
# All the detail goes to standard error.
|
|
#
|
|
# Two combined checks: cargo-semver-checks is the reference for breaks, but it does not
|
|
# report plain additions; the text diff of cargo public-api acts as a safety net (any removed
|
|
# or modified line = break) and provides the count of additions.
|
|
set -euo pipefail
|
|
. "$(dirname "$0")/common.sh"
|
|
|
|
if [ "${API_TRACKED:-yes}" = no ]; then
|
|
echo unchanged # no tracked Rust API: the version advances by patch (or RELEASE=x.y.z)
|
|
exit 0
|
|
fi
|
|
|
|
require_cargo_tool public-api cargo-public-api
|
|
require_cargo_tool semver-checks cargo-semver-checks
|
|
|
|
# A proc-macro crate has no library target: cargo-semver-checks cannot analyse it.
|
|
# Its API (the exported macros) is still tracked by the text diff of cargo public-api; this diff does
|
|
# not see a change in the macro's behaviour (rejected inputs, generated code): to be judged by hand.
|
|
is_proc_macro() {
|
|
"$CARGO" metadata --format-version 1 --no-deps | grep -q '"kind":\["proc-macro"\]'
|
|
}
|
|
|
|
last=$(latest_snapshot)
|
|
if [ -z "$last" ]; then
|
|
info " No snapshot in $API_DIR/: first tracked version"
|
|
echo initial
|
|
exit 0
|
|
fi
|
|
|
|
# A snapshot written with other tools (rustc, cargo-public-api) than today's is no longer
|
|
# comparable: cargo-semver-checks crashes on another rustdoc format, and the text diff sees
|
|
# breaks where only the rendering changed. It is regenerated from the tag of its version (no stamp =
|
|
# written before stamps existed, hence unknown).
|
|
if [ "$(cat "$API_DIR/$last.stamp" 2>/dev/null || true)" != "$(toolchain_stamp)" ]; then
|
|
info " Snapshot $last written with other tools: regenerating from tag version-$last"
|
|
regenerate_snapshot "$last" || {
|
|
err "✗ cannot regenerate snapshot $last: the comparison would be wrong"
|
|
exit 1
|
|
}
|
|
fi
|
|
|
|
tmp=$(mktemp -d)
|
|
trap 'rm -r "$tmp"' EXIT
|
|
info " Reference: API published in version $last"
|
|
|
|
"$CARGO" public-api -s >"$tmp/current.txt" 2>/dev/null || {
|
|
err "✗ cargo public-api failed"
|
|
exit 1
|
|
}
|
|
# `filter_unstable` (common.sh) removes from the cargo public-api text whatever is not the crate's API.
|
|
diff_out=$(diff <(filter_unstable "$API_DIR/$last.txt") <(filter_unstable "$tmp/current.txt") || true)
|
|
removed=$(printf '%s\n' "$diff_out" | grep -c '^<' || true)
|
|
added=$(printf '%s\n' "$diff_out" | grep -c '^>' || true)
|
|
|
|
# Code 100 = break; 0 = nothing to report; other = tool failure.
|
|
set +e
|
|
if is_proc_macro; then
|
|
info " proc-macro crate: cargo-semver-checks not applicable, text diff only"
|
|
rc=0
|
|
else
|
|
gzip -d -c "$API_DIR/$last.json.gz" >"$tmp/baseline.json"
|
|
"$CARGO" semver-checks --baseline-rustdoc "$tmp/baseline.json" --release-type minor >"$tmp/semver.log" 2>&1
|
|
rc=$?
|
|
fi
|
|
set -e
|
|
|
|
level=unchanged
|
|
if [ "$rc" -eq 100 ]; then
|
|
level=breaking
|
|
warn " Break detected by cargo-semver-checks:"
|
|
grep -E '^ +[A-Za-z0-9_]+::|^--- failure' "$tmp/semver.log" >&2 || true
|
|
elif [ "$rc" -ne 0 ]; then
|
|
err "✗ cargo-semver-checks failed (code $rc):"
|
|
tail -n 15 "$tmp/semver.log" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [ "$removed" -gt 0 ]; then
|
|
level=breaking
|
|
warn " $removed API line(s) removed or modified compared to $last:"
|
|
printf '%s\n' "$diff_out" | grep '^<' >&2
|
|
fi
|
|
|
|
if [ "$level" = unchanged ] && [ "$added" -gt 0 ]; then
|
|
level=additive
|
|
fi
|
|
|
|
info " API: +$added / -$removed lines; verdict: $level"
|
|
echo "$level"
|