|
95 | 95 | # Project uses yarn (as specified in package.json packageManager field) |
96 | 96 | # Enable corepack to use the correct yarn version |
97 | 97 | corepack enable |
| 98 | + # Configure yarn registry with fallback to mirror for better reliability |
| 99 | + # Try official registry first, fallback to Taobao mirror if needed |
| 100 | + yarn config set registry https://registry.npmjs.org/ || true |
| 101 | + yarn config set network-timeout 300000 || true |
98 | 102 | # IMPORTANT: skip lifecycle scripts in CI to avoid running `prepare` (husky install), |
99 | 103 | # which fails because `.git` is not present in GitHub Actions checkouts by default. |
100 | | - yarn install --frozen-lockfile --ignore-scripts |
| 104 | + # Retry logic: try up to 3 times with exponential backoff |
| 105 | + max_retries=3 |
| 106 | + retry_count=0 |
| 107 | + while [ $retry_count -lt $max_retries ]; do |
| 108 | + if yarn install --frozen-lockfile --ignore-scripts; then |
| 109 | + echo "✓ Dependencies installed successfully" |
| 110 | + break |
| 111 | + else |
| 112 | + retry_count=$((retry_count + 1)) |
| 113 | + if [ $retry_count -lt $max_retries ]; then |
| 114 | + echo "⚠ Install failed, retrying ($retry_count/$max_retries)..." |
| 115 | + # Switch to Taobao mirror on retry for better reliability in China/network issues |
| 116 | + if [ $retry_count -eq 2 ]; then |
| 117 | + echo "Switching to Taobao mirror for retry..." |
| 118 | + yarn config set registry https://registry.npmmirror.com/ || true |
| 119 | + fi |
| 120 | + sleep $((retry_count * 5)) |
| 121 | + else |
| 122 | + echo "✗ Failed to install dependencies after $max_retries attempts" |
| 123 | + exit 1 |
| 124 | + fi |
| 125 | + fi |
| 126 | + done |
101 | 127 | # Use --frozen-lockfile for reproducible installs. Use --ignore-scripts to keep CI non-intrusive. |
102 | 128 |
|
103 | 129 | - name: Frontend lint check |
|
0 commit comments