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.
69 lines
3.3 KiB
Bash
Executable File
69 lines
3.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Checks that the crate is adopted: the CI release workflow is installed and up to date with the template of
|
|
# its kind (comments and step names ignored; opt out with a `# kit-workflow: custom` line), and the kit copy
|
|
# (.crate-kit/) is identical to the reference kit (crate-kit + overlay, assembled by $KIT_SRC/tools/kit-assemble.sh; default ../crate-kit). Read-only.
|
|
#
|
|
# Compares the CONTENT, not VERSION: a fix to the kit does not always change its number.
|
|
# `--fix`: instead of failing on an out-of-date workflow, replace it with the template of its kind.
|
|
# Without a crate-kit repository alongside (clone of the crate alone, CI), there is nothing to compare: success.
|
|
set -euo pipefail
|
|
. "$(dirname "$0")/common.sh"
|
|
|
|
fix=0
|
|
[ "${1:-}" = "--fix" ] && fix=1
|
|
kit_dir="$(cd "$(dirname "$0")/.." && pwd)"
|
|
crate_dir="$(dirname "$kit_dir")"
|
|
|
|
# Without this workflow, a version-* tag publishes nothing: the crate was not adopted all the way.
|
|
workflow=".gitea/workflows/release.yaml"
|
|
if [ ! -f "$crate_dir/$workflow" ]; then
|
|
err "✗ $workflow is missing in $crate_dir: the release CI will not trigger"
|
|
info " Complete the adoption: crate-kit/adopt.sh [--kind <kind>] $crate_dir"
|
|
exit 1
|
|
fi
|
|
|
|
kit_src="${KIT_SRC:-../crate-kit}"
|
|
|
|
# Workflow up to date with the template of the crate's kind (the same one adopt.sh lays down). Only the
|
|
# logic counts: comment lines and `- name:` labels are ignored, so a rewording is not a difference.
|
|
if [ -x "$kit_src/tools/kit-assemble.sh" ] && ! grep -q '^# kit-workflow: custom' "$crate_dir/$workflow"; then
|
|
kind="${CRATE_KIND:-}"
|
|
if [ -z "$kind" ] && [ -f "$crate_dir/Makefile" ]; then
|
|
kind=$(sed -n 's/^CRATE_KIND *[:?]*= *\([a-z]*\).*/\1/p' "$crate_dir/Makefile" | head -n 1)
|
|
fi
|
|
template="$("$kit_src/tools/kit-assemble.sh" --root)/template"
|
|
overlay=$("$kit_src/tools/kit-assemble.sh" --overlay 2>/dev/null || true)
|
|
[ -n "$kind" ] && [ -n "$overlay" ] && [ -d "$overlay/templates/$kind" ] && template="$overlay/templates/$kind"
|
|
norm() { grep -v '^ *#' "$1" | grep -v '^ *- name:' | sed 's/[[:space:]]*$//'; }
|
|
if [ -f "$template/$workflow" ] && ! diff <(norm "$crate_dir/$workflow") <(norm "$template/$workflow") >/dev/null; then
|
|
if [ "$fix" = 1 ]; then
|
|
cp "$template/$workflow" "$crate_dir/$workflow"
|
|
ok "→ $workflow replaced with the template of its kind"
|
|
else
|
|
err "✗ $workflow differs from the template of its kind: the release CI is out of date"
|
|
diff <(norm "$crate_dir/$workflow") <(norm "$template/$workflow") >&2 || true
|
|
info " Replace it: cp $template/$workflow $crate_dir/$workflow"
|
|
info " (keep a deliberate customization by adding the line \"# kit-workflow: custom\" to the workflow)"
|
|
exit 1
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
if [ ! -x "$kit_src/tools/kit-assemble.sh" ]; then
|
|
info " (reference kit not found: $kit_src, check skipped)"
|
|
exit 0
|
|
fi
|
|
ref="$(mktemp -d "${TMPDIR:-/tmp}/kit-check.XXXXXX")"
|
|
trap 'rm -r "$ref"' EXIT
|
|
"$kit_src/tools/kit-assemble.sh" "$ref"
|
|
|
|
if diff -rq "$ref" "$kit_dir" >/dev/null 2>&1; then
|
|
ok "✓ Kit up to date (crate-kit $(cat "$ref/VERSION"))"
|
|
exit 0
|
|
fi
|
|
|
|
err "✗ This crate's kit is not the one from $kit_src:"
|
|
diff -rq "$ref" "$kit_dir" >&2 || true
|
|
info " Update: make kit-update"
|
|
exit 1
|