Skip to content

Commit 90e91ad

Browse files
committed
[CI] Add retry logic to artifact download action
1 parent 23cac32 commit 90e91ad

File tree

2 files changed

+58
-14
lines changed

2 files changed

+58
-14
lines changed

.github/actions/download-artifact-extract/action.yml

Lines changed: 54 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,67 @@ inputs:
2525
description: "Whether to remove downloaded artifacts after copying (true/false)"
2626
required: false
2727
default: "false"
28+
max-retries:
29+
description: "Maximum number of retry attempts for artifact download (total attempts = max-retries + 1)"
30+
required: false
31+
default: "2"
32+
retry-delay-seconds:
33+
description: "Delay in seconds between retry attempts"
34+
required: false
35+
default: "10"
2836

2937
runs:
3038
using: "composite"
3139
steps:
3240
- name: Download artifact
3341
shell: bash
42+
env:
43+
ARTIFACT_NAME: ${{ inputs.artifact-name }}
44+
GH_TOKEN: ${{ inputs.gh-token }}
45+
RUN_ID: ${{ inputs.run-id }}
46+
EXTRACT_PATH: ${{ inputs.extract-path }}
47+
MAX_RETRIES: ${{ inputs.max-retries }}
48+
RETRY_DELAY: ${{ inputs.retry-delay-seconds }}
3449
run: |
35-
echo "::group::📦 Downloading ${{ inputs.artifact-name }}"
36-
echo "Artifact: ${{ inputs.artifact-name }}"
37-
echo "Run ID: ${{ inputs.run-id }}"
38-
echo "::endgroup::"
39-
40-
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
41-
with:
42-
name: ${{ inputs.artifact-name }}
43-
github-token: ${{ inputs.gh-token }}
44-
run-id: ${{ inputs.run-id }}
45-
path: ${{ inputs.extract-path }}
50+
echo "::group::📦 Downloading $ARTIFACT_NAME"
51+
echo "Artifact: $ARTIFACT_NAME"
52+
echo "Run ID: $RUN_ID"
53+
echo "Max retries: $MAX_RETRIES"
54+
55+
# Create extract path if it doesn't exist
56+
mkdir -p "$EXTRACT_PATH"
57+
58+
ATTEMPT=1
59+
MAX_ATTEMPTS=$((MAX_RETRIES + 1))
60+
CURRENT_DELAY=$RETRY_DELAY
61+
62+
while [ $ATTEMPT -le $MAX_ATTEMPTS ]; do
63+
echo ""
64+
echo "📥 Attempt $ATTEMPT of $MAX_ATTEMPTS..."
65+
66+
# Use gh CLI to download artifact
67+
if gh run download "$RUN_ID" \
68+
--name "$ARTIFACT_NAME" \
69+
--dir "$EXTRACT_PATH" \
70+
--repo "$GITHUB_REPOSITORY"; then
71+
echo "✅ Successfully downloaded artifact on attempt $ATTEMPT"
72+
echo "::endgroup::"
73+
exit 0
74+
fi
75+
76+
if [ $ATTEMPT -lt $MAX_ATTEMPTS ]; then
77+
echo "::warning::Attempt $ATTEMPT failed, retrying in ${CURRENT_DELAY}s (exponential backoff)..."
78+
sleep "$CURRENT_DELAY"
79+
# Exponential backoff: double the delay for next attempt
80+
CURRENT_DELAY=$((CURRENT_DELAY * 2))
81+
else
82+
echo "::error::❌ All $MAX_ATTEMPTS attempts failed to download artifact: $ARTIFACT_NAME"
83+
echo "::endgroup::"
84+
exit 1
85+
fi
86+
87+
ATTEMPT=$((ATTEMPT + 1))
88+
done
4689
4790
- name: Extract artifact
4891
shell: bash

.github/workflows/zombienet_cumulus.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,12 @@ jobs:
8080
- name: Checkout
8181
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
8282

83-
- uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
83+
- name: Download test parachain artifact
8484
if: ${{ matrix.test.needs-wasm-binary }}
85+
uses: ./.github/actions/download-artifact-extract
8586
with:
86-
name: build-test-parachain-${{ needs.preflight.outputs.SOURCE_REF_SLUG }}
87-
github-token: ${{ secrets.GITHUB_TOKEN }}
87+
artifact-name: build-test-parachain-${{ needs.preflight.outputs.SOURCE_REF_SLUG }}
88+
gh-token: ${{ secrets.GITHUB_TOKEN }}
8889
run-id: ${{ needs.preflight.outputs.BUILD_RUN_ID }}
8990

9091
- name: zombienet_test

0 commit comments

Comments
 (0)