Skip to content

Commit

Permalink
build: add action to close stale PRs
Browse files Browse the repository at this point in the history
Add action to close PRs that are over 1 year old and
have had no comments or updates in the last 6 months.

Fixes: nodejs#42981

Signed-off-by: Michael Dawson <mdawson@devrus.com>
  • Loading branch information
mhdawson committed May 17, 2023
1 parent a51491a commit 1281e7a
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/close-stale-pull-requests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Close stale feature requests
on:
workflow_dispatch:
inputs:
endDate:
description: stop procesing PRs after this date
required: false
type: string
schedule:
# Run every day at 1:00 AM UTC.
- cron: 0 1 * * *

# yamllint disable rule:empty-lines
env:
CLOSE_MESSAGE: >
This pull request was opened more than a year ago and there has
been no activity in the last 6 months. We value your contribution
but since it has not progressed in the last 6 months it is being
closed. If you feel closing this issue is not the right thing
to do, please leave a comment.
For more information on how the project manages pull requests,
please consult the
[pull requests](https://github.com/nodejs/node/blob/main/doc/contributing/pull-requests.md#managing-stale-pull-requests).
WARN_MESSAGE: >
This pull request was opened more than a year ago and there has
been no activity in the last 5 months. We value your contribution
but since it has not progressed in the last 5 months it is being
marked stale and will be closed if there is no progress in the
next month. If you feel that is not the right thing to do please
comment on the pull request.
For more information on how the project manages pull requests,
please consult the
[pull requests](https://github.com/nodejs/node/blob/main/doc/contributing/pull-requests.md#managing-stale-pull-requests).
# yamllint enable

permissions:
contents: read

jobs:
stale:
permissions:
pull-requests: write # for actions/stale to close stale PRs
if: github.repository == 'nodejs/node'
runs-on: ubuntu-latest
steps:
- name: Set default end date which is 1 year ago
run: echo "END_DATE=$(date --date='525600 minutes ago' --rfc-2822)" >> "$GITHUB_ENV"
- name: if date set in event override the default end date
env:
END_DATE_INPUT_VALUE: ${{ github.event.inputs.endDate }}
if: "${{ github.event.inputs.endDate != '' }}"
run: echo "END_DATE=$END_DATE_INPUT_VALUE" >> "$GITHUB_ENV"
# - uses: actions/stale@1160a2240286f5da8ec72b1c0816ce2481aabf84 # v8.0.0
- uses: mhdawson/stale@453d6581568dc43dbe345757f24408d7b451c651 # PR to add support for endDate
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
end-date: ${{ env.END_DATE }}
days-before-issue-stale: -1
days-before-issue-close: -1
only-labels: test-stale-pr
days-before-stale: 150
days-before-close: 30
stale-issue-label: stale
close-issue-message: ${{ env.CLOSE_MESSAGE }}
stale-issue-message: ${{ env.WARN_MESSAGE }}
exempt-pr-labels: never-stale
# max requests it will send per run to the GitHub API before it deliberately exits to avoid hitting API rate limits
operations-per-run: 500
remove-stale-when-updated: true
20 changes: 20 additions & 0 deletions doc/contributing/pull-requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* [Accept that there are different opinions about what belongs in Node.js](#accept-that-there-are-different-opinions-about-what-belongs-in-nodejs)
* [Performance is not everything](#performance-is-not-everything)
* [Continuous integration testing](#continuous-integration-testing)
* [Managing stale pull request](#managing-stale-pull-requests)
* [Notes](#notes)
* [Commit squashing](#commit-squashing)
* [Getting approvals for your pull request](#getting-approvals-for-your-pull-request)
Expand Down Expand Up @@ -523,6 +524,25 @@ to fail on specific platforms or for so-called "flaky" tests to fail ("be red").
It is vital to visually inspect the results of all failed ("red") tests to
determine whether the failure was caused by the changes in the pull request.

## Managing stale pull requests

Pull requests are a valuable contribution to the project and the collaborators
work hard to make sure pull requests land as quickly as possible.

Unfortunately not all pull requests land in a timely manner and after an
extended amount of time without active progress the likelyhood of a pull
request landing decreases significantly.

For pull requests that are older than a year and for which there have been
no updates for 5 months, the project uses a stale action to comment on the
pull request and to mark it as stale. If there is no further updates on
the pull request in the next month an additional comment is added and
the pull request is closed.

A simple comment on a pull request can be used to reset a pull request
marked as stale and prevent it from being a candidate for closure for
another 6 months.

## Notes

### Commit squashing
Expand Down

0 comments on commit 1281e7a

Please sign in to comment.