Files
Eric Coissac e14fb6a287
Release / release (push) Successful in 1m12s
feat: add obipipeline crate with typed multi-threaded pipelines
Introduce the `obipipeline` crate, providing typed, composable multi-threaded
pipelines with memory-bounded throttling. The crate includes a scheduler for
managing pipeline stages, a throttle mechanism for concurrency control, and
comprehensive build and release tooling via `.crate-kit`.

- Add `Cargo.toml`, `Cargo.lock`, and `Makefile` to define the `obipipeline`
  package (v0.1.1) with `crossbeam-channel` dependency and build targets.
- Add `LICENSE` and `LICENSE.en` files containing the CeCILL free software
  license agreement under French law.
- Add `.gitignore` to exclude `target` and `/.cargo/config.toml` from version
  control.
- Add `.crate-kit/` directory with build configuration (`VERSION`, `crate.mk`,
  `org.mk`, `dev-patch.mk`, `jj.mk`) and 21 shell scripts for API tracking,
  dependency management, release workflows, and wiki generation.
- Add `.gitea/workflows/release.yaml` to automate releases on tag pushes,
  including building, publishing, and updating the wiki.
- Add `src/lib.rs` to expose `scheduler` and `throttle` modules, re-exporting
  core types like `Pipe`, `Pipeline`, `WorkerPool`, and `Throttle`.
- Add `src/scheduler/` module with `error.rs` (`PipelineError`), `macros.rs`
  (`make_pipe!`, `make_pipeline!`), `pipe.rs` (`Pipe`, `PipeIter`),
  `pool.rs` (`Pipeline`, `WorkerPool`), `runner.rs` (thread runners), and
  `types.rs` (`Stage`, `WorkerTask`, function aliases).
- Add `src/throttle.rs` implementing `Throttle`, `ThrottleGuard`, and
  `throttle` function for memory-bounded concurrency control using semaphores.
- Add `api/` directory with public API snapshots (`0.1.0`, `0.1.1`) in JSON,
  text, and stamp formats for version tracking.
- Add `examples/sandbox_pipeline.rs` demonstrating pipeline construction with
  `make_pipeline!` and `WorkerPool` using sample transformation steps.
- Add `tests/pipe.rs` with tests for pipe composition, flat transforms, and
  empty input handling.
- Add `tests/throttle.rs` with tests verifying throttle ordering, concurrency
  bounds, and guard blocking behavior.
- Update `README.md` with documentation for `obipipeline`, including core
  concepts, API details, and installation instructions.
2026-12-01 19:49:09 +01:00

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