-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtest_release_binary.sh
More file actions
executable file
·92 lines (75 loc) · 2.34 KB
/
Copy pathtest_release_binary.sh
File metadata and controls
executable file
·92 lines (75 loc) · 2.34 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
#!/bin/bash
# Test released binaries by downloading from GitHub and running local testnet
#
# Usage:
# ./scripts/test_release_binary.sh # Latest release
# ./scripts/test_release_binary.sh v0.0.15-test # Specific version
# VERSION=v0.0.15-test ./scripts/test_release_binary.sh
set -eu
# Configuration
REPO="pushchain/push-chain-node"
BINARY_NAME="pchaind"
VERSION=${VERSION:-${1:-"latest"}}
INSTALL_DIR="${INSTALL_DIR:-/usr/local/bin}"
TEMP_DIR=$(mktemp -d)
# Detect OS and architecture
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
case $ARCH in
x86_64) ARCH="amd64" ;;
arm64|aarch64) ARCH="arm64" ;;
esac
echo "=== Release Binary Tester ==="
echo "OS: $OS, Arch: $ARCH"
# Check for gh CLI
if ! command -v gh &> /dev/null; then
echo "Error: GitHub CLI (gh) is required. Install from: https://cli.github.com/"
exit 1
fi
# Get version (resolve 'latest')
if [ "$VERSION" = "latest" ]; then
echo "Fetching latest release..."
VERSION=$(gh release view --repo $REPO --json tagName -q .tagName)
fi
VERSION_NO_V="${VERSION#v}"
echo "Version: $VERSION"
# Download binary
ASSET_NAME="push-chain_${VERSION_NO_V}_${OS}_${ARCH}.tar.gz"
echo "Downloading: $ASSET_NAME"
gh release download "$VERSION" --repo "$REPO" --pattern "$ASSET_NAME" --dir "$TEMP_DIR"
# Extract
echo "Extracting..."
cd "$TEMP_DIR"
tar -xzf "$ASSET_NAME"
# Find the binary (could be pchaind or pchaind-darwin-arm64 etc)
BINARY_FILE=$(find . -type f \( -perm -u+x -o -name "$BINARY_NAME*" \) 2>/dev/null | grep -E "pchaind" | head -1)
if [ -z "$BINARY_FILE" ]; then
BINARY_FILE=$(find . -name "$BINARY_NAME*" -type f | head -1)
fi
if [ -z "$BINARY_FILE" ]; then
echo "Error: Could not find binary in archive"
ls -la
exit 1
fi
chmod +x "$BINARY_FILE"
# Remove ./ prefix if present and construct full path
BINARY_FILE="${BINARY_FILE#./}"
BINARY_PATH="$TEMP_DIR/$BINARY_FILE"
# Check for libwasmvm.dylib (macOS) - bundled with binary
if [ -f "$TEMP_DIR/libwasmvm.dylib" ]; then
echo "Found bundled libwasmvm.dylib"
fi
# Verify binary works
echo ""
echo "=== Testing Binary ==="
"$BINARY_PATH" version
echo ""
echo "=== Starting Testnet ==="
# Run testnet with the downloaded binary
export BINARY="$BINARY_PATH"
export CLEAN=true
export CHAIN_ID="localchain_9000-1"
export BLOCK_TIME="1000ms"
# Return to repo root
cd - > /dev/null
sh scripts/test_node.sh