Skip to content

ci: retry PyPI install smoke test to tolerate index propagation#437

Merged
bigcat88 merged 1 commit intomainfrom
ci/retry-pypi-install-smoke-test
Apr 24, 2026
Merged

ci: retry PyPI install smoke test to tolerate index propagation#437
bigcat88 merged 1 commit intomainfrom
ci/retry-pypi-install-smoke-test

Conversation

@bigcat88
Copy link
Copy Markdown
Contributor

@bigcat88 bigcat88 commented Apr 24, 2026

Summary

The post-publish smoke test in publish_package.yml failed on the v1.7.3 release (run 24876171699) even though the package itself uploaded successfully. The install job ran ~30s after publish and pip reported no matching distribution — PyPI's index simply had not yet surfaced the new version. The previous TestPyPI validation step had a retry loop for exactly this reason; it was lost when trusted publishing replaced it.

Changes:

  • Retry pip install comfy-cli==$VERSION up to 8× with 15s between attempts (~2 min total) before failing the job, with a clear ::error:: annotation on final failure.
  • Strip the leading v from the tag-derived VERSION in both jobs so pyproject.toml and the install specifier use the PEP 440 canonical form (1.7.3) rather than relying on implicit normalization. pip was already normalizing ==v1.7.3 transparently, so this is hygiene rather than a functional fix.

The post-publish install check ran seconds after upload and failed because
PyPI's index had not yet surfaced the new version. Retry the pip install up
to 8 times (15s apart) before failing, and normalize the tag-derived version
to strip the leading "v" so pyproject.toml and the install specifier use the
PEP 440 canonical form.
@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Apr 24, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 24, 2026

📝 Walkthrough

Walkthrough

The publish package workflow now normalizes VERSION by removing leading v in both jobs and replaces the single pip-installation test attempt with a bounded retry loop (8 attempts) featuring --no-cache-dir, 15-second waits, and explicit error handling for delayed package availability on PyPI.

Changes

Cohort / File(s) Summary
GitHub Actions Workflow Configuration
.github/workflows/publish_package.yml
Normalized VERSION variable handling across jobs by stripping leading v prefix. Enhanced pip installation test with retry logic (8 attempts, 15-second intervals) and --no-cache-dir flag to handle PyPI synchronization delays more gracefully—looks like the workflow was tired of failing on the first attempt! Added explicit error reporting and exit code on repeated failures.
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/retry-pypi-install-smoke-test
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch ci/retry-pypi-install-smoke-test

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@           Coverage Diff           @@
##             main     #437   +/-   ##
=======================================
  Coverage   78.02%   78.02%           
=======================================
  Files          35       35           
  Lines        4319     4319           
=======================================
  Hits         3370     3370           
  Misses        949      949           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/publish_package.yml:
- Around line 29-32: Compute and expose the canonical VERSION once in the
build-n-publish-pypi job and consume it in test-pip-installation via job outputs
to avoid duplicating the v-stripping logic: move the VERSION computation (use
parameter expansion that strips both lowercase and uppercase prefixes, e.g.
`${VERSION#[vV]}`) into the build-n-publish-pypi step, set it as an output
(jobs.build-n-publish-pypi.outputs.version), and update test-pip-installation to
read needs.build-n-publish-pypi.outputs.version instead of recomputing; update
any other duplicated occurrences (e.g., the block around lines 78-81) to use the
shared output as well.
- Around line 83-93: In the "Install Comfy CLI via pip and Test" step update the
retry loop to capture and surface pip's failure details and to bound each
attempt with a timeout: run pip install "comfy-cli==${VERSION}" under a
per-attempt timeout (e.g. with the timeout utility) and use pip's network
timeout flag (--timeout) as well; on a failed attempt capture pip's exit code
and stderr/stdout (or at least echo the exit code) before sleeping so the final
"::error::" contains diagnostic info; ensure the loop still exits on success
(exit 0) and preserves the existing retry count and sleep behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 033fb598-a19f-4de0-a5c7-94b24018af5d

📥 Commits

Reviewing files that changed from the base of the PR and between 1150586 and c1f144a.

📒 Files selected for processing (1)
  • .github/workflows/publish_package.yml

Comment on lines +29 to +32
run: |
VERSION="${GITHUB_REF#refs/tags/}"
VERSION="${VERSION#v}"
echo "VERSION=${VERSION}" >> $GITHUB_ENV
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Tiny DRY nit: the v-stripping dance is duplicated in both jobs.

No bug here — just a pinch of repetition. You could compute VERSION once in build-n-publish-pypi and expose it via jobs.<id>.outputs, then consume it in test-pip-installation through needs.build-n-publish-pypi.outputs.version. One tag, one truth — no copy-paste to chase.

Also worth noting: ${VERSION#v} strips only a lowercase leading v. If a maintainer ever tags V1.2.3, it'll sneak through un-stripped. Unlikely given your tagging convention, but a ${VERSION#[vV]} would slam that door shut.

♻️ Optional refactor sketch (share the version across jobs)
   build-n-publish-pypi:
     ...
+    outputs:
+      version: ${{ steps.get_version.outputs.version }}
     steps:
       ...
       - name: Extract version from tag
         id: get_version
         run: |
           VERSION="${GITHUB_REF#refs/tags/}"
-          VERSION="${VERSION#v}"
+          VERSION="${VERSION#[vV]}"
           echo "VERSION=${VERSION}" >> $GITHUB_ENV
+          echo "version=${VERSION}" >> $GITHUB_OUTPUT
   ...
   test-pip-installation:
     needs: build-n-publish-pypi
     ...
     steps:
       ...
-      - name: Extract version from tag
-        id: get_version
-        run: |
-          VERSION="${GITHUB_REF#refs/tags/}"
-          VERSION="${VERSION#v}"
-          echo "VERSION=${VERSION}" >> $GITHUB_ENV
+      - name: Resolve version from upstream job
+        run: echo "VERSION=${{ needs.build-n-publish-pypi.outputs.version }}" >> $GITHUB_ENV

Also applies to: 78-81

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/publish_package.yml around lines 29 - 32, Compute and
expose the canonical VERSION once in the build-n-publish-pypi job and consume it
in test-pip-installation via job outputs to avoid duplicating the v-stripping
logic: move the VERSION computation (use parameter expansion that strips both
lowercase and uppercase prefixes, e.g. `${VERSION#[vV]}`) into the
build-n-publish-pypi step, set it as an output
(jobs.build-n-publish-pypi.outputs.version), and update test-pip-installation to
read needs.build-n-publish-pypi.outputs.version instead of recomputing; update
any other duplicated occurrences (e.g., the block around lines 78-81) to use the
shared output as well.

Comment on lines 83 to +93
- name: Install Comfy CLI via pip and Test
run: pip install comfy-cli==${{env.VERSION}}
run: |
# PyPI's index can lag behind a successful upload by a minute or
# two, so retry before failing the job.
for i in 1 2 3 4 5 6 7 8; do
pip install --no-cache-dir "comfy-cli==${VERSION}" && exit 0
echo "Attempt $i: package not yet available on PyPI, waiting 15s..."
sleep 15
done
echo "::error::Failed to install comfy-cli==${VERSION} after 8 attempts"
exit 1
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Retry loop looks solid — here's a small polish to keep diagnostics crisp.

The logic holds up (thanks to GitHub's default bash -eo pipefail, the failing pip install inside a && list won't abort the script, so the retry actually retries — nice). Two small, optional tweaks:

  1. Capture why pip bailed. Right now any failure — stale index, network hiccup, resolver conflict — looks identical. Teeing pip's output (or echoing its exit code) on each attempt makes post-mortems far less mysterious when the loop exhausts.
  2. Guard against a pip-hang. pip install has no built-in per-attempt deadline, so in the pathological case you could burn the runner's job timeout on a single stuck attempt. A --timeout (network socket timeout) plus a wrapping timeout 60s gives the retry loop teeth.
🛠️ Proposed polish for the retry loop
       - name: Install Comfy CLI via pip and Test
         run: |
           # PyPI's index can lag behind a successful upload by a minute or
           # two, so retry before failing the job.
           for i in 1 2 3 4 5 6 7 8; do
-            pip install --no-cache-dir "comfy-cli==${VERSION}" && exit 0
-            echo "Attempt $i: package not yet available on PyPI, waiting 15s..."
+            if timeout 60s pip install --no-cache-dir --timeout 30 "comfy-cli==${VERSION}"; then
+              exit 0
+            fi
+            echo "Attempt $i failed (exit=$?); waiting 15s for PyPI index to catch up..."
             sleep 15
           done
           echo "::error::Failed to install comfy-cli==${VERSION} after 8 attempts"
           exit 1

A rhyme to sum it up: the loop is sound and tightly bound; log the cause so the fault is found. 🐇

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/publish_package.yml around lines 83 - 93, In the "Install
Comfy CLI via pip and Test" step update the retry loop to capture and surface
pip's failure details and to bound each attempt with a timeout: run pip install
"comfy-cli==${VERSION}" under a per-attempt timeout (e.g. with the timeout
utility) and use pip's network timeout flag (--timeout) as well; on a failed
attempt capture pip's exit code and stderr/stdout (or at least echo the exit
code) before sleeping so the final "::error::" contains diagnostic info; ensure
the loop still exits on success (exit 0) and preserves the existing retry count
and sleep behavior.

@bigcat88 bigcat88 merged commit 96f2ff9 into main Apr 24, 2026
9 checks passed
@bigcat88 bigcat88 deleted the ci/retry-pypi-install-smoke-test branch April 24, 2026 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant