fix: sync.sh reads catalog.yaml dynamically, no hardcodes

This commit is contained in:
2026-05-05 23:46:30 +02:00
parent e2d4231ea4
commit fc2a599904
+44 -38
View File
@@ -1,42 +1,48 @@
#!/bin/bash #!/usr/bin/env python3
# Sync ARAs from source project repos into this aggregator. """
# Uses git sparse-checkout to pull only the ara/ subdirectory. ARA Aggregator Sync
# Run after PRs are merged. Reads catalog.yaml and sparse-checkouts ara/ from each source repo.
Run this after PRs merge to update the aggregator from canonical sources.
"""
import yaml, subprocess, shutil, os, sys
set -e with open(os.path.join(os.path.dirname(__file__), "catalog.yaml")) as f:
GITEA="https://git.wylab.me" catalog = yaml.safe_load(f)
sync_ara() { errors = []
local id=$1 for artifact in catalog["artifacts"]:
local repo=$2 if artifact["status"] == "aggregator-only":
local branch=$3 print(f" skip {artifact['id']} (aggregator-only)")
local src_path=$4 continue
local dest="$id" if "pr-open" in artifact["status"] or "stub" in artifact["status"]:
print(f" skip {artifact['id']} (PR not yet merged: {artifact.get('pr','')})")
continue
echo "Syncing $id from $repo ($branch:$src_path)..." id, repo, branch, path = (
artifact["id"], artifact["repo"],
if [ -d "/tmp/sync-$id" ]; then artifact["branch"], artifact["path"].rstrip("/"),
rm -rf "/tmp/sync-$id" )
fi print(f"syncing {id} from {repo} ({branch}:{path}) ...")
tmp = f"/tmp/ara-sync-{id}"
git clone --no-checkout --filter=blob:none --depth=1 \ try:
-b "$branch" "$repo" "/tmp/sync-$id" 2>/dev/null shutil.rmtree(tmp, ignore_errors=True)
subprocess.run(
cd "/tmp/sync-$id" ["git","clone","--no-checkout","--filter=blob:none","--depth=1","-b",branch,repo,tmp],
git sparse-checkout init --cone check=True, capture_output=True,
git sparse-checkout set "$src_path" )
git checkout subprocess.run(["git","sparse-checkout","init","--cone"], cwd=tmp, check=True, capture_output=True)
subprocess.run(["git","sparse-checkout","set",path], cwd=tmp, check=True, capture_output=True)
cd - subprocess.run(["git","checkout"], cwd=tmp, check=True, capture_output=True)
rm -rf "$dest" dest = id
cp -r "/tmp/sync-$id/$src_path" "$dest" shutil.rmtree(dest, ignore_errors=True)
echo " Done: $id" shutil.copytree(f"{tmp}/{path}", dest)
} shutil.rmtree(tmp, ignore_errors=True)
print(f" ok: {id}")
except Exception as e:
errors.append((id, str(e)))
print(f" ERROR: {id}: {e}", file=sys.stderr)
# Sync after PRs merge: if errors:
# sync_ara "nanobot" "$GITEA/wylab/nanobot.git" "main" "ara" print(f"\nFailed: {[e[0] for e in errors]}", file=sys.stderr)
# sync_ara "ss14-cicd" "$GITEA/wylab/WS14-Docker-Linux-Server.git" "main" "ara" sys.exit(1)
# sync_ara "wylab-station-14" "$GITEA/wylab/wylab-station-14.git" "master" "ara" print("Sync complete.")
# traefik stays aggregator-only (no project repo)
echo "Sync complete."