-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·113 lines (99 loc) · 3.74 KB
/
bootstrap.sh
File metadata and controls
executable file
·113 lines (99 loc) · 3.74 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
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/usr/bin/env bash
# Bootstrap the tracker state from scratch.
# Usage: ./bootstrap.sh [--sdk-repo PATH]
#
# Requires: GITHUB_TOKEN env var, a local polkadot-sdk checkout.
# Builds the tracker, then runs discover -> onchain -> downstream -> annotate (dry-run).
set -euo pipefail
SDK_REPO="${POLKADOT_SDK_DIR:-$HOME/polkadot-sdk}"
for arg in "$@"; do
case "$arg" in
--sdk-repo=*) SDK_REPO="${arg#*=}" ;;
--sdk-repo) shift; SDK_REPO="$1" ;;
esac
shift 2>/dev/null || true
done
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
STATE_PATH="$SCRIPT_DIR/state.json"
TRACKER="$SCRIPT_DIR/target/release/tracker"
: "${GITHUB_TOKEN:?GITHUB_TOKEN env var required}"
if [ ! -d "$SDK_REPO/.git" ]; then
echo "Error: $SDK_REPO is not a git repo. Set --sdk-repo or POLKADOT_SDK_DIR." >&2
exit 1
fi
echo "==> Fetching latest tags in $SDK_REPO"
git -C "$SDK_REPO" fetch --tags --quiet 2>/dev/null || echo " (fetch skipped, using existing tags)"
echo "==> Building tracker"
cargo build --release --manifest-path "$SCRIPT_DIR/Cargo.toml" --quiet
echo "==> Writing minimal state.json"
cat > "$STATE_PATH" <<'EOF'
{
"project": {
"org": "paritytech",
"number": 274
},
"runtimes": [
{
"runtime": "Asset Hub",
"short": "AH",
"repo": "paseo-network/runtimes",
"branch": "main",
"cargo_lock_path": "Cargo.lock",
"cargo_toml_path": "system-parachains/asset-hub-paseo/Cargo.toml",
"spec_version_path": "system-parachains/asset-hub-paseo/src/lib.rs",
"network": "Paseo",
"rpc": "https://paseo-asset-hub-rpc.polkadot.io",
"ws": "wss://sys.ibp.network/asset-hub-paseo",
"field_name": "AH Paseo",
"block_explorer_url": "https://assethub-paseo.subscan.io",
"upgrades": []
},
{
"runtime": "Asset Hub",
"short": "AH",
"repo": "polkadot-fellows/runtimes",
"branch": "main",
"cargo_lock_path": "Cargo.lock",
"cargo_toml_path": "system-parachains/asset-hubs/asset-hub-kusama/Cargo.toml",
"spec_version_path": "system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs",
"network": "Kusama",
"rpc": "https://kusama-asset-hub-rpc.polkadot.io",
"ws": "wss://kusama-asset-hub-rpc.polkadot.io",
"field_name": "AH Kusama",
"block_explorer_url": "https://assethub-kusama.subscan.io",
"upgrades": []
},
{
"runtime": "Asset Hub",
"short": "AH",
"repo": "polkadot-fellows/runtimes",
"branch": "main",
"cargo_lock_path": "Cargo.lock",
"cargo_toml_path": "system-parachains/asset-hubs/asset-hub-polkadot/Cargo.toml",
"spec_version_path": "system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs",
"network": "Polkadot",
"rpc": "https://polkadot-asset-hub-rpc.polkadot.io",
"ws": "wss://polkadot-asset-hub-rpc.polkadot.io",
"field_name": "AH Polkadot",
"block_explorer_url": "https://assethub-polkadot.subscan.io",
"upgrades": []
}
],
"releases": []
}
EOF
echo "==> Step 1: Discover releases"
"$TRACKER" --sdk-repo "$SDK_REPO" --step discover
echo "==> Step 2: Check on-chain upgrades"
"$TRACKER" --sdk-repo "$SDK_REPO" --step onchain
echo "==> Step 3: Check downstream + annotate (dry-run)"
"$TRACKER" --sdk-repo "$SDK_REPO" --dry-run --step annotate
RELEASES=$(python3 -c "import json; d=json.load(open('$STATE_PATH')); print(len(d['releases']))")
CRATES=$(python3 -c "import json; d=json.load(open('$STATE_PATH')); print(sum(len(r['crates']) for r in d['releases']))")
UPGRADES=$(python3 -c "import json; d=json.load(open('$STATE_PATH')); print(sum(len(rt['upgrades']) for rt in d['runtimes']))")
echo ""
echo "==> Bootstrap complete"
echo " Releases: $RELEASES"
echo " Crate entries: $CRATES"
echo " On-chain upgrades: $UPGRADES"
echo " State: $STATE_PATH"