mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-08 11:46:35 +00:00
`make test` and `make lint` now delegate to a generic parallel-make wrapper that caps `-j` at INFINITO_WORKER_CPU, syncs per-target output, and prints wall-clock elapsed time. `make test` gains the full `lint` sweep and drops the phantom `test-deploy` target (PHONY without recipe); pre-commit hooks consolidate around a single `make test` invocation. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
48 lines
1.3 KiB
Bash
Executable File
48 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Generic parallel-make wrapper. Takes one or more make targets as
|
|
# args, derives `-j` from min(arg-count, INFINITO_WORKER_CPU) so each
|
|
# target gets at most one CPU and never more workers than necessary,
|
|
# runs them with --output-sync=target to keep logs readable, and
|
|
# prints wall-clock elapsed time at the end.
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
|
|
cd "${REPO_ROOT}"
|
|
|
|
if [[ $# -eq 0 ]]; then
|
|
echo "scripts/make/parallel.sh: at least one make target required" >&2 # nocheck: self-path-reference
|
|
exit 2
|
|
fi
|
|
|
|
# shellcheck source=scripts/meta/env/load.sh
|
|
source scripts/meta/env/load.sh
|
|
|
|
: "${INFINITO_WORKER_CPU:?INFINITO_WORKER_CPU must be set (provided by env/static.env via the env loader)}"
|
|
|
|
n_targets=$#
|
|
if ((n_targets < INFINITO_WORKER_CPU)); then
|
|
jobs="${n_targets}"
|
|
else
|
|
jobs="${INFINITO_WORKER_CPU}"
|
|
fi
|
|
|
|
format_duration() {
|
|
local seconds="$1"
|
|
printf '%dm %02ds' "$((seconds / 60))" "$((seconds % 60))"
|
|
}
|
|
|
|
echo
|
|
echo "🚀 parallel make dispatch"
|
|
echo " 📋 targets: $*"
|
|
echo " ⚙️ jobs: ${jobs} (cpu cap: ${INFINITO_WORKER_CPU})"
|
|
echo
|
|
|
|
SECONDS=0
|
|
make -j "${jobs}" --output-sync=target "$@"
|
|
elapsed=$SECONDS
|
|
|
|
echo
|
|
echo "✨ done in $(format_duration "${elapsed}") 🎉"
|
|
echo
|