feat(ingest): Improve general script robustness and cleanup
This commit is contained in:
parent
99806b8b3d
commit
00fb74c76a
3 changed files with 19 additions and 3 deletions
|
|
@ -35,7 +35,7 @@ esac
|
|||
|
||||
[[ -f "$LOG_FILE" ]] || { echo "log-append: not found: $LOG_FILE" >&2; exit 1; }
|
||||
|
||||
run_id="$(uuidgen 2>/dev/null || cat /proc/sys/kernel/random/uuid)"
|
||||
run_id="$(uuidgen 2>/dev/null || cat /proc/sys/kernel/random/uuid 2>/dev/null || python3 -c 'import uuid; print(uuid.uuid4())')"
|
||||
today="$(date +%Y-%m-%d)"
|
||||
|
||||
{
|
||||
|
|
|
|||
|
|
@ -46,6 +46,11 @@ all_paths=( "${created_paths[@]}" "${modified_paths[@]}" )
|
|||
|
||||
conflict_label=""
|
||||
|
||||
# NOTE: no rollback. Steps below mutate the working tree in order (index → log → commit).
|
||||
# All are idempotent on re-run EXCEPT log-append (append-only). If a step fails midway,
|
||||
# nothing is committed (open-pr is the only committer) — the operator re-runs, or inspects
|
||||
# wiki/ if log-append already wrote a line. The manifest is removed only on full success.
|
||||
|
||||
# --- 1. index entries (created pages only), inserted in order ---
|
||||
while IFS=$'\t' read -r path summary maturity; do
|
||||
[[ -z "$path" ]] && continue
|
||||
|
|
@ -119,4 +124,10 @@ jq -nc \
|
|||
--arg detail "$pr_out" \
|
||||
'{status:$status, slug:$slug, pr_url:$pr_url, lint_clean:$lint_clean, conflict:$conflict, detail:$detail}'
|
||||
|
||||
[[ $pr_rc -eq 0 ]]
|
||||
# The manifest is a single file overwritten by each pi run (not accumulating), but on full
|
||||
# success we remove it so a stale manifest can never be re-processed by mistake.
|
||||
if [[ $pr_rc -eq 0 ]]; then
|
||||
rm -f "$manifest"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -12,7 +12,12 @@
|
|||
# =============================================================================
|
||||
set -euo pipefail
|
||||
|
||||
: "${KG_LIB_DIR:?set KG_LIB_DIR to the framework lib/ dir (e.g. /opt/knowledge-genome-setup/lib)}"
|
||||
: "${KG_LIB_DIR:?set KG_LIB_DIR to the framework lib/ dir (e.g. /opt/knowledge-genome-orchestrator/lib)}"
|
||||
|
||||
# Fail clearly if the lib files are missing, rather than a raw `source: No such file`.
|
||||
for _f in output.sh lint.sh; do
|
||||
[[ -f "${KG_LIB_DIR}/${_f}" ]] || { echo "scoped-lint: missing ${KG_LIB_DIR}/${_f}" >&2; exit 1; }
|
||||
done
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
source "${KG_LIB_DIR}/output.sh"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue