Skip to content

ci: add pr release cleanup job#1090

Merged
alandtse merged 4 commits into
community-shaders:devfrom
alandtse:prerelease_cleanup
May 27, 2025
Merged

ci: add pr release cleanup job#1090
alandtse merged 4 commits into
community-shaders:devfrom
alandtse:prerelease_cleanup

Conversation

@alandtse
Copy link
Copy Markdown
Collaborator

@alandtse alandtse commented May 24, 2025

Summary by CodeRabbit

  • Chores
    • Introduced an automated workflow to regularly clean up prereleases associated with closed pull requests, helping to keep the repository organized.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 24, 2025

Walkthrough

A new GitHub Actions workflow has been added to automate the cleanup of prereleases associated with closed pull requests. The workflow identifies prerelease tags following a specific pattern, checks the status of related pull requests, and deletes prereleases and tags if the pull requests are no longer open.

Changes

File(s) Change Summary
.github/workflows/cleanup-pr-releases.yaml Added a workflow to identify and delete prereleases and tags linked to closed pull requests.

Sequence Diagram(s)

sequenceDiagram
    participant GitHub Actions
    participant GitHub CLI
    participant Repository

    GitHub Actions->>GitHub CLI: List up to 1000 prereleases
    loop For each prerelease tag matching vX.Y.Z-prN
        GitHub Actions->>GitHub CLI: Query PR N state
        alt PR is not open
            GitHub Actions->>GitHub CLI: Delete prerelease
            GitHub Actions->>Repository: Delete associated git tag
        else PR is open
            GitHub Actions-->>GitHub Actions: Skip deletion
        end
    end
Loading

Poem

A bunny with a sweeping broom,
Hops nightly through the PR room.
Old prereleases, tags in tow,
Are whisked away when PRs close.
Now the garden’s neat and spry—
Thanks to cleanup hops gone by! 🧹🐇

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@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: 1

🧹 Nitpick comments (4)
.github/workflows/cleanup-pr-releases.yaml (4)

13-16: Prevent overlapping runs with concurrency settings.

Without a concurrency group, scheduled and manual runs could overlap. Consider adding:

 jobs:
   cleanup-prereleases:
+    concurrency:
+      group: cleanup-prereleases
+      cancel-in-progress: true
     runs-on: ubuntu-latest

This ensures only one cleanup job runs at a time.


20-23: Fail fast on script errors.

By default, errors in the script may be ignored. Add set -euo pipefail to exit immediately on failures and undefined vars:

 run: |
+  set -euo pipefail
   echo "Fetching all prereleases..."
   releases=$(gh release list --limit 1000 --json tagName,isPrerelease \
     --jq '.[] | select(.isPrerelease) | .tagName')

24-28: Handle tags with spaces safely.

Iterating over $releases can break on whitespace. Use a while read loop:

- for tag in $releases; do
+ while IFS= read -r tag; do
     if [[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+-pr([0-9]+)$ ]]; then
       pr_number="${BASH_REMATCH[1]}"
       echo "Checking PR #$pr_number for tag $tag"
     …
- done
+ done <<< "$releases"

This approach preserves each tag string intact.


41-41: Add trailing newline for YAML lint.

The file is missing a newline at EOF, which YAMLlint flags. Please add a blank line at the end.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 41-41: no new line character at the end of file

(new-line-at-end-of-file)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f9dcd69 and 30c5f86.

📒 Files selected for processing (1)
  • .github/workflows/cleanup-pr-releases.yaml (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/cleanup-pr-releases.yaml

[error] 41-41: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (3)
.github/workflows/cleanup-pr-releases.yaml (3)

3-8: Event triggers are correctly configured.

The workflow listens to manual dispatch, a daily cron schedule, and PR closed events via pull_request_target. This covers both scheduled cleanups and immediate cleanup when PRs close.


10-12: Minimal scoped permissions are correctly set.

Granting contents: write is sufficient for deleting releases and tags without over-privileging the workflow.


25-27: PR tag regex is precise for semver-prN patterns.

The regex ^v[0-9]+\.[0-9]+\.[0-9]+-pr([0-9]+)$ cleanly captures the PR number and avoids false positives.

Comment thread .github/workflows/cleanup-pr-releases.yaml Outdated
Copy link
Copy Markdown
Contributor

@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: 0

🧹 Nitpick comments (5)
.github/workflows/cleanup-pr-releases.yaml (5)

18-22: Consider upgrading the checkout action and fetching tags

  • actions/checkout@v3 works, but v4 is available with fixes and performance improvements.
  • To make git tag -d effective, set fetch-depth: 0 and fetch-tags: true under with: so that tags are actually present locally.
🧰 Tools
🪛 actionlint (1.7.7)

19-19: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


23-26: Simplify token injection for GH CLI
The GitHub CLI will auto-pick up GITHUB_TOKEN, so you can rely on that instead of explicitly mapping GH_TOKEN. This reduces duplication and aligns with common examples.


27-29: Use native prerelease filter
Instead of piping JSON through jq, leverage the built-in flag:

gh release list --prerelease --limit 1000 --json tagName

This simplifies the command and avoids extra filtering.


35-36: Handle merged vs closed PRs explicitly if needed
GitHub’s state field returns OPEN or CLOSED (merged PRs are marked closed). If you ever need to distinguish merges, consider querying .merged in addition to .state.


48-48: Add trailing newline
YAML linters expect a newline at EOF. Please add a blank line after line 48 to satisfy new-line-at-end-of-file.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 48-48: no new line character at the end of file

(new-line-at-end-of-file)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 30c5f86 and ca444d7.

📒 Files selected for processing (1)
  • .github/workflows/cleanup-pr-releases.yaml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/cleanup-pr-releases.yaml

19-19: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 YAMLlint (1.37.1)
.github/workflows/cleanup-pr-releases.yaml

[error] 48-48: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (5)
.github/workflows/cleanup-pr-releases.yaml (5)

3-9: Appropriate event triggers with safe checkout
Using pull_request_target alongside workflow_dispatch and a daily cron ensures closed‐PR cleanup runs on trusted code (you explicitly checkout the default branch). This setup aligns well with security best practices.


10-13: Verify token scope covers release deletion
You’ve scoped contents: write and pull-requests: read. Please confirm that contents: write is sufficient for gh release delete and git-tag removal. If deletion fails due to insufficient permissions, consider granting a dedicated releases: write or full repo permission.


30-34: Correct regex for PR-linked tags
Your pattern ^v[0-9]+\.[0-9]+\.[0-9]+-pr([0-9]+)$ cleanly matches semver prerelease tags (v1.2.3-pr45). Ensure all generated prereleases conform to this naming convention.


38-41: Robust release and tag deletion with fallback
Good use of --cleanup-tag with a fallback git push --delete origin. This covers GH CLI versions <2.3.0. You may drop the local git tag -d step if you don’t fetch tags, or adjust checkout to include tags (see earlier comment).


45-47: Clear logging for skipped tags
Skipping non-PR tags with an explanatory log makes the workflow’s decisions transparent. Nice touch.

@jiayev jiayev self-requested a review May 27, 2025 03:53
@alandtse alandtse merged commit 4d417dd into community-shaders:dev May 27, 2025
6 checks passed
alandtse added a commit to alandtse/open-shaders that referenced this pull request Jul 20, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Jul 28, 2025
@alandtse alandtse deleted the prerelease_cleanup branch December 24, 2025 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants