Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bot to manage stale PRs #5300

Merged
merged 9 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: 'Stale PR Bot'
on:
schedule:
- cron: '0 4 * * *'

permissions:
pull-requests: write

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9.1.0
with:
days-before-issue-stale: -1 # disabled for issues

days-before-pr-stale: 90 # 3 months
days-before-pr-close: 14 # 2 weeks
stale-pr-label: "stale"
exempt-pr-labels: "keep-open"
exempt-draft-pr: true
stale-pr-message: |
This pull request has been marked as stale due to 60 days of inactivity.
If this is still relevant, please update or comment to keep it open.
If this should be kept open indefinitely, please apply the label `keep-open`.
Otherwise, it will be automatically closed after 14 days.
33 changes: 29 additions & 4 deletions scripts/verify-ci-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,31 @@ checkPlugins(path.join(__dirname, '..', '.github', 'workflows', 'appsec.yml'))
/// / Verifying that tests run on correct triggers
/// /

const IGNORED_WORKFLOWS = {
all: [
'prepare-release-proposal.yml',
'rebase-release-proposal.yml',
'release-3.yml',
'release-4.yml',
'release-dev.yml',
'release-latest.yml',
'release-proposal.yml',
'codeql-analysis.yml',
'pr-labels.yml'
],
trigger_pull_request: [
'stale.yml'
],
trigger_push: [
'package-size.yml',
'stale.yml'
],
trigger_schedule: []
}

const workflows = fs.readdirSync(path.join(__dirname, '..', '.github', 'workflows'))
.filter(file =>
!['release', 'codeql', 'pr-labels']
!IGNORED_WORKFLOWS.all
.reduce((contained, name) => contained || file.includes(name), false)
)

Expand All @@ -173,13 +195,16 @@ for (const workflow of workflows) {
const yamlPath = path.join(__dirname, '..', '.github', 'workflows', workflow)
const yamlContent = yaml.parse(fs.readFileSync(yamlPath, 'utf8'))
const triggers = yamlContent.on
if (triggers?.pull_request !== null) {
if (!IGNORED_WORKFLOWS.trigger_pull_request.includes(workflow) &&
triggers?.pull_request !== null) {
triggersError(workflow, 'The `pull_request` trigger should be blank')
}
if (workflow !== 'package-size.yml' && triggers?.push?.branches?.[0] !== 'master') {
if (!IGNORED_WORKFLOWS.trigger_push.includes(workflow) &&
triggers?.push?.branches?.[0] !== 'master') {
triggersError(workflow, 'The `push` trigger should run on master')
}
if (triggers?.schedule?.[0]?.cron !== '0 4 * * *') {
if (!IGNORED_WORKFLOWS.trigger_schedule.includes(workflow) &&
triggers?.schedule?.[0]?.cron !== '0 4 * * *') {
triggersError(workflow, 'The `cron` trigger should be \'0 4 * * *\'')
}
}
Loading