Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9845242

Browse files
authoredSep 25, 2024··
fix(ci) Add script to fetch graz chains (#434)
* fix(ci) Add script to fetch graz chains * pre-commit * retry mechanism * final fix * fix
1 parent 3584ad3 commit 9845242

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed
 

‎package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"start": "next start",
99
"lint": "next lint",
1010
"test": "jest",
11-
"postinstall": "graz generate -g"
11+
"postinstall": "bash scripts/fetchGrazChains.sh"
1212
},
1313
"dependencies": {
1414
"@amplitude/analytics-browser": "^2.8.1",

‎scripts/fetchGrazChains.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
MAX_RETRIES=10
3+
command_exists() {
4+
command -v "$1" >/dev/null 2>&1
5+
}
6+
if ! command_exists graz; then
7+
echo "graz is not installed."
8+
if command_exists npm; then
9+
npm install -g graz
10+
else
11+
echo "Error: npm is not installed. Please install npm and try again."
12+
exit 1
13+
fi
14+
fi
15+
16+
fetch_graz_chains() {
17+
local retry_count=0
18+
19+
while [ $retry_count -lt $MAX_RETRIES ]; do
20+
echo "Attempt $((retry_count + 1)) to fetch cosmos chains..."
21+
22+
if graz generate -g; then
23+
echo "Successfully fetched cosmos chains!"
24+
return 0
25+
else
26+
retry_count=$((retry_count + 1))
27+
if [ $retry_count -lt $MAX_RETRIES ]; then
28+
echo "Fetch failed. Retrying in 5 seconds..."
29+
sleep 5
30+
else
31+
echo "Max retries reached. Unable to fetch cosmos chains."
32+
fi
33+
fi
34+
done
35+
36+
return 1
37+
}
38+
39+
if fetch_graz_chains; then
40+
echo "Cosmos chains have been successfully fetched and stored in $OUTPUT_DIR"
41+
else
42+
echo "Failed to fetch cosmos chains after $MAX_RETRIES attempts."
43+
exit 1
44+
fi

0 commit comments

Comments
 (0)
Please sign in to comment.