-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-local.sh
More file actions
executable file
·145 lines (117 loc) · 4.07 KB
/
Copy pathtest-local.sh
File metadata and controls
executable file
·145 lines (117 loc) · 4.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/bash
# Local test script for Aptos CLI Action
# This script tests the core logic without running the full GitHub Action
set -e
echo "🧪 Testing Aptos CLI Action Logic Locally"
echo "=========================================="
# Test 1: Version detection
echo "📋 Test 1: Version Detection"
echo "----------------------------"
# Test latest version detection
echo "Testing latest version detection..."
LATEST_TAG=$(curl -s https://api.github.com/repos/aptos-labs/aptos-core/releases | grep '"tag_name":' | grep 'aptos-cli-v' | head -1 | sed -E 's/.*"([^"]+)".*/\1/')
echo "Latest CLI tag: $LATEST_TAG"
# Extract version number from tag
if [[ "$LATEST_TAG" =~ aptos-cli-v([0-9]+\.[0-9]+\.[0-9]+) ]]; then
LATEST_VERSION="${BASH_REMATCH[1]}"
elif [[ "$LATEST_TAG" =~ v([0-9]+\.[0-9]+\.[0-9]+) ]]; then
LATEST_VERSION="${BASH_REMATCH[1]}"
elif [[ "$LATEST_TAG" =~ ([0-9]+\.[0-9]+\.[0-9]+) ]]; then
LATEST_VERSION="${BASH_REMATCH[1]}"
else
echo "❌ Could not extract version number from tag: $LATEST_TAG"
exit 1
fi
echo "Latest version: $LATEST_VERSION"
if [ -z "$LATEST_VERSION" ]; then
echo "❌ Failed to detect latest version"
exit 1
else
echo "✅ Latest version detected: $LATEST_VERSION"
fi
# Test specific version
echo "Testing specific version..."
SPECIFIC_VERSION="7.5.0"
echo "Specific version: $SPECIFIC_VERSION"
echo "✅ Specific version test passed"
# Test 2: URL generation
echo ""
echo "📋 Test 2: URL Generation"
echo "-------------------------"
# Detect OS and architecture for asset naming
case "$(uname -s)" in
Linux*) os_name="Linux" ;;
Darwin*) os_name="macOS" ;;
CYGWIN*|MINGW*|MSYS*) os_name="Windows" ;;
*) echo "Unsupported OS: $(uname -s)" && exit 1 ;;
esac
case "$(uname -m)" in
x86_64) arch_name="x86_64" ;;
arm64|aarch64) arch_name="arm64" ;;
*) echo "Unsupported architecture: $(uname -m)" && exit 1 ;;
esac
echo "Detected OS: $os_name"
echo "Detected Architecture: $arch_name"
# Generate URLs
LATEST_URL="https://github.com/aptos-labs/aptos-core/releases/download/aptos-cli-v${LATEST_VERSION}/aptos-cli-${LATEST_VERSION}-${os_name}-${arch_name}.zip"
SPECIFIC_URL="https://github.com/aptos-labs/aptos-core/releases/download/aptos-cli-v${SPECIFIC_VERSION}/aptos-cli-${SPECIFIC_VERSION}-${os_name}-${arch_name}.zip"
echo "Latest URL: $LATEST_URL"
echo "Specific URL: $SPECIFIC_URL"
# Test 3: URL accessibility
echo ""
echo "📋 Test 3: URL Accessibility"
echo "----------------------------"
echo "Testing latest URL accessibility..."
if curl --output /dev/null --silent --head --fail "$LATEST_URL"; then
echo "✅ Latest URL is accessible"
else
echo "❌ Latest URL is not accessible"
exit 1
fi
echo "Testing specific URL accessibility..."
if curl --output /dev/null --silent --head --fail "$SPECIFIC_URL"; then
echo "✅ Specific URL is accessible"
else
echo "❌ Specific URL is not accessible"
exit 1
fi
# Test 4: Download and installation simulation
echo ""
echo "📋 Test 4: Download and Installation Simulation"
echo "-----------------------------------------------"
# Create a temporary directory for testing
TEMP_DIR=$(mktemp -d)
cd "$TEMP_DIR"
echo "Downloading latest version..."
curl -L "$LATEST_URL" -o aptos.zip
if [ ! -f aptos.zip ]; then
echo "❌ Download failed"
exit 1
fi
echo "✅ Download successful"
# Extract and test
echo "Extracting..."
unzip -q aptos.zip -d aptos
if [ -f "aptos/aptos" ] || [ -f "aptos/aptos.exe" ]; then
echo "✅ Extraction successful"
# Test executable
if [ -f "aptos/aptos" ]; then
chmod +x aptos/aptos
echo "Testing executable..."
./aptos/aptos --version
echo "✅ Executable test passed"
elif [ -f "aptos/aptos.exe" ]; then
echo "✅ Windows executable found"
fi
else
echo "❌ Extraction failed - executable not found"
exit 1
fi
# Cleanup
cd - > /dev/null
rm -rf "$TEMP_DIR"
echo ""
echo "🎉 All tests passed!"
echo "==================="
echo "The Aptos CLI Action logic appears to be working correctly."
echo "You can now use this action in your GitHub workflows."