Skip to content

Fix stale workflow: tighten thresholds and fix KBE close logic#54471

Merged
MichaelSimons merged 3 commits into
dotnet:mainfrom
MichaelSimons:main
May 27, 2026
Merged

Fix stale workflow: tighten thresholds and fix KBE close logic#54471
MichaelSimons merged 3 commits into
dotnet:mainfrom
MichaelSimons:main

Conversation

@MichaelSimons

@MichaelSimons MichaelSimons commented May 27, 2026

Copy link
Copy Markdown
Member

Summary

This PR contains two fixes for the stale issue workflow:

  1. Tighten stale thresholds — Reduces issue staleness from ~4.5 years to ~4 years, and PR staleness from ~4 months to ~2 months.

  2. Fix Known Build Error (KBE) issues never closing — The previous implementation had a conflict between its two steps:

    • Step 1 added the stale label and a comment
    • Step 2 (actions/stale) treated that comment as "new activity", removing the stale label
    • This created an infinite loop: daily re-labeling + comment, issue never closed

    The fix replaces Step 2 with direct close logic in the github-script that checks when the stale label was applied via issue timeline events and closes after 7 days. This eliminates the dependency on actions/stale for KBE closure entirely.

Validation

Tested on a fork with 4 scenarios:

  • ✅ Non-KBE issues are not modified
  • ✅ Active KBE issues (with hits) stay open without stale label
  • ✅ KBE issues with 0 monthly hits get marked stale (label + comment) but are NOT immediately closed
  • ✅ KBE issues that have been stale for the configured duration are closed

Related to #54043, and #54044

The stale-known-build-errors job had a conflict between its two steps:
- Step 1 added the 'stale' label and a comment
- Step 2 (actions/stale) treated that comment as new activity, removing
  the stale label — creating an infinite loop of daily re-labeling

Fix: Replace Step 2 with direct close logic in the github-script that
checks when the stale label was applied via issue events and closes
after 7 days. Also tighten stale thresholds (issues: 4y, PRs: 2mo).

Fixes: dotnet#39172

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 27, 2026 19:13
@MichaelSimons MichaelSimons requested a review from lbussell May 27, 2026 19:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates the repo’s stale automation to reduce the time before issues/PRs are marked stale, and fixes the Known Build Error (KBE) stale workflow so KBEs can actually be closed after remaining stale for a configured period (without the “comment activity removes stale label” loop).

Changes:

  • Tighten global stale thresholds (issues ~4y, PRs ~2mo).
  • Replace actions/stale-based KBE closing with github-script logic that closes KBEs after the stale label has been present for 7 days while monthly hits remain 0.

Comment thread .github/workflows/stale.yml Outdated
Fetch a single page (100 events) instead of paginating the entire
issue event history. The stale label was applied by this workflow
recently so it will always be in the last 100 events.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread .github/workflows/stale.yml
Comment thread .github/workflows/stale.yml Outdated
- uses: actions/github-script@v7
with:
script: |
const CLOSE_AFTER_DAYS = 7;

@lbussell lbussell May 27, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

suggestion: Rename this to CLOSE_KBE_AFTER_DAYS and move it to the top of the file under the env: declaration. It seems like that's where most configuration lives for this workflow.

@MichaelSimons MichaelSimons May 27, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I renamed the const as suggested but left it in that location with a9f7aa9. The envs at the top are items that are shared across the jobs. The specific constants for the normal stale and KBE stale jobs are defined within each job.

Rename constant to CLOSE_KBE_AFTER_DAYS, use it in the notification
message, and add whitespace between logical blocks.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@MichaelSimons MichaelSimons requested a review from lbussell May 27, 2026 20:04
@MichaelSimons

Copy link
Copy Markdown
Member Author

Merging ahead of validation since it doesn't cover the GH action.

@MichaelSimons MichaelSimons merged commit de9d552 into dotnet:main May 27, 2026
9 of 26 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview6 milestone May 28, 2026
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.

3 participants