Skip to content

fix: delete stale sticky comment when local tests pass on re-run#44

Merged
Soul-Craft merged 1 commit into
mainfrom
claude/frosty-sammet
Apr 16, 2026
Merged

fix: delete stale sticky comment when local tests pass on re-run#44
Soul-Craft merged 1 commit into
mainfrom
claude/frosty-sammet

Conversation

@Soul-Craft

Copy link
Copy Markdown
Owner

Summary

  • When ci-verify-local transitions from failure → success on a re-run, the "## Local tests" sticky comment posted by the failure run was never cleaned up — it stayed on the PR indefinitely.
  • Added a new Clean up stale sticky comment on success step that runs only on the success path, queries for any existing comment starting with "## Local tests", and deletes it via DELETE /repos/{owner}/{repo}/issues/comments/{id}.
  • No permission changes needed — pull-requests: write was already declared for the failure path's POST/PATCH.

What changed

.github/workflows/ci-verify-local.yml — added a step between "Pass if evidence found" and "Post sticky comment if missing or failed":

- name: Clean up stale sticky comment on success
  if: steps.check.outputs.status == 'success'
  env:
    GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    PR_NUMBER: ${{ github.event.pull_request.number }}
    REPO: ${{ github.repository }}
  run: |
    set -euo pipefail
    existing=$(gh api "repos/$REPO/issues/$PR_NUMBER/comments" --paginate \
      --jq '.[] | select(.body | startswith("## Local tests")) | .id' | head -1)
    if [ -n "$existing" ]; then
      gh api "repos/$REPO/issues/comments/$existing" --method DELETE
      echo "Deleted stale sticky comment $existing"
    fi

The startsWith("## Local tests") predicate matches both the "not yet uploaded" and "failed" comment variants — the same predicate used by the failure path's update logic.

Reviewer notes

  • head -1 guards against the edge case where two matching comments exist (e.g. from concurrent runs).
  • All ${{ }} interpolations go through env: variables — consistent with the existing security posture documented at the top of the file.
  • The step is a no-op when no sticky comment exists (silent if [ -n "$existing" ] guard).

Test plan

  • Open a PR, trigger a failure run (missing or failed local tests) — confirm sticky comment is posted
  • Upload passing results, push a new commit — confirm next workflow run deletes the comment
  • Confirm no comment is posted/touched when success runs with no prior sticky comment

🤖 Generated with Claude Code

When ci-verify-local transitions from failure → success, the "## Local
tests" sticky comment posted by the failure run was never cleaned up.
Add a success-path step that looks for an existing comment (by the same
startsWith predicate used by the failure path) and DELETEs it via the
GitHub API. No new permissions needed — pull-requests: write was already
present.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Soul-Craft Soul-Craft merged commit 8ada922 into main Apr 16, 2026
6 of 7 checks passed
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.

1 participant