Skip to content

Commit 7c443d9

Browse files
Add retry logic for spacetimedb install
1 parent 5bf8a93 commit 7c443d9

File tree

1 file changed

+44
-6
lines changed

1 file changed

+44
-6
lines changed

.github/workflows/test.yml

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,52 @@ jobs:
2121

2222
- name: Install SpacetimeDB CLI
2323
run: |
24-
# Install SpacetimeDB CLI with non-interactive approach using --yes flag
25-
curl -sSf https://install.spacetimedb.com | sh -s -- --yes
24+
# Function to attempt SpacetimeDB CLI installation
25+
install_spacetimedb() {
26+
echo "Attempting to install SpacetimeDB CLI..."
27+
curl -sSf https://install.spacetimedb.com | sh -s -- --yes
28+
return $?
29+
}
2630
27-
# Add the correct path based on installation message
28-
echo "$HOME/.local/bin" >> $GITHUB_PATH
31+
# Function to verify installation
32+
verify_installation() {
33+
if [ -f "$HOME/.local/bin/spacetime" ]; then
34+
echo "✅ SpacetimeDB CLI installed successfully"
35+
echo "$HOME/.local/bin" >> $GITHUB_PATH
36+
ls -la "$HOME/.local/bin/" || echo "Local bin directory not found"
37+
return 0
38+
else
39+
echo "❌ SpacetimeDB CLI installation failed - spacetime binary not found"
40+
return 1
41+
fi
42+
}
2943
30-
# Verify installation worked
31-
ls -la "$HOME/.local/bin/" || echo "Local bin directory not found"
44+
# Retry logic: attempt installation up to 3 times
45+
MAX_ATTEMPTS=3
46+
ATTEMPT=1
47+
48+
while [ $ATTEMPT -le $MAX_ATTEMPTS ]; do
49+
echo "📦 Installation attempt $ATTEMPT of $MAX_ATTEMPTS"
50+
51+
if install_spacetimedb; then
52+
echo "🔍 Verifying installation..."
53+
if verify_installation; then
54+
echo "🎉 SpacetimeDB CLI installation successful on attempt $ATTEMPT"
55+
break
56+
fi
57+
fi
58+
59+
if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then
60+
echo "💥 Failed to install SpacetimeDB CLI after $MAX_ATTEMPTS attempts"
61+
echo "Last error details:"
62+
curl -v https://install.spacetimedb.com 2>&1 || echo "Could not reach installation server"
63+
exit 1
64+
fi
65+
66+
echo "⏳ Waiting 5 seconds before retry..."
67+
sleep 5
68+
ATTEMPT=$((ATTEMPT + 1))
69+
done
3270
3371
- name: Build & test SpacetimeDSL
3472
run: |

0 commit comments

Comments
 (0)