-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpcs-schema-sync.sh
More file actions
100 lines (87 loc) · 3.07 KB
/
Copy pathpcs-schema-sync.sh
File metadata and controls
100 lines (87 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env bash
# Sync PCS JSON schemas from pcs-core into provability-fabric mirrors.
# Preserves PF-only schemas (admission benchmarks, computation bundle, profiles).
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
VENDOR="${1:-${PCS_CORE_PATH:-}}"
CANONICAL="${PCS_CORE_SCHEMAS:-}"
if [[ -z "${CANONICAL}" ]]; then
if [[ -n "${VENDOR}" && -d "${VENDOR}/schemas" ]]; then
CANONICAL="${VENDOR}/schemas"
elif [[ -d "${ROOT}/../pcs-core/schemas" ]]; then
CANONICAL="${ROOT}/../pcs-core/schemas"
else
echo "usage: pcs-schema-sync.sh [pcs-core_repo_root]" >&2
echo " or set PCS_CORE_PATH / PCS_CORE_SCHEMAS" >&2
exit 2
fi
fi
if [[ ! -d "${CANONICAL}" ]]; then
echo "pcs-core schemas not found: ${CANONICAL}" >&2
exit 1
fi
PF_ONLY=(
"AdmissionBenchmarkCase.v0.schema.json"
"ScienceClaimBundle.computation.v0.schema.json"
)
PF_ONLY_PROFILES=(
"ScienceClaimBundle.computation.v0.schema.json"
)
STAGING="$(mktemp -d 2>/dev/null || mktemp -d -t pf-pcs-schema-sync)"
trap 'rm -rf "${STAGING}"' EXIT
for name in "${PF_ONLY[@]}"; do
for dest in "${ROOT}/config/schemas/pcs" "${ROOT}/adapters/pcs/schemas"; do
if [[ -f "${dest}/${name}" ]]; then
cp -f "${dest}/${name}" "${STAGING}/${name}"
fi
done
done
if [[ -d "${ROOT}/config/schemas/pcs/profiles" ]]; then
mkdir -p "${STAGING}/profiles"
for name in "${PF_ONLY_PROFILES[@]}"; do
if [[ -f "${ROOT}/config/schemas/pcs/profiles/${name}" ]]; then
cp -f "${ROOT}/config/schemas/pcs/profiles/${name}" "${STAGING}/profiles/${name}"
fi
done
fi
sync_dir() {
local dest="$1"
mkdir -p "${dest}"
if command -v rsync >/dev/null 2>&1; then
rsync -a --delete "${CANONICAL}/" "${dest}/"
else
rm -rf "${dest:?}"/*
cp -a "${CANONICAL}/." "${dest}/"
fi
}
sync_dir "${ROOT}/config/schemas/pcs"
sync_dir "${ROOT}/adapters/pcs/schemas"
for name in "${PF_ONLY[@]}"; do
if [[ -f "${STAGING}/${name}" ]]; then
cp -f "${STAGING}/${name}" "${ROOT}/config/schemas/pcs/${name}"
cp -f "${STAGING}/${name}" "${ROOT}/adapters/pcs/schemas/${name}"
fi
done
if [[ -d "${STAGING}/profiles" ]]; then
mkdir -p "${ROOT}/config/schemas/pcs/profiles"
cp -af "${STAGING}/profiles/." "${ROOT}/config/schemas/pcs/profiles/"
fi
mirror_pcs_bench_ingest_alias() {
local dest="$1"
local canonical_ingest="${dest}/PcsBenchIngest.v0.schema.json"
local alias_ingest="${dest}/PCSBenchIngest.v0.schema.json"
if [[ ! -f "${canonical_ingest}" ]]; then
return 0
fi
if [[ ! -e "${alias_ingest}" ]] || ! cmp -s "${canonical_ingest}" "${alias_ingest}"; then
cp -f "${canonical_ingest}" "${alias_ingest}" 2>/dev/null || true
fi
}
mirror_pcs_bench_ingest_alias "${ROOT}/config/schemas/pcs"
mirror_pcs_bench_ingest_alias "${ROOT}/adapters/pcs/schemas"
echo "Synced pcs-core schemas from ${CANONICAL} to:"
echo " ${ROOT}/config/schemas/pcs"
echo " ${ROOT}/adapters/pcs/schemas"
echo "Preserved PF-only: ${PF_ONLY[*]}"
echo "Mirrored PcsBenchIngest.v0.schema.json -> PCSBenchIngest.v0.schema.json (PF CLI alias)"
PCS_CORE_SCHEMAS="${CANONICAL}" bash "${ROOT}/scripts/pcs-schema-diff.sh"