Skip to content

Commit 43ef514

Browse files
committed
fix(ci): add retry logic to verify-pypi/testpypi for index propagation
PyPI and TestPyPI can take a few seconds to index newly published packages. Add a retry loop that attempts installation up to 5 times with 10 second delays to handle this race condition.
1 parent 52a7d76 commit 43ef514

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

Justfile

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,22 +186,46 @@ vale-sync:
186186
version:
187187
uv version --package {{package}} | awk '{print $2}'
188188

189-
# Verify a PyPi release
189+
# Verify a PyPi release (with retries for index propagation)
190190
[script]
191191
verify-pypi version:
192192
tmp_dir="/tmp/{{package}}-verify-pypi/venv"
193193
rm -fr "${tmp_dir}"
194194
mkdir -p "${tmp_dir}"
195195
uv venv --directory "${tmp_dir}" --python 3.10 --no-project --no-cache
196-
uv pip install --directory "${tmp_dir}" --no-cache --strict "{{package}}=={{version}}"
196+
for i in 1 2 3 4 5; do
197+
echo "Attempt $i: Installing {{package}}=={{version}} from PyPI..."
198+
if uv pip install --directory "${tmp_dir}" --no-cache --strict "{{package}}=={{version}}"; then
199+
break
200+
fi
201+
if [ "$i" -lt 5 ]; then
202+
echo "Package not yet available, waiting 10 seconds..."
203+
sleep 10
204+
else
205+
echo "Failed to install after 5 attempts"
206+
exit 1
207+
fi
208+
done
197209
uv run --directory "${tmp_dir}" --no-project python -c "import {{module}}; print({{module}}.__version__)"
198210

199-
# Verify a TestPyPi release
211+
# Verify a TestPyPi release (with retries for index propagation)
200212
[script]
201213
verify-testpypi version:
202214
tmp_dir="/tmp/{{package}}-verify-testpypi/venv"
203215
rm -fr "${tmp_dir}"
204216
mkdir -p "${tmp_dir}"
205217
uv venv --directory "${tmp_dir}" --python 3.10 --no-project --no-cache --default-index "https://test.pypi.org/simple/" --extra-index-url "https://pypi.org/simple/"
206-
uv pip install --directory "${tmp_dir}" --no-cache --strict --default-index "https://test.pypi.org/simple/" --extra-index-url "https://pypi.org/simple/" "{{package}}=={{version}}"
218+
for i in 1 2 3 4 5; do
219+
echo "Attempt $i: Installing {{package}}=={{version}} from TestPyPI..."
220+
if uv pip install --directory "${tmp_dir}" --no-cache --strict --default-index "https://test.pypi.org/simple/" --extra-index-url "https://pypi.org/simple/" "{{package}}=={{version}}"; then
221+
break
222+
fi
223+
if [ "$i" -lt 5 ]; then
224+
echo "Package not yet available, waiting 10 seconds..."
225+
sleep 10
226+
else
227+
echo "Failed to install after 5 attempts"
228+
exit 1
229+
fi
230+
done
207231
uv run --directory "${tmp_dir}" --no-project python -c "import {{module}}; print({{module}}.__version__)"

0 commit comments

Comments
 (0)