CI: port cuda-python's PR preview deploy and cleanup #471
/ok to test dc9bd1500a491c9a40e8f472f79a20a2172fe1ee
<!-- coderabbit-ai-generated:v1 -->
<!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- review_stack_entry_start -->
<a href="https://app.coderabbit.ai/change-stack/NVIDIA/numba-cuda-mlir/pull/471?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg" alt="Explain Change →" height="32"></picture></a>
<!-- review_stack_entry_end -->
<!-- This is an auto-generated comment: review paused by coderabbit.ai -->
[!NOTE]
## Reviews paused
> It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.> - Last reviewed commit: db185dd42c65158f5ee60945f55686aeeaabc277
> Use the following commands to manage reviews:
- @coderabbitai resume to resume automatic reviews.- @coderabbitai review to trigger a single review.> Use the checkboxes below for quick actions:
- [ ] <!-- {"checkboxId":"7f6cc2e2-2e4e-497a-8c31-c9e4573e93d1"} --> Resume reviews
- [ ] <!-- {"checkboxId":"e9bb8d72-00e8-4f67-9cb2-caf3b22574fe"} --> Trigger review
<!-- end of auto-generated comment: review paused by coderabbit.ai -->
<!-- recent_review_status_start -->
No actionable comments were generated in the recent review.
<!-- recent_review_status_end -->
<!-- walkthrough_start -->
<details>
<summary><strong>Walkthrough</strong></summary>
<dl>
<dd>
<br>
Important: The documentation workflow now builds and deploys PR previews through a deployment artifact. Cleanup runs share a publishing lock, restrict remote pushes to scheduled or manually dispatched workflow runs, retry rejected pushes, and update comments for closed PR previews.
Changes: Documentation preview publishing and cleanup
|Layer / File(s)|Summary|
|:---|:---|
|Build and deploy PR previews <br> .github/actions/get_pr_number/action.yml, .github/actions/doc_preview/action.yml, .github/workflows/build-docs.yml|The build workflow records deployment metadata and uploads generated documentation as an artifact. A deploy job uses that artifact for previews on pull-request/ refs. The actions extract PR information and limit preview deployment to those refs.|
|Serialize cleanup and update closed-PR comments <br> .github/workflows/cleanup-pr-previews.yml, ci/cleanup-pr-previews|The cleanup workflow shares a concurrency group with publishing and passes its lock value to the script. The script restricts remote pushes, retries rejected pushes, and updates comments for closed PR previews after a successful push.|
Possibly related issues
fetch-depth: 1. The build workflow still uses fetch-depth: 0, so the requested checkout change is only partly present.Suggested labels: github_actions
</dd>
</dl>
</details>
<!-- walkthrough_end -->
<!-- change_assessment_start -->
<!-- change_assessment_commit:"db185dd42c65158f5ee60945f55686aeeaabc277" -->
<!-- change_assessment_priority:{"version":1,"urgency":"p2","manual":false} -->
Change: Bug fix
<!-- change_assessment_end -->
<details>
<summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-unassessed-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minimal</strong> · up to <code>db185</code></summary>
<dl>
<dd>
<br>
<!-- final_review_risk_start -->
<!-- final_review_risk_label
Merge Risk: ⚪ Minimal · up to db185
-->
<!-- final_review_risk_coverage:{"sourceCommitId":"db185dd42c65158f5ee60945f55686aeeaabc277","coveredCommitId":"db185dd42c65158f5ee60945f55686aeeaabc277","kind":"reviewed"} -->
This change moves PR preview deploys and cleanup onto a shared queued lock and restricts remote pushes to the scheduled or manually dispatched cleanup workflow. No merge-blocking risk was identified. A dry run after merge, as planned, would confirm the workflow in practice.
<!-- final_review_risk_end -->
</dd>
</dl>
</details>
<details>
<summary><strong>Security architecture risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-unassessed-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minimal</strong> · up to <code>db185</code></summary>
<dl>
<dd>
<br>
<!-- architecture_review_start -->
<!-- architecture_review_label
Security Architecture Review
Security architecture risk: ⚪ Minimal · up to db185
-->
The inspected changes improve coordination of documentation publishing and constrain cleanup invocations. The added comment permission serves a bounded cleanup operation. No introduced or worsened risk materially affecting security, failure containment, rollback, or ownership was established.
Retained concerns
No architecture-level concerns identified.
<details>
<summary><strong>Security review details</strong></summary>
<dl>
<dd>
<br>
Security Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
</dd>
</dl>
</details>
<!-- architecture_review_end -->
</dd>
</dl>
</details>
<!-- autopilot:start -->
<!-- autopilot:end -->
<!-- recent_review_start -->
<h6>
<details>
<summary><strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="12" height="12" align="absmiddle" alt=""></picture> Recent review info</strong></summary>
<dl>
<dd>
<br>
<!-- review_info_content -->
<details>
<summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</strong></summary>
<dl>
<dd>
<br>
d0f1d1ab-10bf-4ea7-9f22-204e64a19ea4</dd>
</dl>
</details>
<details>
<summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</strong></summary>
<dl>
<dd>
<br>
Reviewing files that changed from the base of the PR and between dc9bd1500a491c9a40e8f472f79a20a2172fe1ee and db185dd42c65158f5ee60945f55686aeeaabc277.
</dd>
</dl>
</details>
<details>
<summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 1</strong></summary>
<dl>
<dd>
<br>
ci/cleanup-pr-previews</dd>
</dl>
</details>
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.
</dd>
</dl>
</details>
</h6>
<!-- recent_review_end -->
<!-- coderabbit-ai-generated:v1 -->
<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/amber-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minor · Performance & Scalability · Quick win
Gate deploy on the publishing refs.
The job-level if checks only needs.build.result. The numba-cuda-mlir-gh-pages-publish group applies to the whole job. A run on a non-publishing ref therefore still takes a queue slot, even though every publish step is skipped. Push triggers in ci.yaml and tag pushes in publish.yaml already run only on publishing refs. A workflow_dispatch run of ci.yaml can select any branch, so it can reach this job from a non-publishing ref. With queue: max and cancel-in-progress: false, that no-op job can delay later publishers and the nightly cleanup.
Add the publishing-ref condition to the job if:
<details>
<summary>Suggested fix</summary>
<dl>
<dd>
<br>
- if: ${{ needs.build.result == 'success' }}
+ if: ${{ needs.build.result == 'success' && (inputs.is-release || github.ref_name == 'main' || startsWith(github.ref_name, 'pull-request/')) }}
</dd>
</dl>
</details>
<!-- suggestion_start -->
<details>
<summary>Committable suggestion</summary>
<dl>
<dd>
<br>
<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg" width="20" height="20" align="absmiddle" alt=""></picture> IMPORTANT
Review the replacement and indentation, then test before committing.
needs: build
if: ${{ needs.build.result == 'success' && (inputs.is-release || github.ref_name == 'main' || startsWith(github.ref_name, 'pull-request/')) }}
</dd>
</dl>
</details>
<!-- suggestion_end -->
<!-- fingerprinting:phantom:medusa:beignet55 -->
<!-- cr-indicator-types:potential_issue -->
<!-- cr-comment:v1:e8172f0701f6727eaa5c9057 -->
<!-- This is an auto-generated reply by CodeRabbit -->
<!-- coderabbit-ai-generated:v1 -->
Actionable comments posted: 1
<details>
<summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/message-square-off-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/message-square-off.svg" width="16" height="16" align="absmiddle" alt=""></picture> Additional comments: 1</summary><blockquote>
<dl>
<dd>
<br>
<details>
<summary>.github/workflows/build-docs.yml-146-148: 1</summary><blockquote>
<dl>
<dd>
<br>
146-148: <picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/neutral-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Trivial · Maintainability & Code Quality · Low value
<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg" width="20" height="20" align="absmiddle" alt=""></picture> Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.
suggestion: Group the three >> "$GITHUB_OUTPUT" redirects into one block.
Problem: the actionlint hint SC2129 flags these lines. The same file already writes GITHUB_ENV with one { ...; } >> "$GITHUB_ENV" block at lines 79-83. Using the same form here keeps the file uniform and clears the lint finding.
Smallest fix: wrap the three echo commands in { ...; } >> "$GITHUB_OUTPUT".
Overall verdict: needs-small-fixes. The one open question is the checkout depth in the cleanup workflow. queue: max is a valid concurrency key on GitHub.com, so the actionlint queue error is a false positive.
<!-- cr-comment:v1:f3ec7e42b91308861f454f77 -->
_Sources: Path instructions, Linters/SAST tools_
</dd>
</dl>
</blockquote></details>
</dd>
</dl>
</blockquote></details>
<h6>
<details>
<summary><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="12" height="12" align="absmiddle" alt=""></picture> Review info</summary>
<dl>
<dd>
<br>
<details>
<summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</summary>
<dl>
<dd>
<br>
ca1e4c0f-7152-4599-8ceb-7c150ec042c3</dd>
</dl>
</details>
<details>
<summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</summary>
<dl>
<dd>
<br>
Reviewing files that changed from the base of the PR and between f77f83017b381a9000357e4b24bd907e7f737c12 and dc9bd1500a491c9a40e8f472f79a20a2172fe1ee.
</dd>
</dl>
</details>
<details>
<summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 5</summary>
<dl>
<dd>
<br>
.github/actions/doc_preview/action.yml
.github/actions/get_pr_number/action.yml
.github/workflows/build-docs.yml
.github/workflows/cleanup-pr-previews.yml
ci/cleanup-pr-previews</dd>
</dl>
</details>
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.
</dd>
</dl>
</details>
</h6>
<!-- This is an auto-generated comment by CodeRabbit for review status -->
<!-- coderabbit-review-publication v1 publication=8e6ded77-3a6d-469b-84ca-c8f886a9859d attempt=5184e253-aca2-43c5-b56e-d55c733f87fd batch=1/1 -->
[P2] Filter preview comments by bot author
The marker-only query followed by tail -n 1 can select a contributor's comment quoting the raw preview message. A mocked reproduction with bot comment 101 followed by contributor comment 202 makes the helper PATCH comment 202, leaving the real preview comment unchanged. Match the expected bot author as well as the marker, consistent with the sticky-comment action's lookup.
replace the jq line with:
--jq '.[] | select(.user.login == "github-actions[bot]" and (.body | contains("<!-- Sticky Pull Request Commentpr-preview -->"))) | .id' \
Keeping this identical to cuda-python's build-docs.yml, which has the same gate. The only cost is a no-op deploy job holding the lock for about a minute when someone manually runs CI on a branch that isn't main or pull-request/*.
-- Leo's bot
Thanks, @jpascucci-nv, would you mind raising a PR to cuda-python too?
Doc Preview CI
:---:
Preview removed because the pull request was closed or merged.
<!-- Sticky Pull Request Commentpr-preview -->
@leofang Submitted https://github.com/NVIDIA/cuda-python/pull/3485
@leofang FYI, that --jq line got corrupted in the copy-paste. It's fine until the contains() section, but use the original string for contains argument and after.
Approved these changes.
Applied in commit db185dd
/ok to test db185dd3
/ok to test db185dd3
@leofang, there was an error processing your request: E2
See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/2/
/ok to test db185dd42c65158f5ee60945f55686aeeaabc277
jpascucci-nv
leofang
The nightly "Cleanup: PR Preview Documentation" workflow has failed every night since late May because it sets no git identity, so 38 of the 53 previews on
gh-pagesbelong to closed PRs. Supersedes #464.This brings the preview deploy and cleanup in line with cuda-python (NVIDIA/cuda-python#2914). The first commit copies
ci/cleanup-pr-previews, the cleanup workflow and thedoc_previewandget_pr_numberactions unchanged from NVIDIA/cuda-python@b80866b3556717c6e702b9a9d11a7fc4ba62097d; the second adapts them to this repo. With that:mainno longer delete the merged PR's preview.build-docs.ymlbuilds and deploys in separate jobs, and the deploy job shares a queued concurrency group with the cleanup, so writes togh-pagesno longer race.gh-pagesmoved, and updates the sticky preview comment of each closed PR.Run locally against this repo, the script finds 38 previews to remove and keeps the 15 of open PRs. After merging, a
workflow_dispatchrun withdry-runchecks the workflow before the next nightly run.The last commit carries NVIDIA/cuda-python#3485, not yet merged there.
-- Leo's bot