-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync.sh
More file actions
executable file
·63 lines (56 loc) · 2.04 KB
/
sync.sh
File metadata and controls
executable file
·63 lines (56 loc) · 2.04 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
#!/usr/bin/env bash
# Vendor the canonical conformance suite into each sibling SDK, or verify that the
# vendored copies are in sync. conformance/ is the single source of truth.
#
# ./sync.sh # copy the canonical suite into each SDK (run after edits)
# ./sync.sh --check # diff vendored copies vs canonical; exit 1 on any drift
#
# --check is the local counterpart to each SDK's CI drift guard (which fetches the
# canonical repo and diffs its own vendored copy).
set -euo pipefail
here="$(cd "$(dirname "$0")" && pwd)"
root="$(dirname "$here")"
mode="sync"
if [ "${1:-}" = "--check" ]; then
mode="check"
fi
# Per-SDK vendored copy. Go uses testdata/ (the toolchain ignores it in builds),
# Java uses src/test/resources/, the rest use tests/conformance/ — the existence
# check derives the SDK root from each dest, so any nesting depth works.
targets=(
"$root/php-sdk/tests/conformance"
"$root/babelqueue-python/tests/conformance"
"$root/babelqueue-go/testdata/conformance"
"$root/babelqueue-node/test/conformance"
"$root/babelqueue-java/src/test/resources/conformance"
"$root/babelqueue-dotnet/tests/BabelQueue.Core.Tests/conformance"
)
drifted=0
for dest in "${targets[@]}"; do
sdk="$(dirname "$(dirname "$dest")")"
if [ ! -d "$sdk" ]; then
echo "skip (missing): $sdk"
continue
fi
if [ "$mode" = "check" ]; then
if diff -q "$here/manifest.json" "$dest/manifest.json" >/dev/null 2>&1 \
&& diff -qr "$here/fixtures" "$dest/fixtures" >/dev/null 2>&1 \
&& diff -qr "$here/schema" "$dest/schema" >/dev/null 2>&1; then
echo "in sync: $dest"
else
echo "DRIFT: $dest"
drifted=1
fi
else
rm -rf "$dest"
mkdir -p "$dest/fixtures" "$dest/schema"
cp "$here/manifest.json" "$dest/manifest.json"
cp "$here"/fixtures/*.json "$dest/fixtures/"
cp "$here"/schema/*.json "$dest/schema/"
echo "synced -> $dest"
fi
done
if [ "$mode" = "check" ] && [ "$drifted" = 1 ]; then
echo "Vendored conformance copies drifted from the canonical suite. Run ./sync.sh." >&2
exit 1
fi