mirror of
https://github.com/actions/stale.git
synced 2025-12-23 17:08:18 +00:00
Compare commits
81 Commits
test-dash-
...
v5.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3cc1237663 | ||
|
|
76e9fbc6ae | ||
|
|
6467b96231 | ||
|
|
8af60513da | ||
|
|
7a7efcae1f | ||
|
|
04a1828bc1 | ||
|
|
65ca3956bd | ||
|
|
eee276c280 | ||
|
|
6c2f9f3f54 | ||
|
|
37323f14dd | ||
|
|
3be940e59b | ||
|
|
7d0e5bedbf | ||
|
|
77bfb89501 | ||
|
|
7fb802b307 | ||
|
|
54197c7137 | ||
|
|
3a971aeb80 | ||
|
|
fc4a5ff942 | ||
|
|
db699ab3b1 | ||
|
|
f8e08de81b | ||
|
|
b83d488cb9 | ||
|
|
1ff6cd74cb | ||
|
|
86fed0e1f1 | ||
|
|
67004407a6 | ||
|
|
b9a40762bf | ||
|
|
bab816b473 | ||
|
|
6299c36a0d | ||
|
|
a8c5bb1c29 | ||
|
|
1c81c38e2f | ||
|
|
f6a70aa856 | ||
|
|
315391885d | ||
|
|
4665995b65 | ||
|
|
b80ae639fa | ||
|
|
3021a55a47 | ||
|
|
b98591d49e | ||
|
|
9912fa74d1 | ||
|
|
303465a5d2 | ||
|
|
dee9af8160 | ||
|
|
31d06d7a0a | ||
|
|
fcb25faea2 | ||
|
|
9dee5c72d9 | ||
|
|
0aa6030913 | ||
|
|
5aa0d3ef84 | ||
|
|
1cdda06bb3 | ||
|
|
002bc97450 | ||
|
|
2e221262b1 | ||
|
|
27d80e173f | ||
|
|
86507610fb | ||
|
|
ceeedec52e | ||
|
|
0156089d02 | ||
|
|
cdf15f641a | ||
|
|
a78d0b721e | ||
|
|
d901397e11 | ||
|
|
678bfc7a59 | ||
|
|
d3bfc50685 | ||
|
|
4b47cddc05 | ||
|
|
f2ae27a59b | ||
|
|
4d1e45b796 | ||
|
|
92d4fc69d8 | ||
|
|
1efddcbe9f | ||
|
|
f1017f33dd | ||
|
|
b1da9e1fb1 | ||
|
|
52f5648db3 | ||
|
|
5f6f311ca6 | ||
|
|
8deaf75055 | ||
|
|
50571d3fa3 | ||
|
|
77a1abc9e8 | ||
|
|
965862c5a6 | ||
|
|
8e70fa8dee | ||
|
|
9a928a1355 | ||
|
|
39b3616748 | ||
|
|
4310353e56 | ||
|
|
1e82956100 | ||
|
|
2347805002 | ||
|
|
3e6d35b685 | ||
|
|
1648064648 | ||
|
|
c2acfb4dd3 | ||
|
|
5fbbfba142 | ||
|
|
e884599072 | ||
|
|
6ec637d238 | ||
|
|
16dfaa2c02 | ||
|
|
4586dc972d |
@@ -28,7 +28,7 @@
|
||||
"@typescript-eslint/no-array-constructor": "error",
|
||||
"@typescript-eslint/no-empty-interface": "error",
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/no-extraneous-class": "error",
|
||||
"@typescript-eslint/no-extraneous-class": "off",
|
||||
"@typescript-eslint/no-for-in-array": "error",
|
||||
"@typescript-eslint/no-inferrable-types": "error",
|
||||
"@typescript-eslint/no-misused-new": "error",
|
||||
|
||||
11
.github/ISSUE_TEMPLATE/feature-request.md
vendored
Normal file
11
.github/ISSUE_TEMPLATE/feature-request.md
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Propose a new feature or an enhancement
|
||||
title: ''
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
## The problem
|
||||
|
||||
## The solution
|
||||
3
.github/ISSUE_TEMPLATE/stale_issue_report.md
vendored
3
.github/ISSUE_TEMPLATE/stale_issue_report.md
vendored
@@ -20,8 +20,7 @@ jobs:
|
||||
runs-on: ...
|
||||
steps:
|
||||
- uses: actions/stale@...
|
||||
with:
|
||||
...
|
||||
with: ...
|
||||
```
|
||||
|
||||
## Further context
|
||||
|
||||
2
.github/pull_request_template.md
vendored
2
.github/pull_request_template.md
vendored
@@ -1,5 +1,7 @@
|
||||
<!-- List the change(s) you're making with this PR. -->
|
||||
|
||||
## Changes
|
||||
|
||||
- [x] ...
|
||||
|
||||
## Context
|
||||
|
||||
53
.github/workflows/check-dist.yml
vendored
Normal file
53
.github/workflows/check-dist.yml
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
# `dist/index.js` is a special file in Actions.
|
||||
# When you reference an action with `uses:` in a workflow,
|
||||
# `index.js` is the code that will run.
|
||||
# For our project, we generate this file through a build process from other source files.
|
||||
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
|
||||
name: Check dist/
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
check-dist:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set Node.js 16.x
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 16.x
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Rebuild the dist/ directory
|
||||
run: |
|
||||
npm run build
|
||||
npm run pack
|
||||
|
||||
- name: Compare the expected and actual dist/ directories
|
||||
run: |
|
||||
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
|
||||
echo "Detected uncommitted changes after build. See status below:"
|
||||
git diff
|
||||
exit 1
|
||||
fi
|
||||
id: diff
|
||||
|
||||
# If index.js was different than expected, upload the expected version as an artifact
|
||||
- uses: actions/upload-artifact@v2
|
||||
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
|
||||
with:
|
||||
name: dist
|
||||
path: dist/
|
||||
3
.github/workflows/stale.yml
vendored
3
.github/workflows/stale.yml
vendored
@@ -9,8 +9,11 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@main
|
||||
id: stale
|
||||
with:
|
||||
stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days'
|
||||
days-before-stale: 30
|
||||
days-before-close: 5
|
||||
exempt-issue-labels: 'blocked,must,should,keep'
|
||||
- name: Print outputs
|
||||
run: echo ${{ join(steps.stale.outputs.*, ',') }}
|
||||
|
||||
5
.github/workflows/test.yml
vendored
5
.github/workflows/test.yml
vendored
@@ -13,13 +13,16 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- run: |
|
||||
npm ci
|
||||
npm run all
|
||||
npm run all:ci
|
||||
test: # make sure the action works on a clean machine without building
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: ./
|
||||
id: stale
|
||||
with:
|
||||
stale-issue-message: 'This issue is stale'
|
||||
stale-pr-message: 'This PR is stale'
|
||||
debug-only: true
|
||||
- name: Print outputs
|
||||
run: echo ${{ join(steps.stale.outputs.*, ',') }}
|
||||
|
||||
3
.versionrc.json
Normal file
3
.versionrc.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"header": "### Actions Stale Changelog\n"
|
||||
}
|
||||
28
CHANGELOG.md
Normal file
28
CHANGELOG.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# Changelog
|
||||
|
||||
## [4.1.0](https://github.com/actions/stale/compare/v3.0.19...v4.1.0) (2021-07-14)
|
||||
|
||||
## Features
|
||||
|
||||
- [Ability to exempt draft PRs](https://github.com/actions/stale/commit/9912fa74d1c01b5d6187793d97441019cbe325d0
|
||||
)
|
||||
|
||||
## [4.0.0](https://github.com/actions/stale/compare/v3.0.19...v4.0.0) (2021-07-14)
|
||||
|
||||
### Features
|
||||
|
||||
- **options:** simplify config by removing skip stale message options ([#457](https://github.com/actions/stale/issues/457)) ([6ec637d](https://github.com/actions/stale/commit/6ec637d238067ab8cc96c9289dcdac280bbd3f4a)), closes [#405](https://github.com/actions/stale/issues/405) [#455](https://github.com/actions/stale/issues/455)
|
||||
- **output:** print output parameters ([#458](https://github.com/actions/stale/issues/458)) ([3e6d35b](https://github.com/actions/stale/commit/3e6d35b685f0b2fa1a69be893fa07d3d85e05ee0))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **dry-run:** forbid mutations in dry-run ([#500](https://github.com/actions/stale/issues/500)) ([f1017f3](https://github.com/actions/stale/commit/f1017f33dd159ea51366375120c3e6981d7c3097)), closes [#499](https://github.com/actions/stale/issues/499)
|
||||
- **logs:** coloured logs ([#465](https://github.com/actions/stale/issues/465)) ([5fbbfba](https://github.com/actions/stale/commit/5fbbfba142860ea6512549e96e36e3540c314132))
|
||||
- **operations:** fail fast the current batch to respect the operations limit ([#474](https://github.com/actions/stale/issues/474)) ([5f6f311](https://github.com/actions/stale/commit/5f6f311ca6aa75babadfc7bac6edf5d85fa3f35d)), closes [#466](https://github.com/actions/stale/issues/466)
|
||||
- **label comparison**: make label comparison case insensitive [#517](https://github.com/actions/stale/pull/517), closes [#516](https://github.com/actions/stale/pull/516)
|
||||
- **filtering comments by actor could have strange behavior**: "stale" comments are now detected based on if the message is the stale message not _who_ made the comment([#519](https://github.com/actions/stale/pull/519)), fixes [#441](https://github.com/actions/stale/pull/441), [#509](https://github.com/actions/stale/pull/509), [#518](https://github.com/actions/stale/pull/518)
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- The options `skip-stale-issue-message` and `skip-stale-pr-message` were removed. Instead, setting the options `stale-issue-message` and `stale-pr-message` will be enough to let the stale workflow add a comment. If the options are unset, a comment will not be added which was the equivalent of setting `skip-stale-issue-message` to `true`.
|
||||
- The `operations-per-run` option will be more effective. After migrating, you could face a failed-fast process workflow if you let the default value (30) or set it to a small number. In that case, you will see a warning at the end of the logs (if enabled) indicating that the workflow was stopped sooner to avoid consuming too much API calls. In most cases, you can just increase this limit to make sure to process everything in a single run.
|
||||
@@ -1,4 +1,4 @@
|
||||
### Building and testing
|
||||
# Building and testing
|
||||
|
||||
Install the dependencies.
|
||||
|
||||
@@ -21,25 +21,47 @@ $ npm test
|
||||
Run the tests and display only the first failing tests :heavy_check_mark:
|
||||
|
||||
```bash
|
||||
$ npm test:only-errors
|
||||
$ npm run test:only-errors
|
||||
```
|
||||
|
||||
Run the tests with the watch mode :heavy_check_mark:
|
||||
|
||||
```bash
|
||||
$ npm test:watch
|
||||
$ npm run test:watch
|
||||
```
|
||||
|
||||
Run the linter and fix (almost) every issue for you :heavy_check_mark:
|
||||
|
||||
```bash
|
||||
$ npm lint:all:fix
|
||||
$ npm run lint:all:fix
|
||||
```
|
||||
|
||||
### Before creating a PR
|
||||
# Before creating a PR
|
||||
|
||||
## Build and quality checks
|
||||
|
||||
Build, lint, package and test everything.
|
||||
|
||||
```bash
|
||||
$ npm all
|
||||
$ npm run all
|
||||
```
|
||||
|
||||
# Release
|
||||
|
||||
Based on [standard-version](https://github.com/conventional-changelog/standard-version).
|
||||
|
||||
## Define the new version
|
||||
|
||||
You can run `npm run release:dry-run` to create a dry-run, or you can directly run `npm run release` to create a new local release.
|
||||
It will run `prerelease` beforehand to build and pack everything.
|
||||
|
||||
If the `prerelease` succeeded, a bump of version will happen based on the unreleased commits.
|
||||
It will:
|
||||
|
||||
- Update the _package.json_ version field
|
||||
- Update the _package-lock.json_ version field
|
||||
- Update the _CHANGELOG.md_ to include the release notes of the new version
|
||||
- Create a local tag
|
||||
- Create a commit
|
||||
|
||||
If everything generated seems ok for you, you can push your tag by running `git push --follow-tags origin {your-branch-name}`.
|
||||
|
||||
569
README.md
569
README.md
@@ -2,71 +2,309 @@
|
||||
|
||||
Warns and then closes issues and PRs that have had no activity for a specified amount of time.
|
||||
|
||||
The configuration must be on the default branch and the default values will:
|
||||
|
||||
- Add a label "Stale" on issues and pull requests after 60 days of inactivity and comment on them
|
||||
- Close the stale issues and pull requests after 7 days of inactivity
|
||||
- If an update/comment occur on stale issues or pull requests, the stale label will be removed and the timer will restart
|
||||
|
||||
## Recommended permissions
|
||||
|
||||
For the execution of this action, it must be able to fetch all issues and pull requests from your repository.
|
||||
In addition, based on the provided configuration, the action could require more permission(s) (e.g.: add label, remove label, comment, close, etc.).
|
||||
This can be achieved with the following [configuration in the action](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#permissions) if the permissions are restricted:
|
||||
|
||||
```yaml
|
||||
permissions:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
```
|
||||
|
||||
You can find more information about the required permissions under the corresponding options that you wish to use.
|
||||
|
||||
## All options
|
||||
|
||||
### List of options
|
||||
### List of input options
|
||||
|
||||
Every argument is optional.
|
||||
|
||||
| Input | Description |
|
||||
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `repo-token` | PAT (Personal Access Token) for authorizing the repository.<br>_Defaults to **${{ github.token }}**_. |
|
||||
| `days-before-stale` | Idle number of days before marking an issue/PR as stale.<br>_Defaults to **60**_. |
|
||||
| `days-before-issue-stale` | Idle number of days before marking an issue as stale.<br>_Override `days-before-stale`_. |
|
||||
| `days-before-pr-stale` | Idle number of days before marking a PR as stale.<br>_Override `days-before-stale`_. |
|
||||
| `days-before-close` | Idle number of days before closing a stale issue/PR.<br>_Defaults to **7**_. |
|
||||
| `days-before-issue-close` | Idle number of days before closing a stale issue.<br>_Override `days-before-close`_. |
|
||||
| `days-before-pr-close` | Idle number of days before closing a stale PR.<br>_Override `days-before-close`_. |
|
||||
| `stale-issue-message` | Message to post on the stale issue. |
|
||||
| `stale-pr-message` | Message to post on the stale PR. |
|
||||
| `close-issue-message` | Message to post on the stale issue while closing it. |
|
||||
| `close-pr-message` | Message to post on the stale PR while closing it. |
|
||||
| `stale-issue-label` | Label to apply on the stale issue.<br>_Defaults to **Stale**_. |
|
||||
| `close-issue-label` | Label to apply on closing issue.<br>Automatically removed if no longer closed nor locked). |
|
||||
| `stale-pr-label` | Label to apply on the stale PR.<br>_Defaults to **Stale**_. |
|
||||
| `close-pr-label` | Label to apply on the closing PR.<br>Automatically removed if no longer closed nor locked). |
|
||||
| `exempt-issue-labels` | Labels on an issue exempted from being marked as stale. |
|
||||
| `exempt-pr-labels` | Labels on the PR exempted from being marked as stale. |
|
||||
| `only-labels` | Only issues and PRs with ALL these labels are checked.<br>Separate multiple labels with commas (eg. "question,answered"). |
|
||||
| `only-issue-labels` | Only issues with ALL these labels are checked.<br>Separate multiple labels with commas (eg. "question,answered").<br>_Override `only-labels`_. |
|
||||
| `only-pr-labels` | Only PRs with ALL these labels are checked.<br>Separate multiple labels with commas (eg. "question,answered").<br>_Override `only-labels`_. |
|
||||
| `any-of-labels` | Only issues and PRs with ANY of these labels are checked.<br>Separate multiple labels with commas (eg. "incomplete,waiting-feedback"). |
|
||||
| `any-of-issue-labels` | Only issues with ANY of these labels are checked.<br>Separate multiple labels with commas (eg. "incomplete,waiting-feedback").<br>_Override `any-of-labels`_. |
|
||||
| `any-of-pr-labels` | Only PRs with ANY of these labels are checked.<br>Separate multiple labels with commas (eg. "incomplete,waiting-feedback").<br>_Override `any-of-labels`_. |
|
||||
| `operations-per-run` | Maximum number of operations per run.<br>GitHub API CRUD related.<br>_Defaults to **30**_. |
|
||||
| `remove-stale-when-updated` | Remove stale label from issue/PR on updates or comments.<br>_Defaults to **true**_. |
|
||||
| `remove-issue-stale-when-updated` | Remove stale label from issue on updates or comments.<br>_Defaults to **true**_.<br>_Override `remove-stale-when-updated`_. |
|
||||
| `remove-pr-stale-when-updated` | Remove stale label from PR on updates or comments.<br>_Defaults to **true**_.<br>_Override `remove-stale-when-updated`_. |
|
||||
| `remove-issue-stale-when-updated` | Remove stale label from issue on updates or comments.<br>_Defaults to **true**_.<br>_Override `remove-stale-when-updated`_. |
|
||||
| `remove-pr-stale-when-updated` | Remove stale label from PR on updates or comments.<br>_Defaults to **true**_.<br>_Override `remove-stale-when-updated`_. |
|
||||
| `debug-only` | Dry-run on action.<br>_Defaults to **false**_. |
|
||||
| `ascending` | Order to get issues/PR.<br>`true` is ascending, `false` is descending.<br>_Defaults to **false**_. |
|
||||
| `skip-stale-issue-message` | Skip adding stale message on stale issue.<br>_Defaults to **false**_. |
|
||||
| `skip-stale-pr-message` | Skip adding stale message on stale PR.<br>_Defaults to **false**_. |
|
||||
| `start-date` | The date used to skip the stale action on issue/PR created before it.<br>ISO 8601 or RFC 2822. |
|
||||
| `delete-branch` | Delete the git branch after closing a stale pull request.<br>_Defaults to **false**_. |
|
||||
| `exempt-milestones` | Milestones on an issue or a PR exempted from being marked as stale. |
|
||||
| `exempt-issue-milestones` | Milestones on an issue exempted from being marked as stale.<br>_Override `exempt-milestones`_. |
|
||||
| `exempt-pr-milestones` | Milestones on the PR exempted from being marked as stale.<br>_Override `exempt-milestones`_. |
|
||||
| `exempt-all-milestones` | Exempt all issues and PRs with milestones from being marked as stale.<br>_Priority over `exempt-milestones` rules_. |
|
||||
| `exempt-all-issue-milestones` | Exempt all issues with milestones from being marked as stale.<br>_Override `exempt-all-milestones`_. |
|
||||
| `exempt-all-pr-milestones` | Exempt all PRs with milestones from being marked as stale.<br>_Override `exempt-all-milestones`_. |
|
||||
| `exempt-assignees` | Assignees on an issue or a PR exempted from being marked as stale. |
|
||||
| `exempt-issue-assignees` | Assignees on an issue exempted from being marked as stale.<br>_Override `exempt-assignees`_. |
|
||||
| `exempt-pr-assignees` | Assignees on the PR exempted from being marked as stale.<br>_Override `exempt-assignees`_. |
|
||||
| `exempt-all-assignees` | Exempt all issues and PRs with assignees from being marked as stale.<br>_Priority over `exempt-assignees` rules_. |
|
||||
| `exempt-all-issue-assignees` | Exempt all issues with assignees from being marked as stale.<br>_Override `exempt-all-assignees`_. |
|
||||
| `exempt-all-pr-assignees` | Exempt all PRs with assignees from being marked as stale.<br>_Override `exempt-all-assignees`_. |
|
||||
| `enable-statistics` | Display some statistics at the end of the logs regarding the stale workflow.<br>Only when the logs are enabled.<br>_Defaults to **true**_. |
|
||||
| Input | Description | Default |
|
||||
| ------------------------------------------------------------------- | --------------------------------------------------------------------------- | --------------------- |
|
||||
| [repo-token](#repo-token) | PAT for GitHub API authentication | `${{ github.token }}` |
|
||||
| [days-before-stale](#days-before-stale) | Idle number of days before marking issues/PRs stale | `60` |
|
||||
| [days-before-issue-stale](#days-before-issue-stale) | Override [days-before-stale](#days-before-stale) for issues only | |
|
||||
| [days-before-pr-stale](#days-before-pr-stale) | Override [days-before-stale](#days-before-stale) for PRs only | |
|
||||
| [days-before-close](#days-before-close) | Idle number of days before closing stale issues/PRs | `7` |
|
||||
| [days-before-issue-close](#days-before-issue-close) | Override [days-before-close](#days-before-close) for issues only | |
|
||||
| [days-before-pr-close](#days-before-pr-close) | Override [days-before-close](#days-before-close) for PRs only | |
|
||||
| [stale-issue-message](#stale-issue-message) | Comment on the staled issues | |
|
||||
| [stale-pr-message](#stale-pr-message) | Comment on the staled PRs | |
|
||||
| [close-issue-message](#close-issue-message) | Comment on the staled issues while closed | |
|
||||
| [close-pr-message](#close-pr-message) | Comment on the staled PRs while closed | |
|
||||
| [stale-issue-label](#stale-issue-label) | Label to apply on staled issues | `Stale` |
|
||||
| [close-issue-label](#close-issue-label) | Label to apply on closed issues | |
|
||||
| [stale-pr-label](#stale-pr-label) | Label to apply on staled PRs | `Stale` |
|
||||
| [close-pr-label](#close-pr-label) | Label to apply on closed PRs | |
|
||||
| [exempt-issue-labels](#exempt-issue-labels) | Labels on issues exempted from stale | |
|
||||
| [exempt-pr-labels](#exempt-pr-labels) | Labels on PRs exempted from stale | |
|
||||
| [only-labels](#only-labels) | Only issues/PRs with ALL these labels are checked | |
|
||||
| [only-issue-labels](#only-issue-labels) | Override [only-labels](#only-labels) for issues only | |
|
||||
| [only-pr-labels](#only-pr-labels) | Override [only-labels](#only-labels) for PRs only | |
|
||||
| [any-of-labels](#any-of-labels) | Only issues/PRs with ANY of these labels are checked | |
|
||||
| [any-of-issue-labels](#any-of-issue-labels) | Override [any-of-labels](#any-of-labels) for issues only | |
|
||||
| [any-of-pr-labels](#any-of-pr-labels) | Override [any-of-labels](#any-of-labels) for PRs only | |
|
||||
| [operations-per-run](#operations-per-run) | Max number of operations per run | `30` |
|
||||
| [remove-stale-when-updated](#remove-stale-when-updated) | Remove stale label from issues/PRs on updates | `true` |
|
||||
| [remove-issue-stale-when-updated](#remove-issue-stale-when-updated) | Remove stale label from issues on updates/comments | |
|
||||
| [remove-pr-stale-when-updated](#remove-pr-stale-when-updated) | Remove stale label from PRs on updates/comments | |
|
||||
| [labels-to-add-when-unstale](#labels-to-add-when-unstale) | Add specified labels from issues/PRs when they become unstale | |
|
||||
| [labels-to-remove-when-unstale](#labels-to-remove-when-unstale) | Remove specified labels from issues/PRs when they become unstale | |
|
||||
| [debug-only](#debug-only) | Dry-run | `false` |
|
||||
| [ascending](#ascending) | Order to get issues/PRs | `false` |
|
||||
| [start-date](#start-date) | Skip stale action for issues/PRs created before it | |
|
||||
| [delete-branch](#delete-branch) | Delete branch after closing a stale PR | `false` |
|
||||
| [exempt-milestones](#exempt-milestones) | Milestones on issues/PRs exempted from stale | |
|
||||
| [exempt-issue-milestones](#exempt-issue-milestones) | Override [exempt-milestones](#exempt-milestones) for issues only | |
|
||||
| [exempt-pr-milestones](#exempt-pr-milestones) | Override [exempt-milestones](#exempt-milestones) for PRs only | |
|
||||
| [exempt-all-milestones](#exempt-all-milestones) | Exempt all issues/PRs with milestones from stale | `false` |
|
||||
| [exempt-all-issue-milestones](#exempt-all-issue-milestones) | Override [exempt-all-milestones](#exempt-all-milestones) for issues only | |
|
||||
| [exempt-all-pr-milestones](#exempt-all-pr-milestones) | Override [exempt-all-milestones](#exempt-all-milestones) for PRs only | |
|
||||
| [exempt-assignees](#exempt-assignees) | Assignees on issues/PRs exempted from stale | |
|
||||
| [exempt-issue-assignees](#exempt-issue-assignees) | Override [exempt-assignees](#exempt-assignees) for issues only | |
|
||||
| [exempt-pr-assignees](#exempt-pr-assignees) | Override [exempt-assignees](#exempt-assignees) for PRs only | |
|
||||
| [exempt-all-assignees](#exempt-all-assignees) | Exempt all issues/PRs with assignees from stale | `false` |
|
||||
| [exempt-all-issue-assignees](#exempt-all-issue-assignees) | Override [exempt-all-assignees](#exempt-all-assignees) for issues only | |
|
||||
| [exempt-all-pr-assignees](#exempt-all-pr-assignees) | Override [exempt-all-assignees](#exempt-all-assignees) for PRs only | |
|
||||
| [exempt-draft-pr](#exempt-draft-pr) | Skip the stale action for draft PRs | `false` |
|
||||
| [enable-statistics](#enable-statistics) | Display statistics in the logs | `true` |
|
||||
| [ignore-updates](#ignore-updates) | Any update (update/comment) can reset the stale idle time on the issues/PRs | `false` |
|
||||
| [ignore-issue-updates](#ignore-issue-updates) | Override [ignore-updates](#ignore-updates) for issues only | |
|
||||
| [ignore-pr-updates](#ignore-pr-updates) | Override [ignore-updates](#ignore-updates) for PRs only | |
|
||||
|
||||
### List of output options
|
||||
|
||||
| Output | Description |
|
||||
| ----------------- | ------------------------------------------- |
|
||||
| staled-issues-prs | List of all staled issues and pull requests |
|
||||
| closed-issues-prs | List of all closed issues and pull requests |
|
||||
|
||||
### Detailed options
|
||||
|
||||
#### repo-token
|
||||
|
||||
Personal Access Token (PAT) that allows the stale workflow to authenticate and perform API calls to GitHub.
|
||||
Under the hood, it uses the [@actions/github](https://www.npmjs.com/package/@actions/github) package.
|
||||
|
||||
Default value: `${{ github.token }}`
|
||||
|
||||
#### days-before-stale
|
||||
|
||||
The idle number of days before marking the issues or the pull requests as stale (by adding a label).
|
||||
The issues or the pull requests will be marked as stale if the last update (based on [GitHub issue](https://docs.github.com/en/rest/reference/issues) field `updated_at`) is older than the idle number of days.
|
||||
It means that any updates made, or any comments added to the issues or to the pull requests will restart the counter of days before marking as stale.
|
||||
However, if you wish to ignore this behaviour so that the creation date (based on [GitHub issue](https://docs.github.com/en/rest/reference/issues) field `created_at`) only matters, you can disable the [ignore-updates](#ignore-updates) option.
|
||||
|
||||
If set to a negative number like `-1`, no issues or pull requests will be marked as stale automatically.
|
||||
In that case, you can still add the stale label manually to mark as stale.
|
||||
|
||||
The label used to stale is defined by these two options:
|
||||
|
||||
- [stale-issue-label](#stale-issue-label)
|
||||
- [stale-pr-label](#stale-pr-label)
|
||||
|
||||
A comment can also be added to notify about the stale and is defined by these two options:
|
||||
|
||||
- [stale-issue-message](#stale-issue-message)
|
||||
- [stale-pr-message](#stale-pr-message)
|
||||
|
||||
You can fine tune which issues or pull requests should be marked as stale based on the milestones, the assignees, the creation date and the missing/present labels from these options:
|
||||
|
||||
- [exempt-issue-labels](#exempt-issue-labels)
|
||||
- [exempt-pr-labels](#exempt-pr-labels)
|
||||
- [only-labels](#only-labels)
|
||||
- [any-of-labels](#any-of-labels)
|
||||
- [start-date](#start-date)
|
||||
- [exempt-milestones](#exempt-milestones)
|
||||
- [exempt-all-milestones](#exempt-all-milestones)
|
||||
- [exempt-assignees](#exempt-assignees)
|
||||
- [exempt-all-assignees](#exempt-all-assignees)
|
||||
- [ignore-updates](#ignore-updates)
|
||||
|
||||
Default value: `60`
|
||||
|
||||
#### days-before-issue-stale
|
||||
|
||||
Useful to override [days-before-stale](#days-before-stale) but only for the idle number of days before marking the issues as stale.
|
||||
|
||||
Default value: unset
|
||||
|
||||
#### days-before-pr-stale
|
||||
|
||||
Useful to override [days-before-stale](#days-before-stale) but only for the idle number of days before marking the pull requests as stale.
|
||||
|
||||
Default value: unset
|
||||
|
||||
#### days-before-close
|
||||
|
||||
The idle number of days before closing the stale issues or the stale pull requests (due to the stale label).
|
||||
The issues or the pull requests will be closed if the last update (based on [GitHub issue](https://docs.github.com/en/rest/reference/issues) field `updated_at`) is older than the idle number of days.
|
||||
Since adding the stale label will alter the last update date, we can calculate the number of days from this date.
|
||||
|
||||
If set to a negative number like `-1`, the issues or the pull requests will never be closed automatically.
|
||||
|
||||
The label used to stale is defined by these two options:
|
||||
|
||||
- [stale-issue-label](#stale-issue-label)
|
||||
- [stale-pr-label](#stale-pr-label)
|
||||
|
||||
Default value: `7`
|
||||
|
||||
#### days-before-issue-close
|
||||
|
||||
Override [days-before-close](#days-before-close) but only for the idle number of days before closing the stale issues.
|
||||
|
||||
Default value: unset
|
||||
|
||||
#### days-before-pr-close
|
||||
|
||||
Override [days-before-close](#days-before-close) but only for the idle number of days before closing the stale pull requests.
|
||||
|
||||
Default value: unset
|
||||
|
||||
#### stale-issue-message
|
||||
|
||||
The message that will be added as a comment to the issues when the stale workflow marks it automatically as stale with a label.
|
||||
|
||||
You can skip the comment sending by passing an empty string.
|
||||
|
||||
Default value: unset
|
||||
Required Permission: `issues: write`
|
||||
|
||||
#### stale-pr-message
|
||||
|
||||
The message that will be added as a comment to the pull requests when the stale workflow marks it automatically as stale with a label.
|
||||
|
||||
You can skip the comment sending by passing an empty string.
|
||||
|
||||
Default value: unset
|
||||
Required Permission: `pull-requests: write`
|
||||
|
||||
#### close-issue-message
|
||||
|
||||
The message that will be added as a comment to the issues when the stale workflow closes it automatically after being stale for too long.
|
||||
|
||||
Default value: unset
|
||||
Required Permission: `issues: write`
|
||||
|
||||
#### close-pr-message
|
||||
|
||||
The message that will be added as a comment to the pull requests when the stale workflow closes it automatically after being stale for too long.
|
||||
|
||||
Default value: unset
|
||||
Required Permission: `pull-requests: write`
|
||||
|
||||
#### stale-issue-label
|
||||
|
||||
The label that will be added to the issues when automatically marked as stale.
|
||||
If you wish to speedup the stale workflow for the issues, you can add this label manually to mark as stale.
|
||||
|
||||
Default value: `Stale`
|
||||
Required Permission: `issues: write`
|
||||
|
||||
#### close-issue-label
|
||||
|
||||
The label that will be added to the issues when closed automatically.
|
||||
It will be automatically removed if the issues are no longer closed nor locked.
|
||||
|
||||
Default value: unset
|
||||
Required Permission: `issues: write`
|
||||
|
||||
#### stale-pr-label
|
||||
|
||||
The label that will be added to the pull requests when automatically marked as stale.
|
||||
If you wish to speedup the stale workflow for the pull requests, you can add this label manually to mark as stale.
|
||||
|
||||
Default value: `Stale`
|
||||
Required Permission: `pull-requests: write`
|
||||
|
||||
#### close-pr-label
|
||||
|
||||
The label that will be added to the pull requests when closed automatically.
|
||||
It will be automatically removed if the pull requests are no longer closed nor locked.
|
||||
|
||||
Default value: unset
|
||||
Required Permission: `pull-requests: write`
|
||||
|
||||
#### exempt-issue-labels
|
||||
|
||||
The label(s) that can exempt to automatically mark as stale the issues.
|
||||
It can be a comma separated list of labels (e.g: `question,bug`).
|
||||
|
||||
If unset (or an empty string), this option will not alter the stale workflow.
|
||||
|
||||
Default value: unset
|
||||
|
||||
#### exempt-pr-labels
|
||||
|
||||
The label(s) that can exempt to automatically mark as stale the pull requests.
|
||||
It can be a comma separated list of labels (e.g: `need-help,WIP`).
|
||||
|
||||
If unset (or an empty string), this option will not alter the stale workflow.
|
||||
|
||||
Default value: unset
|
||||
|
||||
#### only-labels
|
||||
|
||||
An allow-list of label(s) to only process the issues or the pull requests that contain all these label(s).
|
||||
It can be a comma separated list of labels (e.g: `answered,needs-rebase`).
|
||||
|
||||
If unset (or an empty string), this option will not alter the stale workflow.
|
||||
|
||||
If you wish to only check that the issues or the pull requests contain one of these label(s), use instead [any-of-labels](#any-of-labels).
|
||||
|
||||
Default value: unset
|
||||
|
||||
#### only-issue-labels
|
||||
|
||||
Override [only-labels](#only-labels) but only to process the issues that contain all these label(s).
|
||||
|
||||
Default value: unset
|
||||
|
||||
#### only-pr-labels
|
||||
|
||||
Override [only-labels](#only-labels) but only to process the pull requests that contain all these label(s).
|
||||
|
||||
Default value: unset
|
||||
|
||||
#### any-of-labels
|
||||
|
||||
An allow-list of label(s) to only process the issues or the pull requests that contain one of these label(s).
|
||||
It can be a comma separated list of labels (e.g: `answered,needs-rebase`).
|
||||
|
||||
If unset (or an empty string), this option will not alter the stale workflow.
|
||||
|
||||
If you wish to only check that the issues or the pull requests contain all these label(s), use instead [only-labels](#only-labels).
|
||||
|
||||
Default value: unset
|
||||
|
||||
#### any-of-issue-labels
|
||||
|
||||
Override [any-of-labels](#any-of-labels) but only to process the issues that contain one of these label(s).
|
||||
|
||||
Default value: unset
|
||||
|
||||
#### any-of-pr-labels
|
||||
|
||||
Override [any-of-labels](#any-of-labels) but only to process the pull requests that contain one of these label(s).
|
||||
|
||||
Default value: unset
|
||||
|
||||
#### operations-per-run
|
||||
|
||||
_Context:_
|
||||
This action performs some API calls to GitHub to fetch or close issues and pull requests, set or update labels, add comments, delete branches, etc.
|
||||
These operations are made in a very short period of time - because the action is very fast to run - and can be numerous based on your project action configuration and the quantity of issues and pull requests within it.
|
||||
GitHub has a [rate limit](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting) and if reached will block all of these API calls for one hour (or API calls from other actions using the same user (a.k.a: the github-token from the [repo-token](#repo-token) option)).
|
||||
These operations are made in a very short period of time — because the action is very fast to run — and can be numerous based on your project action configuration and the quantity of issues and pull requests within it.
|
||||
GitHub has a [rate limit](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting) and if reached will block these API calls for one hour (or API calls from other actions using the same user (a.k.a.: the github-token from the [repo-token](#repo-token) option)).
|
||||
This option helps you to stay within the GitHub rate limits, as you can use this option to limit the number of operations for a single run.
|
||||
|
||||
_Purpose:_
|
||||
@@ -75,13 +313,202 @@ This option aims to limit the number of operations made with the GitHub API to a
|
||||
Based on your project, your GitHub business plan and the date of the cron job you set for this action, you can increase this limit to a higher number.
|
||||
If you are not sure which is the right value for you or if the default value is good enough, you could enable the logs and look at the end of the stale action.
|
||||
If you reached the limit, you will see a warning message in the logs, telling you that you should increase the number of operations.
|
||||
If you choose not to increase the limit, you might end up with un-processed issues or pull requests after a stale action run.
|
||||
If you choose not to increase the limit, you might end up with unprocessed issues or pull requests after a stale action run.
|
||||
|
||||
When [debugging](#Debugging), you can set it to a much higher number like `1000` since there will be fewer operations made with the GitHub API.
|
||||
Only the [actor](#repo-token) and the batch of issues (100 per batch) will consume the operations.
|
||||
|
||||
Default value: `30`
|
||||
|
||||
#### remove-stale-when-updated
|
||||
|
||||
Automatically remove the stale label when the issues or the pull requests are updated (based on [GitHub issue](https://docs.github.com/en/rest/reference/issues) field `updated_at`) or commented.
|
||||
|
||||
Default value: `true`
|
||||
Required Permission: `issues: write` and `pull-requests: write`
|
||||
|
||||
#### remove-issue-stale-when-updated
|
||||
|
||||
Override [remove-stale-when-updated](#remove-stale-when-updated) but only to automatically remove the stale label when the issues are updated (based on [GitHub issue](https://docs.github.com/en/rest/reference/issues) field `updated_at`) or commented.
|
||||
|
||||
Default value: unset
|
||||
Required Permission: `issues: write`
|
||||
|
||||
#### remove-pr-stale-when-updated
|
||||
|
||||
Override [remove-stale-when-updated](#remove-stale-when-updated) but only to automatically remove the stale label when the pull requests are updated (based on [GitHub issue](https://docs.github.com/en/rest/reference/issues) field `updated_at`) or commented.
|
||||
|
||||
Default value: unset
|
||||
|
||||
#### labels-to-add-when-unstale
|
||||
|
||||
A comma delimited list of labels to add when a stale issue or pull request receives activity and has the [stale-issue-label](#stale-issue-label) or [stale-pr-label](#stale-pr-label) removed from it.
|
||||
|
||||
Default value: unset
|
||||
|
||||
#### labels-to-remove-when-unstale
|
||||
|
||||
A comma delimited list of labels to remove when a stale issue or pull request receives activity and has the [stale-issue-label](#stale-issue-label) or [stale-pr-label](#stale-pr-label) removed from it.
|
||||
|
||||
Warning: each label results in a unique API call which can drastically consume the limit of [operations-per-run](#operations-per-run).
|
||||
|
||||
Default value: unset
|
||||
Required Permission: `pull-requests: write`
|
||||
|
||||
#### debug-only
|
||||
|
||||
Run the stale workflow as dry-run.
|
||||
No GitHub API calls that can alter your issues and pull requests will happen.
|
||||
Useful to debug or when you want to configure the stale workflow safely.
|
||||
|
||||
Default value: `false`
|
||||
|
||||
#### ascending
|
||||
|
||||
Change the order used to fetch the issues and pull requests from GitHub:
|
||||
|
||||
- `true` is for ascending.
|
||||
- `false` is for descending.
|
||||
|
||||
It can be useful if your repository is processing so many issues and pull requests that you reach the [operations-per-run](#operations-per-run) limit.
|
||||
Based on the order, you could prefer to focus on the new content or on the old content of your repository.
|
||||
|
||||
Default value: `false`
|
||||
|
||||
#### start-date
|
||||
|
||||
The start date is used to ignore the issues and pull requests created before the start date.
|
||||
Particularly useful when you wish to add this stale workflow on an existing repository and only wish to stale the new issues and pull requests.
|
||||
|
||||
If set, the date must be formatted following the `ISO 8601` or `RFC 2822` standard.
|
||||
|
||||
Default value: unset
|
||||
|
||||
#### delete-branch
|
||||
|
||||
If set to `true`, the stale workflow will automatically delete the GitHub branches related to the pull requests automatically closed by the stale workflow.
|
||||
|
||||
Default value: `false`
|
||||
Required Permission: `pull-requests: write`
|
||||
|
||||
#### exempt-milestones
|
||||
|
||||
A white-list of milestone(s) to only process the issues or the pull requests that does not contain one of these milestone(s).
|
||||
It can be a comma separated list of milestones (e.g: `V1,next`).
|
||||
|
||||
If unset (or an empty string), this option will not alter the stale workflow.
|
||||
|
||||
Default value: unset
|
||||
|
||||
#### exempt-issue-milestones
|
||||
|
||||
Override [exempt-milestones](#exempt-milestones) but only to process the issues that does not contain one of these milestone(s).
|
||||
|
||||
Default value: unset
|
||||
|
||||
#### exempt-pr-milestones
|
||||
|
||||
Override [exempt-milestones](#exempt-milestones) but only to process the pull requests that does not contain one of these milestone(s).
|
||||
|
||||
Default value: unset
|
||||
|
||||
#### exempt-all-milestones
|
||||
|
||||
If set to `true`, the issues or the pull requests with a milestone will not be marked as stale automatically.
|
||||
|
||||
Priority over [exempt-milestones](#exempt-milestones).
|
||||
|
||||
Default value: `false`
|
||||
|
||||
#### exempt-all-issue-milestones
|
||||
|
||||
Override [exempt-all-milestones](#exempt-all-milestones) but only to exempt the issues with a milestone to be marked as stale automatically.
|
||||
|
||||
Default value: unset
|
||||
|
||||
#### exempt-all-pr-milestones
|
||||
|
||||
Override [exempt-all-milestones](#exempt-all-milestones) but only to exempt the pull requests with a milestone to be marked as stale automatically.
|
||||
|
||||
Default value: unset
|
||||
|
||||
#### exempt-assignees
|
||||
|
||||
An allow-list of assignee(s) to only process the issues or the pull requests that does not contain one of these assignee(s).
|
||||
It can be a comma separated list of assignees (e.g: `marco,polo`).
|
||||
|
||||
If unset (or an empty string), this option will not alter the stale workflow.
|
||||
|
||||
Default value: unset
|
||||
|
||||
#### exempt-issue-assignees
|
||||
|
||||
Override [exempt-assignees](#exempt-assignees) but only to process the issues that does not contain one of these assignee(s).
|
||||
|
||||
Default value: unset
|
||||
|
||||
#### exempt-pr-assignees
|
||||
|
||||
Override [exempt-assignees](#exempt-assignees) but only to process the pull requests that does not contain one of these assignee(s).
|
||||
|
||||
Default value: unset
|
||||
|
||||
#### exempt-all-assignees
|
||||
|
||||
If set to `true`, the issues or the pull requests with an assignee will not be marked as stale automatically.
|
||||
|
||||
Priority over [exempt-assignees](#exempt-assignees).
|
||||
|
||||
Default value: `false`
|
||||
|
||||
#### exempt-all-issue-assignees
|
||||
|
||||
Override [exempt-all-assignees](#exempt-all-assignees) but only to exempt the issues with an assignee to be marked as stale automatically.
|
||||
|
||||
Default value: unset
|
||||
|
||||
#### exempt-all-pr-assignees
|
||||
|
||||
Override [exempt-all-assignees](#exempt-all-assignees) but only to exempt the pull requests with an assignee to be marked as stale automatically.
|
||||
|
||||
Default value: unset
|
||||
|
||||
#### exempt-draft-pr
|
||||
|
||||
If set to `true`, the pull requests currently in draft will not be marked as stale automatically.
|
||||
⚠️ This option consume one operation per pull request to process because we need to fetch the pull request with the GitHub API to know if it's a draft one or not.
|
||||
|
||||
Default value: `false`
|
||||
Required Permission: `pull-requests: read`
|
||||
|
||||
#### enable-statistics
|
||||
|
||||
Collects and display statistics at the end of the stale workflow logs to get a summary of what happened during the run.
|
||||
This option is only useful if the debug output secret `ACTIONS_STEP_DEBUG` is set to `true` in your repository to display the logs.
|
||||
|
||||
Default value: `true`
|
||||
|
||||
#### ignore-updates
|
||||
|
||||
The option [days-before-stale](#days-before-stale) will define the number of days before considering the issues or the pull requests as stale.
|
||||
In most cases, the purpose of this action is to only stale when necessary so if any update occurs or if a comment is added to them, the counter will restart.
|
||||
Nonetheless, if you don't care about this, and you prefer to stick to this number of days no matter the update, you can enable this option.
|
||||
Instead of comparing the number of days based on the [GitHub issue](https://docs.github.com/en/rest/reference/issues) field `updated_at`, it will be based on the [GitHub issue](https://docs.github.com/en/rest/reference/issues) field `created_at`.
|
||||
|
||||
Default value: `false`
|
||||
|
||||
#### ignore-issue-updates
|
||||
|
||||
Useful to override [ignore-updates](#ignore-updates) but only to ignore the updates for the issues.
|
||||
|
||||
Default value: unset
|
||||
|
||||
#### ignore-pr-updates
|
||||
|
||||
Useful to override [ignore-updates](#ignore-updates) but only to ignore the updates for the pull requests.
|
||||
|
||||
Default value: unset
|
||||
|
||||
### Usage
|
||||
|
||||
See also [action.yml](./action.yml) for a comprehensive list of all the options.
|
||||
@@ -98,7 +525,7 @@ jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v3
|
||||
- uses: actions/stale@v4
|
||||
with:
|
||||
stale-issue-message: 'Message to comment on stale issues. If none provided, will not mark issues stale'
|
||||
stale-pr-message: 'Message to comment on stale PRs. If none provided, will not mark PRs stale'
|
||||
@@ -116,7 +543,7 @@ jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v3
|
||||
- uses: actions/stale@v4
|
||||
with:
|
||||
stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.'
|
||||
days-before-stale: 30
|
||||
@@ -135,9 +562,8 @@ jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v3
|
||||
- uses: actions/stale@v4
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.'
|
||||
stale-pr-message: 'This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.'
|
||||
close-issue-message: 'This issue was closed because it has been stalled for 5 days with no activity.'
|
||||
@@ -158,9 +584,8 @@ jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v3
|
||||
- uses: actions/stale@v4
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.'
|
||||
stale-pr-message: 'This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.'
|
||||
close-issue-message: 'This issue was closed because it has been stalled for 5 days with no activity.'
|
||||
@@ -183,7 +608,7 @@ jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v3
|
||||
- uses: actions/stale@v4
|
||||
with:
|
||||
stale-issue-message: 'Stale issue message'
|
||||
stale-pr-message: 'Stale pull request message'
|
||||
@@ -206,9 +631,9 @@ jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v3
|
||||
- uses: actions/stale@v4
|
||||
with:
|
||||
start-date: '2020-18-04T00:00:00Z' // ISO 8601 or RFC 2822
|
||||
start-date: '2020-04-18T00:00:00Z' # ISO 8601 or RFC 2822
|
||||
```
|
||||
|
||||
Avoid stale for specific milestones:
|
||||
@@ -223,7 +648,7 @@ jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v3
|
||||
- uses: actions/stale@v4
|
||||
with:
|
||||
exempt-issue-milestones: 'future,alpha,beta'
|
||||
exempt-pr-milestones: 'bugfix,improvement'
|
||||
@@ -241,7 +666,7 @@ jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v3
|
||||
- uses: actions/stale@v4
|
||||
with:
|
||||
exempt-all-pr-milestones: true
|
||||
```
|
||||
@@ -258,7 +683,7 @@ jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v3
|
||||
- uses: actions/stale@v4
|
||||
with:
|
||||
any-of-labels: 'needs-more-info,needs-demo'
|
||||
# You can opt for 'only-labels' instead if your use-case requires all labels
|
||||
@@ -277,7 +702,7 @@ jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v3
|
||||
- uses: actions/stale@v4
|
||||
with:
|
||||
exempt-issue-assignees: 'marco,polo'
|
||||
exempt-pr-assignees: 'marco'
|
||||
@@ -295,7 +720,7 @@ jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v3
|
||||
- uses: actions/stale@v4
|
||||
with:
|
||||
exempt-all-pr-assignees: true
|
||||
```
|
||||
@@ -304,7 +729,7 @@ jobs:
|
||||
|
||||
**Logs:**
|
||||
To see the debug output from this action, you must set the secret `ACTIONS_STEP_DEBUG` to `true` in your repository.
|
||||
There is a lot of logs so this can be very helpful!
|
||||
There are many logs, so this can be very helpful!
|
||||
|
||||
**Statistics:**
|
||||
If the logs are enabled, you can also enable the statistics log which will be visible at the end of the logs once all issues were processed.
|
||||
@@ -320,9 +745,9 @@ If the `debug-only` option is enabled, this is very helpful because the workflow
|
||||
|
||||
**Job frequency:**
|
||||
You could change the cron job frequency in the stale workflow to run the stale workflow more often.
|
||||
Usually this is not very helpful though.
|
||||
Usually, this is not very helpful though.
|
||||
|
||||
### Contributing
|
||||
|
||||
You wish to contribute?
|
||||
Check out the [contributing](CONTRIBUTING.md) file before helping us.
|
||||
We welcome contributions!
|
||||
Please read the [contributing](CONTRIBUTING.md) file before starting your work.
|
||||
|
||||
@@ -8,7 +8,7 @@ import {generateIssue} from './functions/generate-issue';
|
||||
let issuesProcessorBuilder: IssuesProcessorBuilder;
|
||||
let issuesProcessor: IssuesProcessorMock;
|
||||
|
||||
describe('any-of-labels option', (): void => {
|
||||
describe('any-of-labels options', (): void => {
|
||||
beforeEach((): void => {
|
||||
issuesProcessorBuilder = new IssuesProcessorBuilder();
|
||||
});
|
||||
@@ -1112,14 +1112,12 @@ class IssuesProcessorBuilder {
|
||||
|
||||
issues(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
|
||||
this.issuesOrPrs(
|
||||
issues.map(
|
||||
(issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
|
||||
return {
|
||||
...issue,
|
||||
pull_request: null
|
||||
};
|
||||
}
|
||||
)
|
||||
issues.map((issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
|
||||
return {
|
||||
...issue,
|
||||
pull_request: null
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
return this;
|
||||
@@ -1127,14 +1125,12 @@ class IssuesProcessorBuilder {
|
||||
|
||||
prs(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
|
||||
this.issuesOrPrs(
|
||||
issues.map(
|
||||
(issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
|
||||
return {
|
||||
...issue,
|
||||
pull_request: {key: 'value'}
|
||||
};
|
||||
}
|
||||
)
|
||||
issues.map((issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
|
||||
return {
|
||||
...issue,
|
||||
pull_request: {key: 'value'}
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
return this;
|
||||
@@ -1143,7 +1139,6 @@ class IssuesProcessorBuilder {
|
||||
build(): IssuesProcessorMock {
|
||||
return new IssuesProcessorMock(
|
||||
this._options,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? this._issues : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
|
||||
@@ -48,7 +48,6 @@ describe('assignees options', (): void => {
|
||||
const setProcessor = () => {
|
||||
processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? testIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
|
||||
@@ -2,27 +2,24 @@ import {Issue} from '../../src/classes/issue';
|
||||
import {IssuesProcessor} from '../../src/classes/issues-processor';
|
||||
import {IComment} from '../../src/interfaces/comment';
|
||||
import {IIssuesProcessorOptions} from '../../src/interfaces/issues-processor-options';
|
||||
import {IPullRequest} from '../../src/interfaces/pull-request';
|
||||
|
||||
export class IssuesProcessorMock extends IssuesProcessor {
|
||||
constructor(
|
||||
options: IIssuesProcessorOptions,
|
||||
getActor?: () => Promise<string>,
|
||||
getIssues?: (page: number) => Promise<Issue[]>,
|
||||
listIssueComments?: (
|
||||
issueNumber: number,
|
||||
issue: Issue,
|
||||
sinceDate: string
|
||||
) => Promise<IComment[]>,
|
||||
getLabelCreationDate?: (
|
||||
issue: Issue,
|
||||
label: string
|
||||
) => Promise<string | undefined>
|
||||
) => Promise<string | undefined>,
|
||||
getPullRequest?: (issue: Issue) => Promise<IPullRequest | undefined | void>
|
||||
) {
|
||||
super(options);
|
||||
|
||||
if (getActor) {
|
||||
this.getActor = getActor;
|
||||
}
|
||||
|
||||
if (getIssues) {
|
||||
this.getIssues = getIssues;
|
||||
}
|
||||
@@ -34,5 +31,9 @@ export class IssuesProcessorMock extends IssuesProcessor {
|
||||
if (getLabelCreationDate) {
|
||||
this.getLabelCreationDate = getLabelCreationDate;
|
||||
}
|
||||
|
||||
if (getPullRequest) {
|
||||
this.getPullRequest = getPullRequest;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,8 +30,6 @@ export const DefaultProcessorOptions: IIssuesProcessorOptions = Object.freeze({
|
||||
removeIssueStaleWhenUpdated: undefined,
|
||||
removePrStaleWhenUpdated: undefined,
|
||||
ascending: false,
|
||||
skipStaleIssueMessage: false,
|
||||
skipStalePrMessage: false,
|
||||
deleteBranch: false,
|
||||
startDate: '',
|
||||
exemptMilestones: '',
|
||||
@@ -46,5 +44,11 @@ export const DefaultProcessorOptions: IIssuesProcessorOptions = Object.freeze({
|
||||
exemptAllAssignees: false,
|
||||
exemptAllIssueAssignees: undefined,
|
||||
exemptAllPrAssignees: undefined,
|
||||
enableStatistics: true
|
||||
enableStatistics: true,
|
||||
labelsToRemoveWhenUnstale: '',
|
||||
labelsToAddWhenUnstale: '',
|
||||
ignoreUpdates: false,
|
||||
ignoreIssueUpdates: undefined,
|
||||
ignorePrUpdates: undefined,
|
||||
exemptDraftPr: false
|
||||
});
|
||||
|
||||
139
__tests__/exempt-draft-pr.spec.ts
Normal file
139
__tests__/exempt-draft-pr.spec.ts
Normal file
@@ -0,0 +1,139 @@
|
||||
import {Issue} from '../src/classes/issue';
|
||||
import {IIssue} from '../src/interfaces/issue';
|
||||
import {IIssuesProcessorOptions} from '../src/interfaces/issues-processor-options';
|
||||
import {IPullRequest} from '../src/interfaces/pull-request';
|
||||
import {IssuesProcessorMock} from './classes/issues-processor-mock';
|
||||
import {DefaultProcessorOptions} from './constants/default-processor-options';
|
||||
import {generateIssue} from './functions/generate-issue';
|
||||
|
||||
let issuesProcessorBuilder: IssuesProcessorBuilder;
|
||||
let issuesProcessor: IssuesProcessorMock;
|
||||
|
||||
describe('exempt-draft-pr option', (): void => {
|
||||
beforeEach((): void => {
|
||||
issuesProcessorBuilder = new IssuesProcessorBuilder();
|
||||
});
|
||||
|
||||
describe('when the option "exempt-draft-pr" is disabled', (): void => {
|
||||
beforeEach((): void => {
|
||||
issuesProcessorBuilder.processDraftPr();
|
||||
});
|
||||
|
||||
test('should stale the pull request', async (): Promise<void> => {
|
||||
expect.assertions(1);
|
||||
issuesProcessor = issuesProcessorBuilder
|
||||
.toStalePrs([
|
||||
{
|
||||
number: 10
|
||||
}
|
||||
])
|
||||
.build();
|
||||
|
||||
await issuesProcessor.processIssues();
|
||||
|
||||
expect(issuesProcessor.staleIssues).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the option "exempt-draft-pr" is enabled', (): void => {
|
||||
beforeEach((): void => {
|
||||
issuesProcessorBuilder.exemptDraftPr();
|
||||
});
|
||||
|
||||
test('should not stale the pull request', async (): Promise<void> => {
|
||||
expect.assertions(1);
|
||||
issuesProcessor = issuesProcessorBuilder
|
||||
.toStalePrs([
|
||||
{
|
||||
number: 20
|
||||
}
|
||||
])
|
||||
.build();
|
||||
|
||||
await issuesProcessor.processIssues();
|
||||
|
||||
expect(issuesProcessor.staleIssues).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
class IssuesProcessorBuilder {
|
||||
private _options: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions
|
||||
};
|
||||
private _issues: Issue[] = [];
|
||||
|
||||
processDraftPr(): IssuesProcessorBuilder {
|
||||
this._options.exemptDraftPr = false;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
exemptDraftPr(): IssuesProcessorBuilder {
|
||||
this._options.exemptDraftPr = true;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
issuesOrPrs(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
|
||||
this._issues = issues.map(
|
||||
(issue: Readonly<Partial<IIssue>>, index: Readonly<number>): Issue =>
|
||||
generateIssue(
|
||||
this._options,
|
||||
issue.number ?? index,
|
||||
issue.title ?? 'dummy-title',
|
||||
issue.updated_at ?? new Date().toDateString(),
|
||||
issue.created_at ?? new Date().toDateString(),
|
||||
!!issue.pull_request,
|
||||
issue.labels ? issue.labels.map(label => label.name) : []
|
||||
)
|
||||
);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
prs(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
|
||||
this.issuesOrPrs(
|
||||
issues.map((issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
|
||||
return {
|
||||
...issue,
|
||||
pull_request: {key: 'value'}
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
toStalePrs(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
|
||||
this.prs(
|
||||
issues.map((issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
|
||||
return {
|
||||
...issue,
|
||||
updated_at: '2020-01-01T17:00:00Z',
|
||||
created_at: '2020-01-01T17:00:00Z'
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
build(): IssuesProcessorMock {
|
||||
return new IssuesProcessorMock(
|
||||
this._options,
|
||||
async p => (p === 1 ? this._issues : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString(),
|
||||
async (): Promise<IPullRequest> => {
|
||||
return Promise.resolve({
|
||||
number: 0,
|
||||
draft: true,
|
||||
head: {
|
||||
ref: 'ref'
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import {Issue} from '../../src/classes/issue';
|
||||
import {IAssignee} from '../../src/interfaces/assignee';
|
||||
import {IUserAssignee} from '../../src/interfaces/assignee';
|
||||
import {IIssuesProcessorOptions} from '../../src/interfaces/issues-processor-options';
|
||||
import {IsoDateString} from '../../src/types/iso-date-string';
|
||||
|
||||
@@ -32,12 +32,11 @@ export function generateIssue(
|
||||
title: milestone
|
||||
}
|
||||
: undefined,
|
||||
assignees: assignees.map(
|
||||
(assignee: Readonly<string>): IAssignee => {
|
||||
return {
|
||||
login: assignee
|
||||
};
|
||||
}
|
||||
)
|
||||
assignees: assignees.map((assignee: Readonly<string>): IUserAssignee => {
|
||||
return {
|
||||
login: assignee,
|
||||
type: 'User'
|
||||
};
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ test('processing an issue with no label will make it stale and close it, if it i
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -48,7 +47,6 @@ test('processing an issue with no label and a start date as ECMAScript epoch in
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -80,7 +78,6 @@ test('processing an issue with no label and a start date as ECMAScript epoch in
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -112,7 +109,6 @@ test('processing an issue with no label and a start date as ECMAScript epoch in
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -144,7 +140,6 @@ test('processing an issue with no label and a start date as ECMAScript epoch in
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -176,7 +171,6 @@ test('processing an issue with no label and a start date as ISO 8601 being befor
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -208,7 +202,6 @@ test('processing an issue with no label and a start date as ISO 8601 being after
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -240,7 +233,6 @@ test('processing an issue with no label and a start date as RFC 2822 being befor
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -272,7 +264,6 @@ test('processing an issue with no label and a start date as RFC 2822 being after
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -296,7 +287,6 @@ test('processing an issue with no label will make it stale and close it, if it i
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -321,7 +311,6 @@ test('processing an issue with no label will make it stale and not close it, if
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -344,7 +333,6 @@ test('processing an issue with no label will make it stale and not close it if d
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -368,7 +356,6 @@ test('processing an issue with no label will make it stale and not close it if d
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -392,7 +379,6 @@ test('processing an issue with no label will not make it stale if days-before-st
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -417,7 +403,6 @@ test('processing an issue with no label will not make it stale if days-before-st
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -445,7 +430,6 @@ test('processing an issue with no label will make it stale but not close it', as
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
DefaultProcessorOptions,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -476,7 +460,6 @@ test('processing a stale issue will close it', async () => {
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -507,7 +490,6 @@ test('processing a stale issue containing a space in the label will close it', a
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -538,7 +520,6 @@ test('processing a stale issue containing a slash in the label will close it', a
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -570,7 +551,6 @@ test('processing a stale issue will close it when days-before-issue-stale overri
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -601,7 +581,6 @@ test('processing a stale PR will close it', async () => {
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -633,7 +612,6 @@ test('processing a stale PR will close it when days-before-pr-stale override day
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -665,7 +643,6 @@ test('processing a stale issue will close it even if configured not to mark as s
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -698,7 +675,6 @@ test('processing a stale issue will close it even if configured not to mark as s
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -730,7 +706,6 @@ test('processing a stale PR will close it even if configured not to mark as stal
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -763,7 +738,6 @@ test('processing a stale PR will close it even if configured not to mark as stal
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -791,7 +765,6 @@ test('closed issues will not be marked stale', async () => {
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
DefaultProcessorOptions,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => []
|
||||
);
|
||||
@@ -818,7 +791,6 @@ test('stale closed issues will not be closed', async () => {
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
DefaultProcessorOptions,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -846,7 +818,6 @@ test('closed prs will not be marked stale', async () => {
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
DefaultProcessorOptions,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -874,7 +845,6 @@ test('stale closed prs will not be closed', async () => {
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
DefaultProcessorOptions,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -901,10 +871,8 @@ test('locked issues will not be marked stale', async () => {
|
||||
true
|
||||
)
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
DefaultProcessorOptions,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : [])
|
||||
const processor = new IssuesProcessorMock(DefaultProcessorOptions, async p =>
|
||||
p === 1 ? TestIssueList : []
|
||||
);
|
||||
|
||||
// process our fake issue list
|
||||
@@ -930,7 +898,6 @@ test('stale locked issues will not be closed', async () => {
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
DefaultProcessorOptions,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -957,10 +924,8 @@ test('locked prs will not be marked stale', async () => {
|
||||
true
|
||||
)
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
DefaultProcessorOptions,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : [])
|
||||
const processor = new IssuesProcessorMock(DefaultProcessorOptions, async p =>
|
||||
p === 1 ? TestIssueList : []
|
||||
);
|
||||
|
||||
// process our fake issue list
|
||||
@@ -986,7 +951,6 @@ test('stale locked prs will not be closed', async () => {
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
DefaultProcessorOptions,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -1016,7 +980,6 @@ test('exempt issue labels will not be marked stale', async () => {
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -1046,7 +1009,6 @@ test('exempt issue labels will not be marked stale (multi issue label with space
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -1075,7 +1037,6 @@ test('exempt issue labels will not be marked stale (multi issue label)', async (
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -1122,7 +1083,6 @@ test('exempt pr labels will not be marked stale', async () => {
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -1151,14 +1111,14 @@ test('exempt issue labels will not be marked stale and will remove the existing
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [
|
||||
{
|
||||
user: {
|
||||
login: 'notme',
|
||||
type: 'User'
|
||||
}
|
||||
},
|
||||
body: 'Body'
|
||||
}
|
||||
], // return a fake comment to indicate there was an update
|
||||
async () => new Date().toDateString()
|
||||
@@ -1206,7 +1166,6 @@ test('stale issues should not be closed if days is set to -1', async () => {
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -1234,14 +1193,14 @@ test('stale label should be removed if a comment was added to a stale issue', as
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [
|
||||
{
|
||||
user: {
|
||||
login: 'notme',
|
||||
type: 'User'
|
||||
}
|
||||
},
|
||||
body: 'Body'
|
||||
}
|
||||
], // return a fake comment to indicate there was an update
|
||||
async () => new Date().toDateString()
|
||||
@@ -1255,6 +1214,50 @@ test('stale label should be removed if a comment was added to a stale issue', as
|
||||
expect(processor.removedLabelIssues).toHaveLength(1);
|
||||
});
|
||||
|
||||
test('when the option "labelsToAddWhenUnstale" is set, the labels should be added when unstale', async () => {
|
||||
expect.assertions(4);
|
||||
const opts = {
|
||||
...DefaultProcessorOptions,
|
||||
removeStaleWhenUpdated: true,
|
||||
labelsToAddWhenUnstale: 'test'
|
||||
};
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(
|
||||
opts,
|
||||
1,
|
||||
'An issue that should have labels added to it when unstale',
|
||||
'2020-01-01T17:00:00Z',
|
||||
'2020-01-01T17:00:00Z',
|
||||
false,
|
||||
['Stale']
|
||||
)
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [
|
||||
{
|
||||
user: {
|
||||
login: 'notme',
|
||||
type: 'User'
|
||||
},
|
||||
body: 'Body'
|
||||
}
|
||||
], // return a fake comment to indicate there was an update
|
||||
async () => new Date().toDateString()
|
||||
);
|
||||
|
||||
// process our fake issue list
|
||||
await processor.processIssues(1);
|
||||
|
||||
expect(processor.closedIssues).toHaveLength(0);
|
||||
expect(processor.staleIssues).toHaveLength(0);
|
||||
// Stale should have been removed
|
||||
expect(processor.removedLabelIssues).toHaveLength(1);
|
||||
// Some label should have been added
|
||||
expect(processor.addedLabelIssues).toHaveLength(1);
|
||||
});
|
||||
|
||||
test('stale label should not be removed if a comment was added by the bot (and the issue should be closed)', async () => {
|
||||
const opts = {...DefaultProcessorOptions, removeStaleWhenUpdated: true};
|
||||
github.context.actor = 'abot';
|
||||
@@ -1271,14 +1274,14 @@ test('stale label should not be removed if a comment was added by the bot (and t
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [
|
||||
{
|
||||
user: {
|
||||
login: 'abot',
|
||||
type: 'User'
|
||||
}
|
||||
},
|
||||
body: 'This issue is stale'
|
||||
}
|
||||
], // return a fake comment to indicate there was an update by the bot
|
||||
async () => new Date().toDateString()
|
||||
@@ -1311,9 +1314,8 @@ test('stale label containing a space should be removed if a comment was added to
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [{user: {login: 'notme', type: 'User'}}], // return a fake comment to indicate there was an update
|
||||
async () => [{user: {login: 'notme', type: 'User'}, body: 'Body'}], // return a fake comment to indicate there was an update
|
||||
async () => new Date().toDateString()
|
||||
);
|
||||
|
||||
@@ -1343,7 +1345,6 @@ test('stale issues should not be closed until after the closed number of days',
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -1376,7 +1377,6 @@ test('stale issues should be closed if the closed nubmer of days (additive) is a
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -1408,7 +1408,6 @@ test('stale issues should not be closed until after the closed number of days (l
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -1422,11 +1421,11 @@ test('stale issues should not be closed until after the closed number of days (l
|
||||
expect(processor.staleIssues).toHaveLength(1);
|
||||
});
|
||||
|
||||
test('skips stale message on issues when skip-stale-issue-message is set', async () => {
|
||||
test('skips stale message on issues when stale-issue-message is empty', async () => {
|
||||
const opts = {...DefaultProcessorOptions};
|
||||
opts.daysBeforeStale = 5; // stale after 5 days
|
||||
opts.daysBeforeClose = 20; // closes after 25 days
|
||||
opts.skipStaleIssueMessage = true;
|
||||
opts.staleIssueMessage = '';
|
||||
const lastUpdate = new Date();
|
||||
lastUpdate.setDate(lastUpdate.getDate() - 10);
|
||||
const TestIssueList: Issue[] = [
|
||||
@@ -1441,7 +1440,6 @@ test('skips stale message on issues when skip-stale-issue-message is set', async
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -1467,11 +1465,55 @@ test('skips stale message on issues when skip-stale-issue-message is set', async
|
||||
);
|
||||
});
|
||||
|
||||
test('skips stale message on prs when skip-stale-pr-message is set', async () => {
|
||||
test('send stale message on issues when stale-issue-message is not empty', async () => {
|
||||
const opts = {...DefaultProcessorOptions};
|
||||
opts.daysBeforeStale = 5; // stale after 5 days
|
||||
opts.daysBeforeClose = 20; // closes after 25 days
|
||||
opts.skipStalePrMessage = true;
|
||||
opts.staleIssueMessage = 'dummy issue message';
|
||||
const lastUpdate = new Date();
|
||||
lastUpdate.setDate(lastUpdate.getDate() - 10);
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(
|
||||
opts,
|
||||
1,
|
||||
'An issue that should be marked stale but not closed',
|
||||
lastUpdate.toString(),
|
||||
lastUpdate.toString(),
|
||||
false
|
||||
)
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
);
|
||||
|
||||
// for sake of testing, mocking private function
|
||||
const markSpy = jest.spyOn(processor as any, '_markStale');
|
||||
|
||||
await processor.processIssues(1);
|
||||
|
||||
// issue should be staled
|
||||
expect(processor.closedIssues).toHaveLength(0);
|
||||
expect(processor.removedLabelIssues).toHaveLength(0);
|
||||
expect(processor.staleIssues).toHaveLength(1);
|
||||
|
||||
// comment should not be created
|
||||
expect(markSpy).toHaveBeenCalledWith(
|
||||
TestIssueList[0],
|
||||
opts.staleIssueMessage,
|
||||
opts.staleIssueLabel,
|
||||
// this option is skipMessage
|
||||
false
|
||||
);
|
||||
});
|
||||
|
||||
test('skips stale message on prs when stale-pr-message is empty', async () => {
|
||||
const opts = {...DefaultProcessorOptions};
|
||||
opts.daysBeforeStale = 5; // stale after 5 days
|
||||
opts.daysBeforeClose = 20; // closes after 25 days
|
||||
opts.stalePrMessage = '';
|
||||
const lastUpdate = new Date();
|
||||
lastUpdate.setDate(lastUpdate.getDate() - 10);
|
||||
const TestIssueList: Issue[] = [
|
||||
@@ -1486,7 +1528,6 @@ test('skips stale message on prs when skip-stale-pr-message is set', async () =>
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -1512,46 +1553,11 @@ test('skips stale message on prs when skip-stale-pr-message is set', async () =>
|
||||
);
|
||||
});
|
||||
|
||||
test('not providing state takes precedence over skipStaleIssueMessage', async () => {
|
||||
test('send stale message on prs when stale-pr-message is not empty', async () => {
|
||||
const opts = {...DefaultProcessorOptions};
|
||||
opts.daysBeforeStale = 5; // stale after 5 days
|
||||
opts.daysBeforeClose = 20; // closes after 25 days
|
||||
opts.skipStalePrMessage = true;
|
||||
opts.staleIssueMessage = '';
|
||||
const lastUpdate = new Date();
|
||||
lastUpdate.setDate(lastUpdate.getDate() - 10);
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(
|
||||
opts,
|
||||
1,
|
||||
'An issue that should be marked stale but not closed',
|
||||
lastUpdate.toString(),
|
||||
lastUpdate.toString(),
|
||||
false
|
||||
)
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
);
|
||||
|
||||
await processor.processIssues(1);
|
||||
|
||||
// issue should be staled
|
||||
expect(processor.closedIssues).toHaveLength(0);
|
||||
expect(processor.removedLabelIssues).toHaveLength(0);
|
||||
expect(processor.staleIssues).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('not providing stalePrMessage takes precedence over skipStalePrMessage', async () => {
|
||||
const opts = {...DefaultProcessorOptions};
|
||||
opts.daysBeforeStale = 5; // stale after 5 days
|
||||
opts.daysBeforeClose = 20; // closes after 25 days
|
||||
opts.skipStalePrMessage = true;
|
||||
opts.stalePrMessage = '';
|
||||
opts.stalePrMessage = 'dummy pr message';
|
||||
const lastUpdate = new Date();
|
||||
lastUpdate.setDate(lastUpdate.getDate() - 10);
|
||||
const TestIssueList: Issue[] = [
|
||||
@@ -1566,18 +1572,29 @@ test('not providing stalePrMessage takes precedence over skipStalePrMessage', as
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
);
|
||||
|
||||
// for sake of testing, mocking private function
|
||||
const markSpy = jest.spyOn(processor as any, '_markStale');
|
||||
|
||||
await processor.processIssues(1);
|
||||
|
||||
// issue should be staled
|
||||
expect(processor.closedIssues).toHaveLength(0);
|
||||
expect(processor.removedLabelIssues).toHaveLength(0);
|
||||
expect(processor.staleIssues).toHaveLength(0);
|
||||
expect(processor.staleIssues).toHaveLength(1);
|
||||
|
||||
// comment should not be created
|
||||
expect(markSpy).toHaveBeenCalledWith(
|
||||
TestIssueList[0],
|
||||
opts.stalePrMessage,
|
||||
opts.stalePrLabel,
|
||||
// this option is skipMessage
|
||||
false
|
||||
);
|
||||
});
|
||||
|
||||
test('git branch is deleted when option is enabled', async () => {
|
||||
@@ -1596,7 +1613,6 @@ test('git branch is deleted when option is enabled', async () => {
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -1626,7 +1642,6 @@ test('git branch is not deleted when issue is not pull request', async () => {
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -1658,7 +1673,6 @@ test('an issue without a milestone will be marked as stale', async () => {
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
DefaultProcessorOptions,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -1692,7 +1706,6 @@ test('an issue without an exempted milestone will be marked as stale', async ()
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -1726,7 +1739,6 @@ test('an issue with an exempted milestone will not be marked as stale', async ()
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -1760,7 +1772,6 @@ test('an issue with an exempted milestone will not be marked as stale (multi mil
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -1794,7 +1805,6 @@ test('an issue with an exempted milestone will not be marked as stale (multi mil
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -1829,7 +1839,6 @@ test('an issue with an exempted milestone but without an exempted issue mileston
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -1864,7 +1873,6 @@ test('an issue with an exempted milestone but with another exempted issue milest
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -1899,7 +1907,6 @@ test('an issue with an exempted milestone and with an exempted issue milestone w
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -1927,7 +1934,6 @@ test('processing an issue opened since 2 days and with the option "daysBeforeIss
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -1954,7 +1960,6 @@ test('processing an issue opened since 2 days and with the option "daysBeforeIss
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -1981,7 +1986,6 @@ test('processing an issue opened since 2 days and with the option "daysBeforeIss
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -2015,7 +2019,6 @@ test('processing a pull request opened since 2 days and with the option "daysBef
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -2049,7 +2052,6 @@ test('processing a pull request opened since 2 days and with the option "daysBef
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -2083,7 +2085,6 @@ test('processing a pull request opened since 2 days and with the option "daysBef
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -2120,7 +2121,6 @@ test('processing a previously closed issue with a close label will remove the cl
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -2156,7 +2156,6 @@ test('processing a closed issue with a close label will not remove the close lab
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -2192,7 +2191,6 @@ test('processing a locked issue with a close label will not remove the close lab
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
@@ -2232,7 +2230,6 @@ test('processing an issue stale since less than the daysBeforeStale with a stale
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async (): Promise<IComment[]> => Promise.resolve([]),
|
||||
async () => labelCreatedAt.toDateString()
|
||||
@@ -2273,7 +2270,6 @@ test('processing an issue stale since less than the daysBeforeStale without a st
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async (): Promise<IComment[]> => Promise.resolve([]),
|
||||
async () => new Date().toDateString()
|
||||
@@ -2286,3 +2282,73 @@ test('processing an issue stale since less than the daysBeforeStale without a st
|
||||
expect(processor.deletedBranchIssues).toHaveLength(0);
|
||||
expect(processor.closedIssues).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('processing a pull request to be stale with the "stalePrMessage" option set will send a PR comment', async () => {
|
||||
expect.assertions(3);
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
stalePrMessage: 'This PR is stale',
|
||||
daysBeforeStale: 10,
|
||||
daysBeforePrStale: 1
|
||||
};
|
||||
const issueDate = new Date();
|
||||
issueDate.setDate(issueDate.getDate() - 2);
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(
|
||||
opts,
|
||||
1,
|
||||
'A pull request with no label and a stale message',
|
||||
issueDate.toDateString(),
|
||||
issueDate.toDateString(),
|
||||
true
|
||||
)
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
);
|
||||
|
||||
// process our fake issue list
|
||||
await processor.processIssues(1);
|
||||
|
||||
expect(processor.staleIssues).toHaveLength(1);
|
||||
expect(processor.closedIssues).toHaveLength(0);
|
||||
expect(processor.statistics?.addedPullRequestsCommentsCount).toStrictEqual(1);
|
||||
});
|
||||
|
||||
test('processing a pull request to be stale with the "stalePrMessage" option set to empty will not send a PR comment', async () => {
|
||||
expect.assertions(3);
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
stalePrMessage: '',
|
||||
daysBeforeStale: 10,
|
||||
daysBeforePrStale: 1
|
||||
};
|
||||
const issueDate = new Date();
|
||||
issueDate.setDate(issueDate.getDate() - 2);
|
||||
const TestIssueList: Issue[] = [
|
||||
generateIssue(
|
||||
opts,
|
||||
1,
|
||||
'A pull request with no label and a stale message',
|
||||
issueDate.toDateString(),
|
||||
issueDate.toDateString(),
|
||||
true
|
||||
)
|
||||
];
|
||||
const processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async p => (p === 1 ? TestIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
);
|
||||
|
||||
// process our fake issue list
|
||||
await processor.processIssues(1);
|
||||
|
||||
expect(processor.staleIssues).toHaveLength(1);
|
||||
expect(processor.closedIssues).toHaveLength(0);
|
||||
expect(processor.statistics?.addedPullRequestsCommentsCount).toStrictEqual(0);
|
||||
});
|
||||
|
||||
@@ -39,7 +39,6 @@ describe('milestones options', (): void => {
|
||||
const setProcessor = () => {
|
||||
processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? testIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
|
||||
@@ -8,7 +8,7 @@ import {generateIssue} from './functions/generate-issue';
|
||||
let issuesProcessorBuilder: IssuesProcessorBuilder;
|
||||
let issuesProcessor: IssuesProcessorMock;
|
||||
|
||||
describe('only-labels option', (): void => {
|
||||
describe('only-labels options', (): void => {
|
||||
beforeEach((): void => {
|
||||
issuesProcessorBuilder = new IssuesProcessorBuilder();
|
||||
});
|
||||
@@ -1112,14 +1112,12 @@ class IssuesProcessorBuilder {
|
||||
|
||||
issues(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
|
||||
this.issuesOrPrs(
|
||||
issues.map(
|
||||
(issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
|
||||
return {
|
||||
...issue,
|
||||
pull_request: null
|
||||
};
|
||||
}
|
||||
)
|
||||
issues.map((issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
|
||||
return {
|
||||
...issue,
|
||||
pull_request: null
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
return this;
|
||||
@@ -1127,14 +1125,12 @@ class IssuesProcessorBuilder {
|
||||
|
||||
prs(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
|
||||
this.issuesOrPrs(
|
||||
issues.map(
|
||||
(issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
|
||||
return {
|
||||
...issue,
|
||||
pull_request: {key: 'value'}
|
||||
};
|
||||
}
|
||||
)
|
||||
issues.map((issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
|
||||
return {
|
||||
...issue,
|
||||
pull_request: {key: 'value'}
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
return this;
|
||||
@@ -1143,7 +1139,6 @@ class IssuesProcessorBuilder {
|
||||
build(): IssuesProcessorMock {
|
||||
return new IssuesProcessorMock(
|
||||
this._options,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? this._issues : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
|
||||
227
__tests__/operations-per-run.spec.ts
Normal file
227
__tests__/operations-per-run.spec.ts
Normal file
@@ -0,0 +1,227 @@
|
||||
import {Issue} from '../src/classes/issue';
|
||||
import {IIssuesProcessorOptions} from '../src/interfaces/issues-processor-options';
|
||||
import {IsoDateString} from '../src/types/iso-date-string';
|
||||
import {IssuesProcessorMock} from './classes/issues-processor-mock';
|
||||
import {DefaultProcessorOptions} from './constants/default-processor-options';
|
||||
import {generateIssue} from './functions/generate-issue';
|
||||
|
||||
describe('operations-per-run option', (): void => {
|
||||
let sut: SUT;
|
||||
|
||||
beforeEach((): void => {
|
||||
sut = new SUT();
|
||||
});
|
||||
|
||||
describe('when one issue should be stale within 10 days and updated 20 days ago', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.staleIn(10).newIssue().updated(20);
|
||||
});
|
||||
|
||||
describe('when the operations per run option is set to 1', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.operationsPerRun(1);
|
||||
});
|
||||
|
||||
it('should consume 1 operation (stale label)', async () => {
|
||||
expect.assertions(2);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(1);
|
||||
expect(
|
||||
sut.processor.operations.getConsumedOperationsCount()
|
||||
).toStrictEqual(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when one issue should be stale within 10 days and updated 20 days ago and a comment should be added when stale', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.staleIn(10).commentOnStale().newIssue().updated(20);
|
||||
});
|
||||
|
||||
describe('when the operations per run option is set to 2', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.operationsPerRun(2);
|
||||
});
|
||||
|
||||
it('should consume 2 operations (stale label, comment)', async () => {
|
||||
expect.assertions(2);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(1);
|
||||
expect(
|
||||
sut.processor.operations.getConsumedOperationsCount()
|
||||
).toStrictEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
// Special case were we continue the issue processing even if the operations per run is reached
|
||||
describe('when the operations per run option is set to 1', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.operationsPerRun(1);
|
||||
});
|
||||
|
||||
it('should consume 2 operations (stale label, comment)', async () => {
|
||||
expect.assertions(2);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(1);
|
||||
expect(
|
||||
sut.processor.operations.getConsumedOperationsCount()
|
||||
).toStrictEqual(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when two issues should be stale within 10 days and updated 20 days ago and a comment should be added when stale', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.staleIn(10).commentOnStale();
|
||||
sut.newIssue().updated(20);
|
||||
sut.newIssue().updated(20);
|
||||
});
|
||||
|
||||
describe('when the operations per run option is set to 3', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.operationsPerRun(3);
|
||||
});
|
||||
|
||||
it('should consume 4 operations (stale label, comment)', async () => {
|
||||
expect.assertions(2);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(2);
|
||||
expect(
|
||||
sut.processor.operations.getConsumedOperationsCount()
|
||||
).toStrictEqual(4);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the operations per run option is set to 2', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.operationsPerRun(2);
|
||||
});
|
||||
|
||||
it('should consume 2 operations (stale label, comment) and stop', async () => {
|
||||
expect.assertions(2);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(1);
|
||||
expect(
|
||||
sut.processor.operations.getConsumedOperationsCount()
|
||||
).toStrictEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
// Special case were we continue the issue processing even if the operations per run is reached
|
||||
describe('when the operations per run option is set to 1', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.operationsPerRun(1);
|
||||
});
|
||||
|
||||
it('should consume 2 operations (stale label, comment) and stop', async () => {
|
||||
expect.assertions(2);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(1);
|
||||
expect(
|
||||
sut.processor.operations.getConsumedOperationsCount()
|
||||
).toStrictEqual(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
class SUT {
|
||||
processor!: IssuesProcessorMock;
|
||||
private _opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
staleIssueMessage: ''
|
||||
};
|
||||
private _testIssueList: Issue[] = [];
|
||||
private _sutIssues: SUTIssue[] = [];
|
||||
|
||||
newIssue(): SUTIssue {
|
||||
const sutIssue: SUTIssue = new SUTIssue();
|
||||
this._sutIssues.push(sutIssue);
|
||||
|
||||
return sutIssue;
|
||||
}
|
||||
|
||||
staleIn(days: number): SUT {
|
||||
this._updateOptions({
|
||||
daysBeforeIssueStale: days
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
commentOnStale(): SUT {
|
||||
this._updateOptions({
|
||||
staleIssueMessage: 'Dummy stale issue message'
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
operationsPerRun(count: number): SUT {
|
||||
this._updateOptions({
|
||||
operationsPerRun: count
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
async test(): Promise<number> {
|
||||
return this._setTestIssueList()._setProcessor();
|
||||
}
|
||||
|
||||
private _updateOptions(opts: Partial<IIssuesProcessorOptions>): SUT {
|
||||
this._opts = {...this._opts, ...opts};
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private _setTestIssueList(): SUT {
|
||||
this._testIssueList = this._sutIssues.map((sutIssue: SUTIssue): Issue => {
|
||||
return generateIssue(
|
||||
this._opts,
|
||||
1,
|
||||
'My first issue',
|
||||
sutIssue.updatedAt,
|
||||
sutIssue.updatedAt,
|
||||
false
|
||||
);
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private async _setProcessor(): Promise<number> {
|
||||
this.processor = new IssuesProcessorMock(
|
||||
this._opts,
|
||||
async p => (p === 1 ? this._testIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
);
|
||||
|
||||
return this.processor.processIssues(1);
|
||||
}
|
||||
}
|
||||
|
||||
class SUTIssue {
|
||||
updatedAt: IsoDateString = '2020-01-01T17:00:00Z';
|
||||
|
||||
updated(daysAgo: number): SUTIssue {
|
||||
const today = new Date();
|
||||
today.setDate(today.getDate() - daysAgo);
|
||||
this.updatedAt = today.toISOString();
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -464,14 +464,12 @@ class IssuesProcessorBuilder {
|
||||
|
||||
issues(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
|
||||
this.issuesOrPrs(
|
||||
issues.map(
|
||||
(issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
|
||||
return {
|
||||
...issue,
|
||||
pull_request: null
|
||||
};
|
||||
}
|
||||
)
|
||||
issues.map((issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
|
||||
return {
|
||||
...issue,
|
||||
pull_request: null
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
return this;
|
||||
@@ -479,27 +477,23 @@ class IssuesProcessorBuilder {
|
||||
|
||||
staleIssues(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
|
||||
this.issues(
|
||||
issues.map(
|
||||
(issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
|
||||
return {
|
||||
...issue,
|
||||
updated_at: '2020-01-01T17:00:00Z',
|
||||
created_at: '2020-01-01T17:00:00Z',
|
||||
labels: issue.labels?.map(
|
||||
(label: Readonly<ILabel>): ILabel => {
|
||||
return {
|
||||
...label,
|
||||
name: 'Stale'
|
||||
};
|
||||
}
|
||||
) ?? [
|
||||
{
|
||||
name: 'Stale'
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
)
|
||||
issues.map((issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
|
||||
return {
|
||||
...issue,
|
||||
updated_at: '2020-01-01T17:00:00Z',
|
||||
created_at: '2020-01-01T17:00:00Z',
|
||||
labels: issue.labels?.map((label: Readonly<ILabel>): ILabel => {
|
||||
return {
|
||||
...label,
|
||||
name: 'Stale'
|
||||
};
|
||||
}) ?? [
|
||||
{
|
||||
name: 'Stale'
|
||||
}
|
||||
]
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
return this;
|
||||
@@ -507,14 +501,12 @@ class IssuesProcessorBuilder {
|
||||
|
||||
prs(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
|
||||
this.issuesOrPrs(
|
||||
issues.map(
|
||||
(issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
|
||||
return {
|
||||
...issue,
|
||||
pull_request: {key: 'value'}
|
||||
};
|
||||
}
|
||||
)
|
||||
issues.map((issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
|
||||
return {
|
||||
...issue,
|
||||
pull_request: {key: 'value'}
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
return this;
|
||||
@@ -522,27 +514,23 @@ class IssuesProcessorBuilder {
|
||||
|
||||
stalePrs(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
|
||||
this.prs(
|
||||
issues.map(
|
||||
(issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
|
||||
return {
|
||||
...issue,
|
||||
updated_at: '2020-01-01T17:00:00Z',
|
||||
created_at: '2020-01-01T17:00:00Z',
|
||||
labels: issue.labels?.map(
|
||||
(label: Readonly<ILabel>): ILabel => {
|
||||
return {
|
||||
...label,
|
||||
name: 'Stale'
|
||||
};
|
||||
}
|
||||
) ?? [
|
||||
{
|
||||
name: 'Stale'
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
)
|
||||
issues.map((issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
|
||||
return {
|
||||
...issue,
|
||||
updated_at: '2020-01-01T17:00:00Z',
|
||||
created_at: '2020-01-01T17:00:00Z',
|
||||
labels: issue.labels?.map((label: Readonly<ILabel>): ILabel => {
|
||||
return {
|
||||
...label,
|
||||
name: 'Stale'
|
||||
};
|
||||
}) ?? [
|
||||
{
|
||||
name: 'Stale'
|
||||
}
|
||||
]
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
return this;
|
||||
@@ -551,14 +539,14 @@ class IssuesProcessorBuilder {
|
||||
build(): IssuesProcessorMock {
|
||||
return new IssuesProcessorMock(
|
||||
this._options,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? this._issues : []),
|
||||
async () => [
|
||||
{
|
||||
user: {
|
||||
login: 'notme',
|
||||
type: 'User'
|
||||
}
|
||||
},
|
||||
body: 'body'
|
||||
}
|
||||
],
|
||||
async () => new Date().toDateString()
|
||||
|
||||
696
__tests__/updates-reset-stale.spec.ts
Normal file
696
__tests__/updates-reset-stale.spec.ts
Normal file
@@ -0,0 +1,696 @@
|
||||
import {Issue} from '../src/classes/issue';
|
||||
import {IIssuesProcessorOptions} from '../src/interfaces/issues-processor-options';
|
||||
import {IsoDateString} from '../src/types/iso-date-string';
|
||||
import {IssuesProcessorMock} from './classes/issues-processor-mock';
|
||||
import {DefaultProcessorOptions} from './constants/default-processor-options';
|
||||
import {generateIssue} from './functions/generate-issue';
|
||||
|
||||
describe('ignore-updates options', (): void => {
|
||||
let sut: SUT;
|
||||
|
||||
beforeEach((): void => {
|
||||
sut = new SUT();
|
||||
});
|
||||
|
||||
describe('when the issue should be stale within 10 days and was created 20 days ago and updated 5 days ago', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.toIssue().staleIn(10).created(20).updated(5);
|
||||
});
|
||||
|
||||
describe('when the ignore updates option is disabled', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.staleOnUpdates();
|
||||
});
|
||||
|
||||
it('should not stale the issue', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(0);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
|
||||
describe('when the ignore issue updates option is enabled', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.ignoreIssueUpdates();
|
||||
});
|
||||
|
||||
it('should stale the issue', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(1);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the ignore issue updates option is disabled', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.staleOnIssueUpdates();
|
||||
});
|
||||
|
||||
it('should not stale the issue', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(0);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the ignore issue updates option is unset', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.unsetIgnoreIssueUpdates();
|
||||
});
|
||||
|
||||
it('should not stale the issue', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(0);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the ignore updates option is enabled', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.ignoreUpdates();
|
||||
});
|
||||
|
||||
it('should stale the issue', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(1);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
|
||||
describe('when the ignore issue updates option is enabled', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.ignoreIssueUpdates();
|
||||
});
|
||||
|
||||
it('should stale the issue', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(1);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the ignore issue updates option is disabled', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.staleOnIssueUpdates();
|
||||
});
|
||||
|
||||
it('should not stale the issue', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(0);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the ignore issue updates option is unset', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.unsetIgnoreIssueUpdates();
|
||||
});
|
||||
|
||||
it('should stale the issue', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(1);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the issue should be stale within 10 days and was created 20 days ago and updated 15 days ago', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.toIssue().staleIn(10).created(20).updated(15);
|
||||
});
|
||||
|
||||
describe('when the ignore updates option is disabled', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.staleOnUpdates();
|
||||
});
|
||||
|
||||
it('should stale the issue', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(1);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
|
||||
describe('when the ignore issue updates option is enabled', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.ignoreIssueUpdates();
|
||||
});
|
||||
|
||||
it('should stale the issue', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(1);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the ignore issue updates option is disabled', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.staleOnIssueUpdates();
|
||||
});
|
||||
|
||||
it('should stale the issue', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(1);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the ignore issue updates option is unset', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.unsetIgnoreIssueUpdates();
|
||||
});
|
||||
|
||||
it('should stale the issue', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(1);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the ignore updates option is enabled', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.ignoreUpdates();
|
||||
});
|
||||
|
||||
it('should stale the issue', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(1);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
|
||||
describe('when the ignore issue updates option is enabled', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.ignoreIssueUpdates();
|
||||
});
|
||||
|
||||
it('should stale the issue', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(1);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the ignore issue updates option is disabled', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.staleOnIssueUpdates();
|
||||
});
|
||||
|
||||
it('should stale the issue', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(1);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the ignore issue updates option is unset', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.unsetIgnoreIssueUpdates();
|
||||
});
|
||||
|
||||
it('should stale the issue', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(1);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the pull request should be stale within 10 days and was created 20 days ago and updated 5 days ago', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.toPullRequest().staleIn(10).created(20).updated(5);
|
||||
});
|
||||
|
||||
describe('when the ignore updates option is disabled', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.staleOnUpdates();
|
||||
});
|
||||
|
||||
it('should not stale the pull request', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(0);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
|
||||
describe('when the ignore pull request updates option is enabled', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.ignorePullRequestUpdates();
|
||||
});
|
||||
|
||||
it('should stale the pull request', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(1);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the ignore pull request updates option is disabled', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.staleOnPullRequestUpdates();
|
||||
});
|
||||
|
||||
it('should not stale the pull request', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(0);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the ignore pull request updates option is unset', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.unsetIgnorePullRequestUpdates();
|
||||
});
|
||||
|
||||
it('should not stale the pull request', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(0);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the ignore updates option is enabled', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.ignoreUpdates();
|
||||
});
|
||||
|
||||
it('should stale the pull request', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(1);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
|
||||
describe('when the ignore pull request updates option is enabled', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.ignorePullRequestUpdates();
|
||||
});
|
||||
|
||||
it('should stale the pull request', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(1);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the ignore pull request updates option is disabled', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.staleOnPullRequestUpdates();
|
||||
});
|
||||
|
||||
it('should not stale the pull request', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(0);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the ignore pull request updates option is unset', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.unsetIgnorePullRequestUpdates();
|
||||
});
|
||||
|
||||
it('should stale the pull request', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(1);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the pull request should be stale within 10 days and was created 20 days ago and updated 15 days ago', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.toPullRequest().staleIn(10).created(20).updated(15);
|
||||
});
|
||||
|
||||
describe('when the ignore updates option is disabled', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.staleOnUpdates();
|
||||
});
|
||||
|
||||
it('should stale the pull request', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(1);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
|
||||
describe('when the ignore pull request updates option is enabled', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.ignorePullRequestUpdates();
|
||||
});
|
||||
|
||||
it('should stale the pull request', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(1);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the ignore pull request updates option is disabled', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.staleOnPullRequestUpdates();
|
||||
});
|
||||
|
||||
it('should stale the pull request', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(1);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the ignore pull request updates option is unset', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.unsetIgnorePullRequestUpdates();
|
||||
});
|
||||
|
||||
it('should stale the pull request', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(1);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the ignore updates option is enabled', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.ignoreUpdates();
|
||||
});
|
||||
|
||||
it('should stale the pull request', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(1);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
|
||||
describe('when the ignore pull request updates option is enabled', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.ignorePullRequestUpdates();
|
||||
});
|
||||
|
||||
it('should stale the pull request', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(1);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the ignore pull request updates option is disabled', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.staleOnPullRequestUpdates();
|
||||
});
|
||||
|
||||
it('should stale the pull request', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(1);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the ignore pull request updates option is unset', (): void => {
|
||||
beforeEach((): void => {
|
||||
sut.unsetIgnorePullRequestUpdates();
|
||||
});
|
||||
|
||||
it('should stale the pull request', async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
await sut.test();
|
||||
|
||||
expect(sut.processor.staleIssues).toHaveLength(1);
|
||||
expect(sut.processor.closedIssues).toHaveLength(0);
|
||||
expect(sut.processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
class SUT {
|
||||
processor!: IssuesProcessorMock;
|
||||
private _opts: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||
private _isPullRequest = false;
|
||||
private _createdAt: IsoDateString = '2020-01-01T17:00:00Z';
|
||||
private _updatedAt: IsoDateString = '2020-01-01T17:00:00Z';
|
||||
private _testIssueList: Issue[] = [];
|
||||
|
||||
toIssue(): SUT {
|
||||
this._isPullRequest = false;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
toPullRequest(): SUT {
|
||||
this._isPullRequest = true;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
staleIn(days: number): SUT {
|
||||
this._updateOptions({
|
||||
daysBeforeIssueStale: days,
|
||||
daysBeforePrStale: days
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
created(daysAgo: number): SUT {
|
||||
const today = new Date();
|
||||
today.setDate(today.getDate() - daysAgo);
|
||||
this._createdAt = today.toISOString();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
updated(daysAgo: number): SUT {
|
||||
const today = new Date();
|
||||
today.setDate(today.getDate() - daysAgo);
|
||||
this._updatedAt = today.toISOString();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
ignoreUpdates(): SUT {
|
||||
this._updateOptions({
|
||||
ignoreUpdates: true
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
staleOnUpdates(): SUT {
|
||||
this._updateOptions({
|
||||
ignoreUpdates: false
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
ignoreIssueUpdates(): SUT {
|
||||
this._updateOptions({
|
||||
ignoreIssueUpdates: true
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
staleOnIssueUpdates(): SUT {
|
||||
this._updateOptions({
|
||||
ignoreIssueUpdates: false
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
unsetIgnoreIssueUpdates(): SUT {
|
||||
this._updateOptions({
|
||||
ignoreIssueUpdates: undefined
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
ignorePullRequestUpdates(): SUT {
|
||||
this._updateOptions({
|
||||
ignorePrUpdates: true
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
staleOnPullRequestUpdates(): SUT {
|
||||
this._updateOptions({
|
||||
ignorePrUpdates: false
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
unsetIgnorePullRequestUpdates(): SUT {
|
||||
this._updateOptions({
|
||||
ignorePrUpdates: undefined
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
async test(): Promise<number> {
|
||||
return this._setTestIssueList()._setProcessor();
|
||||
}
|
||||
|
||||
private _updateOptions(opts: Partial<IIssuesProcessorOptions>): SUT {
|
||||
this._opts = {...this._opts, ...opts};
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private _setTestIssueList(): SUT {
|
||||
this._testIssueList = [
|
||||
generateIssue(
|
||||
this._opts,
|
||||
1,
|
||||
'My first issue',
|
||||
this._updatedAt,
|
||||
this._createdAt,
|
||||
this._isPullRequest
|
||||
)
|
||||
];
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private async _setProcessor(): Promise<number> {
|
||||
this.processor = new IssuesProcessorMock(
|
||||
this._opts,
|
||||
async p => (p === 1 ? this._testIssueList : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString()
|
||||
);
|
||||
|
||||
return this.processor.processIssues(1);
|
||||
}
|
||||
}
|
||||
43
action.yml
43
action.yml
@@ -118,11 +118,11 @@ inputs:
|
||||
required: false
|
||||
remove-issue-stale-when-updated:
|
||||
description: 'Remove stale labels from issues when they are updated or commented on. Override "remove-stale-when-updated" option regarding only the issues.'
|
||||
default: 'true'
|
||||
default: ''
|
||||
required: false
|
||||
remove-pr-stale-when-updated:
|
||||
description: 'Remove stale labels from pull requests when they are updated or commented on. Override "remove-stale-when-updated" option regarding only the pull requests.'
|
||||
default: 'true'
|
||||
default: ''
|
||||
required: false
|
||||
debug-only:
|
||||
description: 'Run the processor in debug mode without actually performing any operations on live issues.'
|
||||
@@ -132,14 +132,6 @@ inputs:
|
||||
description: 'The order to get issues or pull requests. Defaults to false, which is descending.'
|
||||
default: 'false'
|
||||
required: false
|
||||
skip-stale-pr-message:
|
||||
description: 'Skip adding stale message when marking a pull request as stale.'
|
||||
default: 'false'
|
||||
required: false
|
||||
skip-stale-issue-message:
|
||||
description: 'Skip adding stale message when marking an issue as stale.'
|
||||
default: 'false'
|
||||
required: false
|
||||
delete-branch:
|
||||
description: 'Delete the git branch after closing a stale pull request.'
|
||||
default: 'false'
|
||||
@@ -172,10 +164,39 @@ inputs:
|
||||
description: 'Exempt all pull requests with assignees from being marked as stale. Override "exempt-all-assignees" option regarding only the pull requests.'
|
||||
default: ''
|
||||
required: false
|
||||
exempt-draft-pr:
|
||||
description: 'Exempt draft pull requests from being marked as stale. Default to false.'
|
||||
default: 'false'
|
||||
required: false
|
||||
enable-statistics:
|
||||
description: 'Display some statistics at the end regarding the stale workflow (only when the logs are enabled).'
|
||||
default: 'true'
|
||||
required: false
|
||||
labels-to-add-when-unstale:
|
||||
description: 'A comma delimited list of labels to add when a stale issue or pull request receives activity and has the stale-issue-label or stale-pr-label removed from it.'
|
||||
default: ''
|
||||
required: false
|
||||
labels-to-remove-when-unstale:
|
||||
description: 'A comma delimited list of labels to remove when a stale issue or pull request receives activity and has the stale-issue-label or stale-pr-label removed from it.'
|
||||
default: ''
|
||||
required: false
|
||||
ignore-updates:
|
||||
description: 'Any update (update/comment) can reset the stale idle time on the issues and pull requests.'
|
||||
default: 'false'
|
||||
required: false
|
||||
ignore-issue-updates:
|
||||
description: 'Any update (update/comment) can reset the stale idle time on the issues. Override "ignore-updates" option regarding only the issues.'
|
||||
default: ''
|
||||
required: false
|
||||
ignore-pr-updates:
|
||||
description: 'Any update (update/comment) can reset the stale idle time on the pull requests. Override "ignore-updates" option regarding only the pull requests.'
|
||||
default: ''
|
||||
required: false
|
||||
outputs:
|
||||
closed-issues-prs:
|
||||
description: 'List of all closed issues and pull requests.'
|
||||
staled-issues-prs:
|
||||
description: 'List of all staled issues and pull requests.'
|
||||
runs:
|
||||
using: 'node12'
|
||||
using: 'node16'
|
||||
main: 'dist/index.js'
|
||||
|
||||
3376
dist/index.js
vendored
3376
dist/index.js
vendored
File diff suppressed because it is too large
Load Diff
@@ -7,6 +7,5 @@ module.exports = {
|
||||
transform: {
|
||||
'^.+\\.ts$': 'ts-jest'
|
||||
},
|
||||
verbose: true,
|
||||
setupFilesAfterEnv: [`./jest/test.ts`]
|
||||
verbose: true
|
||||
};
|
||||
|
||||
11
jest/test.ts
11
jest/test.ts
@@ -1,11 +0,0 @@
|
||||
import chalk from 'chalk';
|
||||
|
||||
// Disabled the colors to:
|
||||
// - improve the performances
|
||||
// - avoid to mock chalk
|
||||
// - avoid to have failing tests when testing the logs due to the extra text the log message will contains
|
||||
//
|
||||
// Note:
|
||||
// If you need to debug the log colours you can remove this line temporarily
|
||||
// But some tests will fail
|
||||
chalk.level = 0;
|
||||
8884
package-lock.json
generated
8884
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
43
package.json
43
package.json
@@ -6,8 +6,8 @@
|
||||
"main": "lib/main.js",
|
||||
"scripts": {
|
||||
"build": "tsc --project tsconfig.app.json",
|
||||
"format": "prettier --write --ignore-unknown **/*.{md,json,yml,ts}",
|
||||
"format-check": "prettier --check --ignore-unknown **/*.{md,json,yml,ts}",
|
||||
"format": "prettier --write --ignore-unknown **/*.{json,yml,ts}",
|
||||
"format-check": "prettier --check --ignore-unknown **/*.{json,yml,ts}",
|
||||
"lint": "eslint src/**/*.ts",
|
||||
"lint:fix": "eslint src/**/*.ts --fix",
|
||||
"lint:all": "npm run format-check && npm run lint",
|
||||
@@ -16,7 +16,11 @@
|
||||
"test": "jest",
|
||||
"test:only-errors": "jest --reporters jest-silent-reporter --silent",
|
||||
"test:watch": "jest --watch --notify --expand",
|
||||
"all": "npm run build && npm run format && npm run lint && npm run pack && npm test"
|
||||
"all": "npm run build && npm run format && npm run lint && npm run pack && npm test",
|
||||
"all:ci": "npm run build && npm run lint:all && npm run pack && npm run test:only-errors",
|
||||
"prerelease": "npm run build && npm run pack",
|
||||
"release": "standard-version",
|
||||
"release:dry-run": "standard-version --dry-run"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -27,6 +31,10 @@
|
||||
"node",
|
||||
"stale"
|
||||
],
|
||||
"engines": {
|
||||
"node": "12",
|
||||
"npm": "6"
|
||||
},
|
||||
"author": "GitHub",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -36,24 +44,25 @@
|
||||
"semver": "^7.3.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^26.0.20",
|
||||
"@types/jest": "^27.0.2",
|
||||
"@types/lodash.deburr": "^4.1.6",
|
||||
"@types/node": "^15.0.2",
|
||||
"@types/semver": "^7.3.5",
|
||||
"@typescript-eslint/eslint-plugin": "^4.16.1",
|
||||
"@typescript-eslint/parser": "^4.22.1",
|
||||
"@vercel/ncc": "^0.27.0",
|
||||
"chalk": "^4.1.0",
|
||||
"eslint": "^7.21.0",
|
||||
"@typescript-eslint/eslint-plugin": "^4.31.1",
|
||||
"@typescript-eslint/parser": "^4.31.1",
|
||||
"@vercel/ncc": "^0.28.6",
|
||||
"ansi-styles": "5.2.0",
|
||||
"eslint": "^7.28.0",
|
||||
"eslint-plugin-github": "^4.1.2",
|
||||
"eslint-plugin-jest": "^24.3.6",
|
||||
"jest": "^26.6.3",
|
||||
"jest-circus": "^26.6.3",
|
||||
"jest-silent-reporter": "^0.4.0",
|
||||
"js-yaml": "^4.0.0",
|
||||
"prettier": "^2.2.1",
|
||||
"eslint-plugin-jest": "^25.3.2",
|
||||
"jest": "^27.2.5",
|
||||
"jest-circus": "^27.4.6",
|
||||
"jest-silent-reporter": "^0.5.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
"prettier": "^2.5.1",
|
||||
"standard-version": "^9.3.1",
|
||||
"terminal-link": "^2.1.1",
|
||||
"ts-jest": "^26.5.3",
|
||||
"typescript": "^4.2.4"
|
||||
"ts-jest": "^27.1.2",
|
||||
"typescript": "^4.3.2"
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,19 +1,15 @@
|
||||
import chalk from 'chalk';
|
||||
import deburr from 'lodash.deburr';
|
||||
import {Option} from '../enums/option';
|
||||
import {wordsToList} from '../functions/words-to-list';
|
||||
import {IAssignee} from '../interfaces/assignee';
|
||||
import {Assignee} from '../interfaces/assignee';
|
||||
import {IIssuesProcessorOptions} from '../interfaces/issues-processor-options';
|
||||
import {Issue} from './issue';
|
||||
import {IssueLogger} from './loggers/issue-logger';
|
||||
import {LoggerService} from '../services/logger.service';
|
||||
|
||||
type CleanAssignee = string;
|
||||
|
||||
export class Assignees {
|
||||
private static _cleanAssignee(assignee: Readonly<string>): CleanAssignee {
|
||||
return deburr(assignee.toLowerCase());
|
||||
}
|
||||
|
||||
private readonly _options: IIssuesProcessorOptions;
|
||||
private readonly _issue: Issue;
|
||||
private readonly _issueLogger: IssueLogger;
|
||||
@@ -24,6 +20,10 @@ export class Assignees {
|
||||
this._issueLogger = new IssueLogger(issue);
|
||||
}
|
||||
|
||||
private static _cleanAssignee(assignee: Readonly<string>): CleanAssignee {
|
||||
return deburr(assignee.toLowerCase());
|
||||
}
|
||||
|
||||
shouldExemptAssignees(): boolean {
|
||||
if (!this._issue.hasAssignees) {
|
||||
this._issueLogger.info('This $$type has no assignee');
|
||||
@@ -34,7 +34,7 @@ export class Assignees {
|
||||
|
||||
if (this._shouldExemptAllAssignees()) {
|
||||
this._issueLogger.info(
|
||||
chalk.white('└──'),
|
||||
LoggerService.white('└──'),
|
||||
'Skipping this $$type because it has an exempt assignee'
|
||||
);
|
||||
|
||||
@@ -45,7 +45,7 @@ export class Assignees {
|
||||
|
||||
if (exemptAssignees.length === 0) {
|
||||
this._issueLogger.info(
|
||||
chalk.white('├──'),
|
||||
LoggerService.white('├──'),
|
||||
`No assignee option was specified to skip the stale process for this $$type`
|
||||
);
|
||||
this._logSkip();
|
||||
@@ -54,8 +54,8 @@ export class Assignees {
|
||||
}
|
||||
|
||||
this._issueLogger.info(
|
||||
chalk.white('├──'),
|
||||
`Found ${chalk.cyan(exemptAssignees.length)} assignee${
|
||||
LoggerService.white('├──'),
|
||||
`Found ${LoggerService.cyan(exemptAssignees.length)} assignee${
|
||||
exemptAssignees.length > 1 ? 's' : ''
|
||||
} that can exempt stale on this $$type`
|
||||
);
|
||||
@@ -67,13 +67,13 @@ export class Assignees {
|
||||
|
||||
if (!hasExemptAssignee) {
|
||||
this._issueLogger.info(
|
||||
chalk.white('├──'),
|
||||
LoggerService.white('├──'),
|
||||
'No assignee on this $$type can exempt the stale process'
|
||||
);
|
||||
this._logSkip();
|
||||
} else {
|
||||
this._issueLogger.info(
|
||||
chalk.white('└──'),
|
||||
LoggerService.white('└──'),
|
||||
'Skipping this $$type because it has an exempt assignee'
|
||||
);
|
||||
}
|
||||
@@ -90,7 +90,7 @@ export class Assignees {
|
||||
private _getExemptIssueAssignees(): string[] {
|
||||
if (this._options.exemptIssueAssignees === '') {
|
||||
this._issueLogger.info(
|
||||
chalk.white('├──'),
|
||||
LoggerService.white('├──'),
|
||||
`The option ${this._issueLogger.createOptionLink(
|
||||
Option.ExemptIssueAssignees
|
||||
)} is disabled. No specific assignee can skip the stale process for this $$type`
|
||||
@@ -98,7 +98,7 @@ export class Assignees {
|
||||
|
||||
if (this._options.exemptAssignees === '') {
|
||||
this._issueLogger.info(
|
||||
chalk.white('├──'),
|
||||
LoggerService.white('├──'),
|
||||
`The option ${this._issueLogger.createOptionLink(
|
||||
Option.ExemptAssignees
|
||||
)} is disabled. No specific assignee can skip the stale process for this $$type`
|
||||
@@ -112,10 +112,10 @@ export class Assignees {
|
||||
);
|
||||
|
||||
this._issueLogger.info(
|
||||
chalk.white('├──'),
|
||||
LoggerService.white('├──'),
|
||||
`The option ${this._issueLogger.createOptionLink(
|
||||
Option.ExemptAssignees
|
||||
)} is set. ${chalk.cyan(exemptAssignees.length)} assignee${
|
||||
)} is set. ${LoggerService.cyan(exemptAssignees.length)} assignee${
|
||||
exemptAssignees.length === 1 ? '' : 's'
|
||||
} can skip the stale process for this $$type`
|
||||
);
|
||||
@@ -128,10 +128,10 @@ export class Assignees {
|
||||
);
|
||||
|
||||
this._issueLogger.info(
|
||||
chalk.white('├──'),
|
||||
LoggerService.white('├──'),
|
||||
`The option ${this._issueLogger.createOptionLink(
|
||||
Option.ExemptIssueAssignees
|
||||
)} is set. ${chalk.cyan(exemptAssignees.length)} assignee${
|
||||
)} is set. ${LoggerService.cyan(exemptAssignees.length)} assignee${
|
||||
exemptAssignees.length === 1 ? '' : 's'
|
||||
} can skip the stale process for this $$type`
|
||||
);
|
||||
@@ -142,7 +142,7 @@ export class Assignees {
|
||||
private _getExemptPullRequestAssignees(): string[] {
|
||||
if (this._options.exemptPrAssignees === '') {
|
||||
this._issueLogger.info(
|
||||
chalk.white('├──'),
|
||||
LoggerService.white('├──'),
|
||||
`The option ${this._issueLogger.createOptionLink(
|
||||
Option.ExemptPrAssignees
|
||||
)} is disabled. No specific assignee can skip the stale process for this $$type`
|
||||
@@ -150,7 +150,7 @@ export class Assignees {
|
||||
|
||||
if (this._options.exemptAssignees === '') {
|
||||
this._issueLogger.info(
|
||||
chalk.white('├──'),
|
||||
LoggerService.white('├──'),
|
||||
`The option ${this._issueLogger.createOptionLink(
|
||||
Option.ExemptAssignees
|
||||
)} is disabled. No specific assignee can skip the stale process for this $$type`
|
||||
@@ -164,10 +164,10 @@ export class Assignees {
|
||||
);
|
||||
|
||||
this._issueLogger.info(
|
||||
chalk.white('├──'),
|
||||
LoggerService.white('├──'),
|
||||
`The option ${this._issueLogger.createOptionLink(
|
||||
Option.ExemptAssignees
|
||||
)} is set. ${chalk.cyan(exemptAssignees.length)} assignee${
|
||||
)} is set. ${LoggerService.cyan(exemptAssignees.length)} assignee${
|
||||
exemptAssignees.length === 1 ? '' : 's'
|
||||
} can skip the stale process for this $$type`
|
||||
);
|
||||
@@ -180,10 +180,10 @@ export class Assignees {
|
||||
);
|
||||
|
||||
this._issueLogger.info(
|
||||
chalk.white('├──'),
|
||||
LoggerService.white('├──'),
|
||||
`The option ${this._issueLogger.createOptionLink(
|
||||
Option.ExemptPrAssignees
|
||||
)} is set. ${chalk.cyan(exemptAssignees.length)} assignee${
|
||||
)} is set. ${LoggerService.cyan(exemptAssignees.length)} assignee${
|
||||
exemptAssignees.length === 1 ? '' : 's'
|
||||
} can skip the stale process for this $$type`
|
||||
);
|
||||
@@ -195,13 +195,13 @@ export class Assignees {
|
||||
const cleanAssignee: CleanAssignee = Assignees._cleanAssignee(assignee);
|
||||
|
||||
return this._issue.assignees.some(
|
||||
(issueAssignee: Readonly<IAssignee>): boolean => {
|
||||
(issueAssignee: Readonly<Assignee>): boolean => {
|
||||
const isSameAssignee: boolean =
|
||||
cleanAssignee === Assignees._cleanAssignee(issueAssignee.login);
|
||||
|
||||
if (isSameAssignee) {
|
||||
this._issueLogger.info(
|
||||
chalk.white('├──'),
|
||||
LoggerService.white('├──'),
|
||||
`@${issueAssignee.login} is assigned on this $$type and is an exempt assignee`
|
||||
);
|
||||
}
|
||||
@@ -282,6 +282,9 @@ export class Assignees {
|
||||
}
|
||||
|
||||
private _logSkip(): void {
|
||||
this._issueLogger.info(chalk.white('└──'), 'Skip the assignees checks');
|
||||
this._issueLogger.info(
|
||||
LoggerService.white('└──'),
|
||||
'Skip the assignees checks'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
51
src/classes/exempt-draft-pull-request.ts
Normal file
51
src/classes/exempt-draft-pull-request.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import {Option} from '../enums/option';
|
||||
import {IIssuesProcessorOptions} from '../interfaces/issues-processor-options';
|
||||
import {IPullRequest} from '../interfaces/pull-request';
|
||||
import {LoggerService} from '../services/logger.service';
|
||||
import {Issue} from './issue';
|
||||
import {IssueLogger} from './loggers/issue-logger';
|
||||
|
||||
export class ExemptDraftPullRequest {
|
||||
private readonly _options: IIssuesProcessorOptions;
|
||||
private readonly _issue: Issue;
|
||||
private readonly _issueLogger: IssueLogger;
|
||||
|
||||
constructor(options: Readonly<IIssuesProcessorOptions>, issue: Issue) {
|
||||
this._options = options;
|
||||
this._issue = issue;
|
||||
this._issueLogger = new IssueLogger(issue);
|
||||
}
|
||||
|
||||
async shouldExemptDraftPullRequest(
|
||||
pullRequestCallback: () => Promise<IPullRequest | undefined | void>
|
||||
): Promise<boolean> {
|
||||
if (this._issue.isPullRequest) {
|
||||
if (this._options.exemptDraftPr) {
|
||||
this._issueLogger.info(
|
||||
`The option ${this._issueLogger.createOptionLink(
|
||||
Option.ExemptDraftPr
|
||||
)} is enabled`
|
||||
);
|
||||
|
||||
const pullRequest: IPullRequest | undefined | void =
|
||||
await pullRequestCallback();
|
||||
|
||||
if (pullRequest?.draft === true) {
|
||||
this._issueLogger.info(
|
||||
LoggerService.white('└──'),
|
||||
`Skip the $$type draft checks`
|
||||
);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
this._issueLogger.info(
|
||||
LoggerService.white('└──'),
|
||||
`Continuing the process for this $$type because it is not a draft`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
251
src/classes/ignore-updates.spec.ts
Normal file
251
src/classes/ignore-updates.spec.ts
Normal file
@@ -0,0 +1,251 @@
|
||||
import {DefaultProcessorOptions} from '../../__tests__/constants/default-processor-options';
|
||||
import {generateIIssue} from '../../__tests__/functions/generate-iissue';
|
||||
import {IIssue} from '../interfaces/issue';
|
||||
import {IIssuesProcessorOptions} from '../interfaces/issues-processor-options';
|
||||
import {IgnoreUpdates} from './ignore-updates';
|
||||
import {Issue} from './issue';
|
||||
|
||||
describe('IgnoreUpdates', (): void => {
|
||||
let ignoreUpdates: IgnoreUpdates;
|
||||
let optionsInterface: IIssuesProcessorOptions;
|
||||
let issue: Issue;
|
||||
let issueInterface: IIssue;
|
||||
|
||||
beforeEach((): void => {
|
||||
optionsInterface = {
|
||||
...DefaultProcessorOptions,
|
||||
ignoreIssueUpdates: true
|
||||
};
|
||||
issueInterface = generateIIssue();
|
||||
});
|
||||
|
||||
describe('shouldIgnoreUpdates()', (): void => {
|
||||
describe('when the given issue is not a pull request', (): void => {
|
||||
beforeEach((): void => {
|
||||
issueInterface.pull_request = undefined;
|
||||
});
|
||||
|
||||
describe('when the given options are configured to reset the stale on updates', (): void => {
|
||||
beforeEach((): void => {
|
||||
optionsInterface.ignoreUpdates = false;
|
||||
});
|
||||
|
||||
describe('when the given options are not configured to reset the issue stale on updates', (): void => {
|
||||
beforeEach((): void => {
|
||||
delete optionsInterface.ignoreIssueUpdates;
|
||||
});
|
||||
|
||||
it('should return false', (): void => {
|
||||
expect.assertions(1);
|
||||
issue = new Issue(optionsInterface, issueInterface);
|
||||
ignoreUpdates = new IgnoreUpdates(optionsInterface, issue);
|
||||
|
||||
const result = ignoreUpdates.shouldIgnoreUpdates();
|
||||
|
||||
expect(result).toStrictEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the given options are configured to reset the issue stale on updates', (): void => {
|
||||
beforeEach((): void => {
|
||||
optionsInterface.ignoreIssueUpdates = false;
|
||||
});
|
||||
|
||||
it('should return false', (): void => {
|
||||
expect.assertions(1);
|
||||
issue = new Issue(optionsInterface, issueInterface);
|
||||
ignoreUpdates = new IgnoreUpdates(optionsInterface, issue);
|
||||
|
||||
const result = ignoreUpdates.shouldIgnoreUpdates();
|
||||
|
||||
expect(result).toStrictEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the given options are configured to not reset the issue stale on updates', (): void => {
|
||||
beforeEach((): void => {
|
||||
optionsInterface.ignoreIssueUpdates = true;
|
||||
});
|
||||
|
||||
it('should return true', (): void => {
|
||||
expect.assertions(1);
|
||||
issue = new Issue(optionsInterface, issueInterface);
|
||||
ignoreUpdates = new IgnoreUpdates(optionsInterface, issue);
|
||||
|
||||
const result = ignoreUpdates.shouldIgnoreUpdates();
|
||||
|
||||
expect(result).toStrictEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the given options are configured to reset the stale on updates', (): void => {
|
||||
beforeEach((): void => {
|
||||
optionsInterface.ignoreUpdates = true;
|
||||
});
|
||||
|
||||
describe('when the given options are not configured to reset the issue stale on updates', (): void => {
|
||||
beforeEach((): void => {
|
||||
delete optionsInterface.ignoreIssueUpdates;
|
||||
});
|
||||
|
||||
it('should return true', (): void => {
|
||||
expect.assertions(1);
|
||||
issue = new Issue(optionsInterface, issueInterface);
|
||||
ignoreUpdates = new IgnoreUpdates(optionsInterface, issue);
|
||||
|
||||
const result = ignoreUpdates.shouldIgnoreUpdates();
|
||||
|
||||
expect(result).toStrictEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the given options are configured to reset the issue stale on updates', (): void => {
|
||||
beforeEach((): void => {
|
||||
optionsInterface.ignoreIssueUpdates = false;
|
||||
});
|
||||
|
||||
it('should return false', (): void => {
|
||||
expect.assertions(1);
|
||||
issue = new Issue(optionsInterface, issueInterface);
|
||||
ignoreUpdates = new IgnoreUpdates(optionsInterface, issue);
|
||||
|
||||
const result = ignoreUpdates.shouldIgnoreUpdates();
|
||||
|
||||
expect(result).toStrictEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the given options are configured to not reset the issue stale on updates', (): void => {
|
||||
beforeEach((): void => {
|
||||
optionsInterface.ignoreIssueUpdates = true;
|
||||
});
|
||||
|
||||
it('should return true', (): void => {
|
||||
expect.assertions(1);
|
||||
issue = new Issue(optionsInterface, issueInterface);
|
||||
ignoreUpdates = new IgnoreUpdates(optionsInterface, issue);
|
||||
|
||||
const result = ignoreUpdates.shouldIgnoreUpdates();
|
||||
|
||||
expect(result).toStrictEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the given issue is a pull request', (): void => {
|
||||
beforeEach((): void => {
|
||||
issueInterface.pull_request = {};
|
||||
});
|
||||
|
||||
describe('when the given options are configured to reset the stale on updates', (): void => {
|
||||
beforeEach((): void => {
|
||||
optionsInterface.ignoreUpdates = false;
|
||||
});
|
||||
|
||||
describe('when the given options are not configured to reset the pull request stale on updates', (): void => {
|
||||
beforeEach((): void => {
|
||||
delete optionsInterface.ignorePrUpdates;
|
||||
});
|
||||
|
||||
it('should return false', (): void => {
|
||||
expect.assertions(1);
|
||||
issue = new Issue(optionsInterface, issueInterface);
|
||||
ignoreUpdates = new IgnoreUpdates(optionsInterface, issue);
|
||||
|
||||
const result = ignoreUpdates.shouldIgnoreUpdates();
|
||||
|
||||
expect(result).toStrictEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the given options are configured to reset the pull request stale on updates', (): void => {
|
||||
beforeEach((): void => {
|
||||
optionsInterface.ignorePrUpdates = false;
|
||||
});
|
||||
|
||||
it('should return false', (): void => {
|
||||
expect.assertions(1);
|
||||
issue = new Issue(optionsInterface, issueInterface);
|
||||
ignoreUpdates = new IgnoreUpdates(optionsInterface, issue);
|
||||
|
||||
const result = ignoreUpdates.shouldIgnoreUpdates();
|
||||
|
||||
expect(result).toStrictEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the given options are configured to not reset the pull request stale on updates', (): void => {
|
||||
beforeEach((): void => {
|
||||
optionsInterface.ignorePrUpdates = true;
|
||||
});
|
||||
|
||||
it('should return true', (): void => {
|
||||
expect.assertions(1);
|
||||
issue = new Issue(optionsInterface, issueInterface);
|
||||
ignoreUpdates = new IgnoreUpdates(optionsInterface, issue);
|
||||
|
||||
const result = ignoreUpdates.shouldIgnoreUpdates();
|
||||
|
||||
expect(result).toStrictEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the given options are configured to not reset the stale on updates', (): void => {
|
||||
beforeEach((): void => {
|
||||
optionsInterface.ignoreUpdates = true;
|
||||
});
|
||||
|
||||
describe('when the given options are not configured to reset the pull request stale on updates', (): void => {
|
||||
beforeEach((): void => {
|
||||
delete optionsInterface.ignorePrUpdates;
|
||||
});
|
||||
|
||||
it('should return true', (): void => {
|
||||
expect.assertions(1);
|
||||
issue = new Issue(optionsInterface, issueInterface);
|
||||
ignoreUpdates = new IgnoreUpdates(optionsInterface, issue);
|
||||
|
||||
const result = ignoreUpdates.shouldIgnoreUpdates();
|
||||
|
||||
expect(result).toStrictEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the given options are configured to reset the pull request stale on updates', (): void => {
|
||||
beforeEach((): void => {
|
||||
optionsInterface.ignorePrUpdates = false;
|
||||
});
|
||||
|
||||
it('should return false', (): void => {
|
||||
expect.assertions(1);
|
||||
issue = new Issue(optionsInterface, issueInterface);
|
||||
ignoreUpdates = new IgnoreUpdates(optionsInterface, issue);
|
||||
|
||||
const result = ignoreUpdates.shouldIgnoreUpdates();
|
||||
|
||||
expect(result).toStrictEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the given options are configured to not reset the pull request stale on updates', (): void => {
|
||||
beforeEach((): void => {
|
||||
optionsInterface.ignorePrUpdates = true;
|
||||
});
|
||||
|
||||
it('should return true', (): void => {
|
||||
expect.assertions(1);
|
||||
issue = new Issue(optionsInterface, issueInterface);
|
||||
ignoreUpdates = new IgnoreUpdates(optionsInterface, issue);
|
||||
|
||||
const result = ignoreUpdates.shouldIgnoreUpdates();
|
||||
|
||||
expect(result).toStrictEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
90
src/classes/ignore-updates.ts
Normal file
90
src/classes/ignore-updates.ts
Normal file
@@ -0,0 +1,90 @@
|
||||
import {Option} from '../enums/option';
|
||||
import {IIssuesProcessorOptions} from '../interfaces/issues-processor-options';
|
||||
import {Issue} from './issue';
|
||||
import {IssueLogger} from './loggers/issue-logger';
|
||||
|
||||
export class IgnoreUpdates {
|
||||
private readonly _options: IIssuesProcessorOptions;
|
||||
private readonly _issue: Issue;
|
||||
private readonly _issueLogger: IssueLogger;
|
||||
|
||||
constructor(options: Readonly<IIssuesProcessorOptions>, issue: Issue) {
|
||||
this._options = options;
|
||||
this._issue = issue;
|
||||
this._issueLogger = new IssueLogger(issue);
|
||||
}
|
||||
|
||||
shouldIgnoreUpdates(): boolean {
|
||||
return this._shouldIgnoreUpdates();
|
||||
}
|
||||
|
||||
private _shouldIgnoreUpdates(): boolean {
|
||||
return this._issue.isPullRequest
|
||||
? this._shouldIgnorePullRequestUpdates()
|
||||
: this._shouldIgnoreIssueUpdates();
|
||||
}
|
||||
|
||||
private _shouldIgnorePullRequestUpdates(): boolean {
|
||||
if (this._options.ignorePrUpdates === true) {
|
||||
this._issueLogger.info(
|
||||
`The option ${this._issueLogger.createOptionLink(
|
||||
Option.IgnorePrUpdates
|
||||
)} is enabled. The stale counter will ignore any updates or comments on this $$type and will use the creation date as a reference ignoring any kind of update`
|
||||
);
|
||||
|
||||
return true;
|
||||
} else if (this._options.ignorePrUpdates === false) {
|
||||
this._issueLogger.info(
|
||||
`The option ${this._issueLogger.createOptionLink(
|
||||
Option.IgnorePrUpdates
|
||||
)} is disabled. The stale counter will take into account updates and comments on this $$type to avoid to stale when there is some update`
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
this._logIgnoreUpdates();
|
||||
|
||||
return this._options.ignoreUpdates;
|
||||
}
|
||||
|
||||
private _shouldIgnoreIssueUpdates(): boolean {
|
||||
if (this._options.ignoreIssueUpdates === true) {
|
||||
this._issueLogger.info(
|
||||
`The option ${this._issueLogger.createOptionLink(
|
||||
Option.IgnoreIssueUpdates
|
||||
)} is enabled. The stale counter will ignore any updates or comments on this $$type and will use the creation date as a reference ignoring any kind of update`
|
||||
);
|
||||
|
||||
return true;
|
||||
} else if (this._options.ignoreIssueUpdates === false) {
|
||||
this._issueLogger.info(
|
||||
`The option ${this._issueLogger.createOptionLink(
|
||||
Option.IgnoreIssueUpdates
|
||||
)} is disabled. The stale counter will take into account updates and comments on this $$type to avoid to stale when there is some update`
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
this._logIgnoreUpdates();
|
||||
|
||||
return this._options.ignoreUpdates;
|
||||
}
|
||||
|
||||
private _logIgnoreUpdates(): void {
|
||||
if (this._options.ignoreUpdates) {
|
||||
this._issueLogger.info(
|
||||
`The option ${this._issueLogger.createOptionLink(
|
||||
Option.IgnoreUpdates
|
||||
)} is enabled. The stale counter will ignore any updates or comments on this $$type and will use the creation date as a reference ignoring any kind of update`
|
||||
);
|
||||
} else {
|
||||
this._issueLogger.info(
|
||||
`The option ${this._issueLogger.createOptionLink(
|
||||
Option.IgnoreUpdates
|
||||
)} is disabled. The stale counter will take into account updates and comments on this $$type to avoid to stale when there is some update`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import {IAssignee} from '../interfaces/assignee';
|
||||
import {IUserAssignee} from '../interfaces/assignee';
|
||||
import {IIssue} from '../interfaces/issue';
|
||||
import {IIssuesProcessorOptions} from '../interfaces/issues-processor-options';
|
||||
import {ILabel} from '../interfaces/label';
|
||||
@@ -38,8 +38,6 @@ describe('Issue', (): void => {
|
||||
removeIssueStaleWhenUpdated: undefined,
|
||||
removePrStaleWhenUpdated: undefined,
|
||||
repoToken: '',
|
||||
skipStaleIssueMessage: false,
|
||||
skipStalePrMessage: false,
|
||||
staleIssueMessage: '',
|
||||
stalePrMessage: '',
|
||||
startDate: undefined,
|
||||
@@ -57,7 +55,13 @@ describe('Issue', (): void => {
|
||||
exemptAllAssignees: false,
|
||||
exemptAllIssueAssignees: undefined,
|
||||
exemptAllPrAssignees: undefined,
|
||||
enableStatistics: false
|
||||
enableStatistics: false,
|
||||
labelsToRemoveWhenUnstale: '',
|
||||
labelsToAddWhenUnstale: '',
|
||||
ignoreUpdates: false,
|
||||
ignoreIssueUpdates: undefined,
|
||||
ignorePrUpdates: undefined,
|
||||
exemptDraftPr: false
|
||||
};
|
||||
issueInterface = {
|
||||
title: 'dummy-title',
|
||||
@@ -77,7 +81,8 @@ describe('Issue', (): void => {
|
||||
},
|
||||
assignees: [
|
||||
{
|
||||
login: 'dummy-login'
|
||||
login: 'dummy-login',
|
||||
type: 'User'
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -150,8 +155,9 @@ describe('Issue', (): void => {
|
||||
|
||||
expect(issue.assignees).toStrictEqual([
|
||||
{
|
||||
login: 'dummy-login'
|
||||
} as IAssignee
|
||||
login: 'dummy-login',
|
||||
type: 'User'
|
||||
} as IUserAssignee
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -272,7 +278,8 @@ describe('Issue', (): void => {
|
||||
beforeEach((): void => {
|
||||
issueInterface.assignees = [
|
||||
{
|
||||
login: 'dummy-login'
|
||||
login: 'dummy-login',
|
||||
type: 'User'
|
||||
}
|
||||
];
|
||||
issue = new Issue(optionsInterface, issueInterface);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {isLabeled} from '../functions/is-labeled';
|
||||
import {isPullRequest} from '../functions/is-pull-request';
|
||||
import {IAssignee} from '../interfaces/assignee';
|
||||
import {Assignee} from '../interfaces/assignee';
|
||||
import {IIssue} from '../interfaces/issue';
|
||||
import {IIssuesProcessorOptions} from '../interfaces/issues-processor-options';
|
||||
import {ILabel} from '../interfaces/label';
|
||||
@@ -9,7 +9,6 @@ import {IsoDateString} from '../types/iso-date-string';
|
||||
import {Operations} from './operations';
|
||||
|
||||
export class Issue implements IIssue {
|
||||
private readonly _options: IIssuesProcessorOptions;
|
||||
readonly title: string;
|
||||
readonly number: number;
|
||||
created_at: IsoDateString;
|
||||
@@ -19,21 +18,10 @@ export class Issue implements IIssue {
|
||||
readonly state: string | 'closed' | 'open';
|
||||
readonly locked: boolean;
|
||||
readonly milestone: IMilestone | undefined;
|
||||
readonly assignees: IAssignee[];
|
||||
readonly assignees: Assignee[];
|
||||
isStale: boolean;
|
||||
operations = new Operations();
|
||||
|
||||
get isPullRequest(): boolean {
|
||||
return isPullRequest(this);
|
||||
}
|
||||
|
||||
get staleLabel(): string {
|
||||
return this._getStaleLabel();
|
||||
}
|
||||
|
||||
get hasAssignees(): boolean {
|
||||
return this.assignees.length > 0;
|
||||
}
|
||||
private readonly _options: IIssuesProcessorOptions;
|
||||
|
||||
constructor(
|
||||
options: Readonly<IIssuesProcessorOptions>,
|
||||
@@ -50,10 +38,21 @@ export class Issue implements IIssue {
|
||||
this.locked = issue.locked;
|
||||
this.milestone = issue.milestone;
|
||||
this.assignees = issue.assignees;
|
||||
|
||||
this.isStale = isLabeled(this, this.staleLabel);
|
||||
}
|
||||
|
||||
get isPullRequest(): boolean {
|
||||
return isPullRequest(this);
|
||||
}
|
||||
|
||||
get staleLabel(): string {
|
||||
return this._getStaleLabel();
|
||||
}
|
||||
|
||||
get hasAssignees(): boolean {
|
||||
return this.assignees.length > 0;
|
||||
}
|
||||
|
||||
private _getStaleLabel(): string {
|
||||
return this.isPullRequest
|
||||
? this._options.stalePrLabel
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -26,12 +26,17 @@ describe('IssueLogger', (): void => {
|
||||
});
|
||||
|
||||
it('should log a warning with the given message and with the issue number as prefix', (): void => {
|
||||
expect.assertions(2);
|
||||
expect.assertions(3);
|
||||
|
||||
issueLogger.warning(message);
|
||||
|
||||
expect(coreWarningSpy).toHaveBeenCalledTimes(1);
|
||||
expect(coreWarningSpy).toHaveBeenCalledWith('[#8] dummy-message');
|
||||
expect(coreWarningSpy).toHaveBeenCalledWith(
|
||||
expect.stringContaining('[#8]')
|
||||
);
|
||||
expect(coreWarningSpy).toHaveBeenCalledWith(
|
||||
expect.stringContaining('dummy-message')
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -52,12 +57,15 @@ describe('IssueLogger', (): void => {
|
||||
});
|
||||
|
||||
it('should log an information with the given message and with the issue number as prefix', (): void => {
|
||||
expect.assertions(2);
|
||||
expect.assertions(3);
|
||||
|
||||
issueLogger.info(message);
|
||||
|
||||
expect(coreInfoSpy).toHaveBeenCalledTimes(1);
|
||||
expect(coreInfoSpy).toHaveBeenCalledWith('[#8] dummy-message');
|
||||
expect(coreInfoSpy).toHaveBeenCalledWith(expect.stringContaining('[#8]'));
|
||||
expect(coreInfoSpy).toHaveBeenCalledWith(
|
||||
expect.stringContaining('dummy-message')
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -78,17 +86,22 @@ describe('IssueLogger', (): void => {
|
||||
});
|
||||
|
||||
it('should log an error with the given message and with the issue number as prefix', (): void => {
|
||||
expect.assertions(2);
|
||||
expect.assertions(3);
|
||||
|
||||
issueLogger.error(message);
|
||||
|
||||
expect(coreErrorSpy).toHaveBeenCalledTimes(1);
|
||||
expect(coreErrorSpy).toHaveBeenCalledWith('[#8] dummy-message');
|
||||
expect(coreErrorSpy).toHaveBeenCalledWith(
|
||||
expect.stringContaining('[#8]')
|
||||
);
|
||||
expect(coreErrorSpy).toHaveBeenCalledWith(
|
||||
expect.stringContaining('dummy-message')
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('should prefix the message with the issue number', (): void => {
|
||||
expect.assertions(2);
|
||||
expect.assertions(3);
|
||||
message = 'dummy-message';
|
||||
issue = new Issue(
|
||||
DefaultProcessorOptions,
|
||||
@@ -102,7 +115,12 @@ describe('IssueLogger', (): void => {
|
||||
issueLogger.warning(message);
|
||||
|
||||
expect(coreWarningSpy).toHaveBeenCalledTimes(1);
|
||||
expect(coreWarningSpy).toHaveBeenCalledWith('[#123] dummy-message');
|
||||
expect(coreWarningSpy).toHaveBeenCalledWith(
|
||||
expect.stringContaining('[#123]')
|
||||
);
|
||||
expect(coreWarningSpy).toHaveBeenCalledWith(
|
||||
expect.stringContaining('dummy-message')
|
||||
);
|
||||
});
|
||||
|
||||
it.each`
|
||||
@@ -114,7 +132,7 @@ describe('IssueLogger', (): void => {
|
||||
`(
|
||||
'should replace the special tokens "$$type" with the corresponding type',
|
||||
({pull_request, replacement}): void => {
|
||||
expect.assertions(2);
|
||||
expect.assertions(3);
|
||||
message = 'The $$type will stale! $$type will soon be closed!';
|
||||
issue = new Issue(
|
||||
DefaultProcessorOptions,
|
||||
@@ -130,7 +148,12 @@ describe('IssueLogger', (): void => {
|
||||
|
||||
expect(coreWarningSpy).toHaveBeenCalledTimes(1);
|
||||
expect(coreWarningSpy).toHaveBeenCalledWith(
|
||||
`[#8] The ${replacement} will stale! ${replacement} will soon be closed!`
|
||||
expect.stringContaining(`[#8]`)
|
||||
);
|
||||
expect(coreWarningSpy).toHaveBeenCalledWith(
|
||||
expect.stringContaining(
|
||||
`The ${replacement} will stale! ${replacement} will soon be closed!`
|
||||
)
|
||||
);
|
||||
}
|
||||
);
|
||||
@@ -144,7 +167,7 @@ describe('IssueLogger', (): void => {
|
||||
`(
|
||||
'should replace the special token "$$type" with the corresponding type with first letter as uppercase',
|
||||
({pull_request, replacement}): void => {
|
||||
expect.assertions(2);
|
||||
expect.assertions(3);
|
||||
message = '$$type will stale';
|
||||
issue = new Issue(
|
||||
DefaultProcessorOptions,
|
||||
@@ -160,7 +183,10 @@ describe('IssueLogger', (): void => {
|
||||
|
||||
expect(coreWarningSpy).toHaveBeenCalledTimes(1);
|
||||
expect(coreWarningSpy).toHaveBeenCalledWith(
|
||||
`[#8] ${replacement} will stale`
|
||||
expect.stringContaining(`[#8]`)
|
||||
);
|
||||
expect(coreWarningSpy).toHaveBeenCalledWith(
|
||||
expect.stringContaining(`${replacement} will stale`)
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import chalk from 'chalk';
|
||||
import {Issue} from '../issue';
|
||||
import {Logger} from './logger';
|
||||
import {LoggerService} from '../../services/logger.service';
|
||||
|
||||
/**
|
||||
* @description
|
||||
@@ -35,6 +35,10 @@ export class IssueLogger extends Logger {
|
||||
super.error(this._format(...message));
|
||||
}
|
||||
|
||||
async grouping(message: string, fn: () => Promise<void>): Promise<void> {
|
||||
return super.grouping(this._format(message), fn);
|
||||
}
|
||||
|
||||
private _replaceTokens(message: Readonly<string>): string {
|
||||
return this._replaceTypeToken(message);
|
||||
}
|
||||
@@ -70,10 +74,10 @@ export class IssueLogger extends Logger {
|
||||
}
|
||||
|
||||
private _getIssuePrefix(): string {
|
||||
return chalk.red(`[#${this._getIssueNumber()}]`);
|
||||
return LoggerService.red(`[#${this._getIssueNumber()}]`);
|
||||
}
|
||||
|
||||
private _getPullRequestPrefix(): string {
|
||||
return chalk.blue(`[#${this._getIssueNumber()}]`);
|
||||
return LoggerService.blue(`[#${this._getIssueNumber()}]`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,9 @@ describe('Logger', (): void => {
|
||||
logger.warning(message);
|
||||
|
||||
expect(coreWarningSpy).toHaveBeenCalledTimes(1);
|
||||
expect(coreWarningSpy).toHaveBeenCalledWith('dummy-message');
|
||||
expect(coreWarningSpy).toHaveBeenCalledWith(
|
||||
expect.stringContaining('dummy-message')
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -46,7 +48,9 @@ describe('Logger', (): void => {
|
||||
logger.info(message);
|
||||
|
||||
expect(coreInfoSpy).toHaveBeenCalledTimes(1);
|
||||
expect(coreInfoSpy).toHaveBeenCalledWith('dummy-message');
|
||||
expect(coreInfoSpy).toHaveBeenCalledWith(
|
||||
expect.stringContaining('dummy-message')
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -67,7 +71,9 @@ describe('Logger', (): void => {
|
||||
logger.error(message);
|
||||
|
||||
expect(coreErrorSpy).toHaveBeenCalledTimes(1);
|
||||
expect(coreErrorSpy).toHaveBeenCalledWith('dummy-message');
|
||||
expect(coreErrorSpy).toHaveBeenCalledWith(
|
||||
expect.stringContaining('dummy-message')
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
import * as core from '@actions/core';
|
||||
import chalk from 'chalk';
|
||||
import terminalLink from 'terminal-link';
|
||||
import {Option} from '../../enums/option';
|
||||
import {LoggerService} from '../../services/logger.service';
|
||||
|
||||
export class Logger {
|
||||
warning(...message: string[]): void {
|
||||
core.warning(chalk.whiteBright(...message));
|
||||
core.warning(LoggerService.whiteBright(message.join(' ')));
|
||||
}
|
||||
|
||||
info(...message: string[]): void {
|
||||
core.info(chalk.whiteBright(...message));
|
||||
core.info(LoggerService.whiteBright(message.join(' ')));
|
||||
}
|
||||
|
||||
error(...message: string[]): void {
|
||||
core.error(chalk.whiteBright(...message));
|
||||
core.error(LoggerService.whiteBright(message.join(' ')));
|
||||
}
|
||||
|
||||
async grouping(message: string, fn: () => Promise<void>): Promise<void> {
|
||||
return core.group(LoggerService.whiteBright(message), fn);
|
||||
}
|
||||
|
||||
createLink(name: Readonly<string>, link: Readonly<string>): string {
|
||||
@@ -21,7 +25,7 @@ export class Logger {
|
||||
}
|
||||
|
||||
createOptionLink(option: Readonly<Option>): string {
|
||||
return chalk.magenta(
|
||||
return LoggerService.magenta(
|
||||
this.createLink(option, `https://github.com/actions/stale#${option}`)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import chalk from 'chalk';
|
||||
import deburr from 'lodash.deburr';
|
||||
import {Option} from '../enums/option';
|
||||
import {wordsToList} from '../functions/words-to-list';
|
||||
import {IIssuesProcessorOptions} from '../interfaces/issues-processor-options';
|
||||
import {Issue} from './issue';
|
||||
import {IssueLogger} from './loggers/issue-logger';
|
||||
import {LoggerService} from '../services/logger.service';
|
||||
|
||||
type CleanMilestone = string;
|
||||
|
||||
@@ -33,7 +33,7 @@ export class Milestones {
|
||||
|
||||
if (this._shouldExemptAllMilestones()) {
|
||||
this._issueLogger.info(
|
||||
chalk.white('└──'),
|
||||
LoggerService.white('└──'),
|
||||
'Skipping this $$type because it has a milestone'
|
||||
);
|
||||
|
||||
@@ -44,7 +44,7 @@ export class Milestones {
|
||||
|
||||
if (exemptMilestones.length === 0) {
|
||||
this._issueLogger.info(
|
||||
chalk.white('├──'),
|
||||
LoggerService.white('├──'),
|
||||
`No milestone option was specified to skip the stale process for this $$type`
|
||||
);
|
||||
this._logSkip();
|
||||
@@ -53,8 +53,8 @@ export class Milestones {
|
||||
}
|
||||
|
||||
this._issueLogger.info(
|
||||
chalk.white('├──'),
|
||||
`Found ${chalk.cyan(exemptMilestones.length)} milestone${
|
||||
LoggerService.white('├──'),
|
||||
`Found ${LoggerService.cyan(exemptMilestones.length)} milestone${
|
||||
exemptMilestones.length > 1 ? 's' : ''
|
||||
} that can exempt stale on this $$type`
|
||||
);
|
||||
@@ -66,13 +66,13 @@ export class Milestones {
|
||||
|
||||
if (!hasExemptMilestone) {
|
||||
this._issueLogger.info(
|
||||
chalk.white('├──'),
|
||||
LoggerService.white('├──'),
|
||||
'No milestone on this $$type can exempt the stale process'
|
||||
);
|
||||
this._logSkip();
|
||||
} else {
|
||||
this._issueLogger.info(
|
||||
chalk.white('└──'),
|
||||
LoggerService.white('└──'),
|
||||
'Skipping this $$type because it has an exempt milestone'
|
||||
);
|
||||
}
|
||||
@@ -89,7 +89,7 @@ export class Milestones {
|
||||
private _getExemptIssueMilestones(): string[] {
|
||||
if (this._options.exemptIssueMilestones === '') {
|
||||
this._issueLogger.info(
|
||||
chalk.white('├──'),
|
||||
LoggerService.white('├──'),
|
||||
`The option ${this._issueLogger.createOptionLink(
|
||||
Option.ExemptIssueMilestones
|
||||
)} is disabled. No specific milestone can skip the stale process for this $$type`
|
||||
@@ -97,7 +97,7 @@ export class Milestones {
|
||||
|
||||
if (this._options.exemptMilestones === '') {
|
||||
this._issueLogger.info(
|
||||
chalk.white('├──'),
|
||||
LoggerService.white('├──'),
|
||||
`The option ${this._issueLogger.createOptionLink(
|
||||
Option.ExemptMilestones
|
||||
)} is disabled. No specific milestone can skip the stale process for this $$type`
|
||||
@@ -111,10 +111,10 @@ export class Milestones {
|
||||
);
|
||||
|
||||
this._issueLogger.info(
|
||||
chalk.white('├──'),
|
||||
LoggerService.white('├──'),
|
||||
`The option ${this._issueLogger.createOptionLink(
|
||||
Option.ExemptMilestones
|
||||
)} is set. ${chalk.cyan(exemptMilestones.length)} milestone${
|
||||
)} is set. ${LoggerService.cyan(exemptMilestones.length)} milestone${
|
||||
exemptMilestones.length === 1 ? '' : 's'
|
||||
} can skip the stale process for this $$type`
|
||||
);
|
||||
@@ -127,10 +127,10 @@ export class Milestones {
|
||||
);
|
||||
|
||||
this._issueLogger.info(
|
||||
chalk.white('├──'),
|
||||
LoggerService.white('├──'),
|
||||
`The option ${this._issueLogger.createOptionLink(
|
||||
Option.ExemptIssueMilestones
|
||||
)} is set. ${chalk.cyan(exemptMilestones.length)} milestone${
|
||||
)} is set. ${LoggerService.cyan(exemptMilestones.length)} milestone${
|
||||
exemptMilestones.length === 1 ? '' : 's'
|
||||
} can skip the stale process for this $$type`
|
||||
);
|
||||
@@ -141,7 +141,7 @@ export class Milestones {
|
||||
private _getExemptPullRequestMilestones(): string[] {
|
||||
if (this._options.exemptPrMilestones === '') {
|
||||
this._issueLogger.info(
|
||||
chalk.white('├──'),
|
||||
LoggerService.white('├──'),
|
||||
`The option ${this._issueLogger.createOptionLink(
|
||||
Option.ExemptPrMilestones
|
||||
)} is disabled. No specific milestone can skip the stale process for this $$type`
|
||||
@@ -149,7 +149,7 @@ export class Milestones {
|
||||
|
||||
if (this._options.exemptMilestones === '') {
|
||||
this._issueLogger.info(
|
||||
chalk.white('├──'),
|
||||
LoggerService.white('├──'),
|
||||
`The option ${this._issueLogger.createOptionLink(
|
||||
Option.ExemptMilestones
|
||||
)} is disabled. No specific milestone can skip the stale process for this $$type`
|
||||
@@ -163,10 +163,10 @@ export class Milestones {
|
||||
);
|
||||
|
||||
this._issueLogger.info(
|
||||
chalk.white('├──'),
|
||||
LoggerService.white('├──'),
|
||||
`The option ${this._issueLogger.createOptionLink(
|
||||
Option.ExemptMilestones
|
||||
)} is set. ${chalk.cyan(exemptMilestones.length)} milestone${
|
||||
)} is set. ${LoggerService.cyan(exemptMilestones.length)} milestone${
|
||||
exemptMilestones.length === 1 ? '' : 's'
|
||||
} can skip the stale process for this $$type`
|
||||
);
|
||||
@@ -179,10 +179,10 @@ export class Milestones {
|
||||
);
|
||||
|
||||
this._issueLogger.info(
|
||||
chalk.white('├──'),
|
||||
LoggerService.white('├──'),
|
||||
`The option ${this._issueLogger.createOptionLink(
|
||||
Option.ExemptPrMilestones
|
||||
)} is set. ${chalk.cyan(exemptMilestones.length)} milestone${
|
||||
)} is set. ${LoggerService.cyan(exemptMilestones.length)} milestone${
|
||||
exemptMilestones.length === 1 ? '' : 's'
|
||||
} can skip the stale process for this $$type`
|
||||
);
|
||||
@@ -195,9 +195,8 @@ export class Milestones {
|
||||
return false;
|
||||
}
|
||||
|
||||
const cleanMilestone: CleanMilestone = Milestones._cleanMilestone(
|
||||
milestone
|
||||
);
|
||||
const cleanMilestone: CleanMilestone =
|
||||
Milestones._cleanMilestone(milestone);
|
||||
|
||||
const isSameMilestone: boolean =
|
||||
cleanMilestone ===
|
||||
@@ -205,8 +204,10 @@ export class Milestones {
|
||||
|
||||
if (isSameMilestone) {
|
||||
this._issueLogger.info(
|
||||
chalk.white('├──'),
|
||||
`The milestone "${milestone}" is set on this $$type and is an exempt milestone`
|
||||
LoggerService.white('├──'),
|
||||
`The milestone "${LoggerService.cyan(
|
||||
milestone
|
||||
)}" is set on this $$type and is an exempt milestone`
|
||||
);
|
||||
}
|
||||
|
||||
@@ -288,6 +289,9 @@ export class Milestones {
|
||||
}
|
||||
|
||||
private _logSkip(): void {
|
||||
this._issueLogger.info(chalk.white('└──'), 'Skip the milestones checks');
|
||||
this._issueLogger.info(
|
||||
LoggerService.white('└──'),
|
||||
'Skip the milestones checks'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import chalk from 'chalk';
|
||||
import {Issue} from './issue';
|
||||
import {Logger} from './loggers/logger';
|
||||
import {LoggerService} from '../services/logger.service';
|
||||
|
||||
interface IGroupValue {
|
||||
name: string;
|
||||
@@ -9,28 +9,28 @@ interface IGroupValue {
|
||||
|
||||
export class Statistics {
|
||||
private readonly _logger: Logger = new Logger();
|
||||
private _processedIssuesCount = 0;
|
||||
private _processedPullRequestsCount = 0;
|
||||
private _staleIssuesCount = 0;
|
||||
private _stalePullRequestsCount = 0;
|
||||
private _undoStaleIssuesCount = 0;
|
||||
private _undoStalePullRequestsCount = 0;
|
||||
private _operationsCount = 0;
|
||||
private _closedIssuesCount = 0;
|
||||
private _closedPullRequestsCount = 0;
|
||||
private _deletedIssuesLabelsCount = 0;
|
||||
private _deletedPullRequestsLabelsCount = 0;
|
||||
private _deletedCloseIssuesLabelsCount = 0;
|
||||
private _deletedClosePullRequestsLabelsCount = 0;
|
||||
private _deletedBranchesCount = 0;
|
||||
private _addedIssuesLabelsCount = 0;
|
||||
private _addedPullRequestsLabelsCount = 0;
|
||||
private _addedIssuesCommentsCount = 0;
|
||||
private _addedPullRequestsCommentsCount = 0;
|
||||
private _fetchedItemsCount = 0;
|
||||
private _fetchedItemsEventsCount = 0;
|
||||
private _fetchedItemsCommentsCount = 0;
|
||||
private _fetchedPullRequestsCount = 0;
|
||||
processedIssuesCount = 0;
|
||||
processedPullRequestsCount = 0;
|
||||
staleIssuesCount = 0;
|
||||
stalePullRequestsCount = 0;
|
||||
undoStaleIssuesCount = 0;
|
||||
undoStalePullRequestsCount = 0;
|
||||
operationsCount = 0;
|
||||
closedIssuesCount = 0;
|
||||
closedPullRequestsCount = 0;
|
||||
deletedIssuesLabelsCount = 0;
|
||||
deletedPullRequestsLabelsCount = 0;
|
||||
deletedCloseIssuesLabelsCount = 0;
|
||||
deletedClosePullRequestsLabelsCount = 0;
|
||||
deletedBranchesCount = 0;
|
||||
addedIssuesLabelsCount = 0;
|
||||
addedPullRequestsLabelsCount = 0;
|
||||
addedIssuesCommentsCount = 0;
|
||||
addedPullRequestsCommentsCount = 0;
|
||||
fetchedItemsCount = 0;
|
||||
fetchedItemsEventsCount = 0;
|
||||
fetchedItemsCommentsCount = 0;
|
||||
fetchedPullRequestsCount = 0;
|
||||
|
||||
incrementProcessedItemsCount(
|
||||
issue: Readonly<Issue>,
|
||||
@@ -65,8 +65,8 @@ export class Statistics {
|
||||
return this._incrementUndoStaleIssuesCount(increment);
|
||||
}
|
||||
|
||||
setRemainingOperations(remainingOperations: Readonly<number>): Statistics {
|
||||
this._operationsCount = remainingOperations;
|
||||
setOperationsCount(operationsCount: Readonly<number>): Statistics {
|
||||
this.operationsCount = operationsCount;
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -105,7 +105,7 @@ export class Statistics {
|
||||
}
|
||||
|
||||
incrementDeletedBranchesCount(increment: Readonly<number> = 1): Statistics {
|
||||
this._deletedBranchesCount += increment;
|
||||
this.deletedBranchesCount += increment;
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -133,7 +133,7 @@ export class Statistics {
|
||||
}
|
||||
|
||||
incrementFetchedItemsCount(increment: Readonly<number> = 1): Statistics {
|
||||
this._fetchedItemsCount += increment;
|
||||
this.fetchedItemsCount += increment;
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -141,7 +141,7 @@ export class Statistics {
|
||||
incrementFetchedItemsEventsCount(
|
||||
increment: Readonly<number> = 1
|
||||
): Statistics {
|
||||
this._fetchedItemsEventsCount += increment;
|
||||
this.fetchedItemsEventsCount += increment;
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -149,7 +149,7 @@ export class Statistics {
|
||||
incrementFetchedItemsCommentsCount(
|
||||
increment: Readonly<number> = 1
|
||||
): Statistics {
|
||||
this._fetchedItemsCommentsCount += increment;
|
||||
this.fetchedItemsCommentsCount += increment;
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -157,13 +157,13 @@ export class Statistics {
|
||||
incrementFetchedPullRequestsCount(
|
||||
increment: Readonly<number> = 1
|
||||
): Statistics {
|
||||
this._fetchedPullRequestsCount += increment;
|
||||
this.fetchedPullRequestsCount += increment;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
logStats(): Statistics {
|
||||
this._logger.info(chalk.yellow.bold('Statistics:'));
|
||||
this._logger.info(LoggerService.yellow(LoggerService.bold(`Statistics:`)));
|
||||
this._logProcessedIssuesAndPullRequestsCount();
|
||||
this._logStaleIssuesAndPullRequestsCount();
|
||||
this._logUndoStaleIssuesAndPullRequestsCount();
|
||||
@@ -185,7 +185,7 @@ export class Statistics {
|
||||
private _incrementProcessedIssuesCount(
|
||||
increment: Readonly<number> = 1
|
||||
): Statistics {
|
||||
this._processedIssuesCount += increment;
|
||||
this.processedIssuesCount += increment;
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -193,7 +193,7 @@ export class Statistics {
|
||||
private _incrementProcessedPullRequestsCount(
|
||||
increment: Readonly<number> = 1
|
||||
): Statistics {
|
||||
this._processedPullRequestsCount += increment;
|
||||
this.processedPullRequestsCount += increment;
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -201,7 +201,7 @@ export class Statistics {
|
||||
private _incrementStaleIssuesCount(
|
||||
increment: Readonly<number> = 1
|
||||
): Statistics {
|
||||
this._staleIssuesCount += increment;
|
||||
this.staleIssuesCount += increment;
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -209,7 +209,7 @@ export class Statistics {
|
||||
private _incrementStalePullRequestsCount(
|
||||
increment: Readonly<number> = 1
|
||||
): Statistics {
|
||||
this._stalePullRequestsCount += increment;
|
||||
this.stalePullRequestsCount += increment;
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -217,7 +217,7 @@ export class Statistics {
|
||||
private _incrementUndoStaleIssuesCount(
|
||||
increment: Readonly<number> = 1
|
||||
): Statistics {
|
||||
this._undoStaleIssuesCount += increment;
|
||||
this.undoStaleIssuesCount += increment;
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -225,7 +225,7 @@ export class Statistics {
|
||||
private _incrementUndoStalePullRequestsCount(
|
||||
increment: Readonly<number> = 1
|
||||
): Statistics {
|
||||
this._undoStalePullRequestsCount += increment;
|
||||
this.undoStalePullRequestsCount += increment;
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -233,7 +233,7 @@ export class Statistics {
|
||||
private _incrementClosedIssuesCount(
|
||||
increment: Readonly<number> = 1
|
||||
): Statistics {
|
||||
this._closedIssuesCount += increment;
|
||||
this.closedIssuesCount += increment;
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -241,7 +241,7 @@ export class Statistics {
|
||||
private _incrementClosedPullRequestsCount(
|
||||
increment: Readonly<number> = 1
|
||||
): Statistics {
|
||||
this._closedPullRequestsCount += increment;
|
||||
this.closedPullRequestsCount += increment;
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -249,7 +249,7 @@ export class Statistics {
|
||||
private _incrementDeletedIssuesLabelsCount(
|
||||
increment: Readonly<number> = 1
|
||||
): Statistics {
|
||||
this._deletedIssuesLabelsCount += increment;
|
||||
this.deletedIssuesLabelsCount += increment;
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -257,7 +257,7 @@ export class Statistics {
|
||||
private _incrementDeletedPullRequestsLabelsCount(
|
||||
increment: Readonly<number> = 1
|
||||
): Statistics {
|
||||
this._deletedPullRequestsLabelsCount += increment;
|
||||
this.deletedPullRequestsLabelsCount += increment;
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -265,7 +265,7 @@ export class Statistics {
|
||||
private _incrementDeletedCloseIssuesLabelsCount(
|
||||
increment: Readonly<number> = 1
|
||||
): Statistics {
|
||||
this._deletedCloseIssuesLabelsCount += increment;
|
||||
this.deletedCloseIssuesLabelsCount += increment;
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -273,7 +273,7 @@ export class Statistics {
|
||||
private _incrementDeletedClosePullRequestsLabelsCount(
|
||||
increment: Readonly<number> = 1
|
||||
): Statistics {
|
||||
this._deletedClosePullRequestsLabelsCount += increment;
|
||||
this.deletedClosePullRequestsLabelsCount += increment;
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -281,7 +281,7 @@ export class Statistics {
|
||||
private _incrementAddedIssuesLabel(
|
||||
increment: Readonly<number> = 1
|
||||
): Statistics {
|
||||
this._addedIssuesLabelsCount += increment;
|
||||
this.addedIssuesLabelsCount += increment;
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -289,7 +289,7 @@ export class Statistics {
|
||||
private _incrementAddedPullRequestsLabel(
|
||||
increment: Readonly<number> = 1
|
||||
): Statistics {
|
||||
this._addedPullRequestsLabelsCount += increment;
|
||||
this.addedPullRequestsLabelsCount += increment;
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -297,7 +297,7 @@ export class Statistics {
|
||||
private _incrementAddedIssuesComment(
|
||||
increment: Readonly<number> = 1
|
||||
): Statistics {
|
||||
this._addedIssuesCommentsCount += increment;
|
||||
this.addedIssuesCommentsCount += increment;
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -305,7 +305,7 @@ export class Statistics {
|
||||
private _incrementAddedPullRequestsComment(
|
||||
increment: Readonly<number> = 1
|
||||
): Statistics {
|
||||
this._addedPullRequestsCommentsCount += increment;
|
||||
this.addedPullRequestsCommentsCount += increment;
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -314,11 +314,11 @@ export class Statistics {
|
||||
this._logGroup('Processed items', [
|
||||
{
|
||||
name: 'Processed issues',
|
||||
count: this._processedIssuesCount
|
||||
count: this.processedIssuesCount
|
||||
},
|
||||
{
|
||||
name: 'Processed PRs',
|
||||
count: this._processedPullRequestsCount
|
||||
count: this.processedPullRequestsCount
|
||||
}
|
||||
]);
|
||||
}
|
||||
@@ -327,11 +327,11 @@ export class Statistics {
|
||||
this._logGroup('New stale items', [
|
||||
{
|
||||
name: 'New stale issues',
|
||||
count: this._staleIssuesCount
|
||||
count: this.staleIssuesCount
|
||||
},
|
||||
{
|
||||
name: 'New stale PRs',
|
||||
count: this._stalePullRequestsCount
|
||||
count: this.stalePullRequestsCount
|
||||
}
|
||||
]);
|
||||
}
|
||||
@@ -340,11 +340,11 @@ export class Statistics {
|
||||
this._logGroup('No longer stale items', [
|
||||
{
|
||||
name: 'No longer stale issues',
|
||||
count: this._undoStaleIssuesCount
|
||||
count: this.undoStaleIssuesCount
|
||||
},
|
||||
{
|
||||
name: 'No longer stale PRs',
|
||||
count: this._undoStalePullRequestsCount
|
||||
count: this.undoStalePullRequestsCount
|
||||
}
|
||||
]);
|
||||
}
|
||||
@@ -353,11 +353,11 @@ export class Statistics {
|
||||
this._logGroup('Closed items', [
|
||||
{
|
||||
name: 'Closed issues',
|
||||
count: this._closedIssuesCount
|
||||
count: this.closedIssuesCount
|
||||
},
|
||||
{
|
||||
name: 'Closed PRs',
|
||||
count: this._closedPullRequestsCount
|
||||
count: this.closedPullRequestsCount
|
||||
}
|
||||
]);
|
||||
}
|
||||
@@ -366,11 +366,11 @@ export class Statistics {
|
||||
this._logGroup('Deleted items labels', [
|
||||
{
|
||||
name: 'Deleted issues labels',
|
||||
count: this._deletedIssuesLabelsCount
|
||||
count: this.deletedIssuesLabelsCount
|
||||
},
|
||||
{
|
||||
name: 'Deleted PRs labels',
|
||||
count: this._deletedPullRequestsLabelsCount
|
||||
count: this.deletedPullRequestsLabelsCount
|
||||
}
|
||||
]);
|
||||
}
|
||||
@@ -379,28 +379,28 @@ export class Statistics {
|
||||
this._logGroup('Deleted close items labels', [
|
||||
{
|
||||
name: 'Deleted close issues labels',
|
||||
count: this._deletedCloseIssuesLabelsCount
|
||||
count: this.deletedCloseIssuesLabelsCount
|
||||
},
|
||||
{
|
||||
name: 'Deleted close PRs labels',
|
||||
count: this._deletedClosePullRequestsLabelsCount
|
||||
count: this.deletedClosePullRequestsLabelsCount
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
||||
private _logDeletedBranchesCount(): void {
|
||||
this._logCount('Deleted branches', this._deletedBranchesCount);
|
||||
this._logCount('Deleted branches', this.deletedBranchesCount);
|
||||
}
|
||||
|
||||
private _logAddedIssuesAndPullRequestsLabelsCount(): void {
|
||||
this._logGroup('Added items labels', [
|
||||
{
|
||||
name: 'Added issues labels',
|
||||
count: this._addedIssuesLabelsCount
|
||||
count: this.addedIssuesLabelsCount
|
||||
},
|
||||
{
|
||||
name: 'Added PRs labels',
|
||||
count: this._addedPullRequestsLabelsCount
|
||||
count: this.addedPullRequestsLabelsCount
|
||||
}
|
||||
]);
|
||||
}
|
||||
@@ -409,38 +409,38 @@ export class Statistics {
|
||||
this._logGroup('Added items comments', [
|
||||
{
|
||||
name: 'Added issues comments',
|
||||
count: this._addedIssuesCommentsCount
|
||||
count: this.addedIssuesCommentsCount
|
||||
},
|
||||
{
|
||||
name: 'Added PRs comments',
|
||||
count: this._addedPullRequestsCommentsCount
|
||||
count: this.addedPullRequestsCommentsCount
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
||||
private _logFetchedItemsCount(): void {
|
||||
this._logCount('Fetched items', this._fetchedItemsCount);
|
||||
this._logCount('Fetched items', this.fetchedItemsCount);
|
||||
}
|
||||
|
||||
private _logFetchedItemsEventsCount(): void {
|
||||
this._logCount('Fetched items events', this._fetchedItemsEventsCount);
|
||||
this._logCount('Fetched items events', this.fetchedItemsEventsCount);
|
||||
}
|
||||
|
||||
private _logFetchedItemsCommentsCount(): void {
|
||||
this._logCount('Fetched items comments', this._fetchedItemsCommentsCount);
|
||||
this._logCount('Fetched items comments', this.fetchedItemsCommentsCount);
|
||||
}
|
||||
|
||||
private _logFetchedPullRequestsCount(): void {
|
||||
this._logCount('Fetched pull requests', this._fetchedPullRequestsCount);
|
||||
this._logCount('Fetched pull requests', this.fetchedPullRequestsCount);
|
||||
}
|
||||
|
||||
private _logOperationsCount(): void {
|
||||
this._logCount('Operations performed', this._operationsCount);
|
||||
this._logCount('Operations performed', this.operationsCount);
|
||||
}
|
||||
|
||||
private _logCount(name: Readonly<string>, count: Readonly<number>): void {
|
||||
if (count > 0) {
|
||||
this._logger.info(`${name}:`, chalk.cyan(count));
|
||||
this._logger.info(`${name}:`, LoggerService.cyan(count));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -498,7 +498,10 @@ export class Statistics {
|
||||
const prefix = index === onlyValuesSet.length - 1 ? '└──' : '├──';
|
||||
|
||||
this._logCount(
|
||||
`${chalk.white(prefix)} ${value.name.padEnd(longestValue, ' ')}`,
|
||||
`${LoggerService.white(prefix)} ${value.name.padEnd(
|
||||
longestValue,
|
||||
' '
|
||||
)}`,
|
||||
value.count
|
||||
);
|
||||
}
|
||||
|
||||
@@ -22,10 +22,10 @@ export enum Option {
|
||||
AnyOfLabels = 'any-of-labels',
|
||||
OperationsPerRun = 'operations-per-run',
|
||||
RemoveStaleWhenUpdated = 'remove-stale-when-updated',
|
||||
RemoveIssueStaleWhenUpdated = 'remove-issue-stale-when-updated',
|
||||
RemovePrStaleWhenUpdated = 'remove-pr-stale-when-updated',
|
||||
DebugOnly = 'debug-only',
|
||||
Ascending = 'ascending',
|
||||
SkipStaleIssueMessage = 'skip-stale-issue-message',
|
||||
SkipStalePrMessage = 'skip-stale-pr-message',
|
||||
DeleteBranch = 'delete-branch',
|
||||
StartDate = 'start-date',
|
||||
ExemptMilestones = 'exempt-milestones',
|
||||
@@ -40,5 +40,11 @@ export enum Option {
|
||||
ExemptAllAssignees = 'exempt-all-assignees',
|
||||
ExemptAllIssueAssignees = 'exempt-all-issue-assignees',
|
||||
ExemptAllPrAssignees = 'exempt-all-pr-assignees',
|
||||
EnableStatistics = 'enable-statistics'
|
||||
EnableStatistics = 'enable-statistics',
|
||||
LabelsToRemoveWhenUnstale = 'labels-to-remove-when-unstale',
|
||||
LabelsToAddWhenUnstale = 'labels-to-add-when-unstale',
|
||||
IgnoreUpdates = 'ignore-updates',
|
||||
IgnoreIssueUpdates = 'ignore-issue-updates',
|
||||
IgnorePrUpdates = 'ignore-pr-updates',
|
||||
ExemptDraftPr = 'exempt-draft-pr'
|
||||
}
|
||||
|
||||
14
src/functions/clean-label.ts
Normal file
14
src/functions/clean-label.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import deburr from 'lodash.deburr';
|
||||
import {CleanLabel} from '../types/clean-label';
|
||||
|
||||
/**
|
||||
* @description
|
||||
* Clean a label by lowercasing it and deburring it for consistency
|
||||
*
|
||||
* @param {string} label A raw GitHub label
|
||||
*
|
||||
* @return {string} A lowercased, deburred version of the passed in label
|
||||
*/
|
||||
export function cleanLabel(label: Readonly<string>): CleanLabel {
|
||||
return deburr(label.toLowerCase());
|
||||
}
|
||||
@@ -7,9 +7,9 @@ describe('isLabeled()', (): void => {
|
||||
|
||||
describe('when the given issue contains no label', (): void => {
|
||||
beforeEach((): void => {
|
||||
issue = ({
|
||||
issue = {
|
||||
labels: []
|
||||
} as unknown) as Issue;
|
||||
} as unknown as Issue;
|
||||
});
|
||||
|
||||
describe('when the given label is a simple label', (): void => {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import deburr from 'lodash.deburr';
|
||||
import {Issue} from '../classes/issue';
|
||||
import {ILabel} from '../interfaces/label';
|
||||
import {CleanLabel} from '../types/clean-label';
|
||||
import {cleanLabel} from './clean-label';
|
||||
|
||||
/**
|
||||
* @description
|
||||
@@ -20,7 +19,3 @@ export function isLabeled(
|
||||
return cleanLabel(label) === cleanLabel(issueLabel.name);
|
||||
});
|
||||
}
|
||||
|
||||
function cleanLabel(label: Readonly<string>): CleanLabel {
|
||||
return deburr(label.toLowerCase());
|
||||
}
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
export interface IAssignee {
|
||||
login: string;
|
||||
}
|
||||
// @todo improve to include the notion of team?
|
||||
interface IAssignee {
|
||||
type: string;
|
||||
}
|
||||
|
||||
export interface IUserAssignee extends IAssignee {
|
||||
login: string;
|
||||
type: 'User' | string;
|
||||
}
|
||||
|
||||
export type Assignee = IUserAssignee;
|
||||
|
||||
@@ -2,4 +2,5 @@ import {IUser} from './user';
|
||||
|
||||
export interface IComment {
|
||||
user: IUser;
|
||||
body: string;
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import {IsoDateString} from '../types/iso-date-string';
|
||||
import {IAssignee} from './assignee';
|
||||
import {ILabel} from './label';
|
||||
import {IMilestone} from './milestone';
|
||||
|
||||
export interface IIssue {
|
||||
title: string;
|
||||
number: number;
|
||||
created_at: IsoDateString;
|
||||
updated_at: IsoDateString;
|
||||
labels: ILabel[];
|
||||
pull_request: Object | null | undefined;
|
||||
state: string;
|
||||
locked: boolean;
|
||||
milestone: IMilestone | undefined;
|
||||
assignees: IAssignee[];
|
||||
}
|
||||
import {IsoDateString} from '../types/iso-date-string';
|
||||
import {Assignee} from './assignee';
|
||||
import {ILabel} from './label';
|
||||
import {IMilestone} from './milestone';
|
||||
|
||||
export interface IIssue {
|
||||
title: string;
|
||||
number: number;
|
||||
created_at: IsoDateString;
|
||||
updated_at: IsoDateString;
|
||||
labels: ILabel[];
|
||||
pull_request: Object | null | undefined;
|
||||
state: string;
|
||||
locked: boolean;
|
||||
milestone: IMilestone | undefined;
|
||||
assignees: Assignee[];
|
||||
}
|
||||
|
||||
@@ -30,8 +30,6 @@ export interface IIssuesProcessorOptions {
|
||||
removePrStaleWhenUpdated: boolean | undefined;
|
||||
debugOnly: boolean;
|
||||
ascending: boolean;
|
||||
skipStaleIssueMessage: boolean;
|
||||
skipStalePrMessage: boolean;
|
||||
deleteBranch: boolean;
|
||||
startDate: IsoOrRfcDateString | undefined; // Should be ISO 8601 or RFC 2822
|
||||
exemptMilestones: string;
|
||||
@@ -47,4 +45,10 @@ export interface IIssuesProcessorOptions {
|
||||
exemptAllIssueAssignees: boolean | undefined;
|
||||
exemptAllPrAssignees: boolean | undefined;
|
||||
enableStatistics: boolean;
|
||||
labelsToRemoveWhenUnstale: string;
|
||||
labelsToAddWhenUnstale: string;
|
||||
ignoreUpdates: boolean;
|
||||
ignoreIssueUpdates: boolean | undefined;
|
||||
ignorePrUpdates: boolean | undefined;
|
||||
exemptDraftPr: boolean;
|
||||
}
|
||||
|
||||
@@ -3,4 +3,5 @@ export interface IPullRequest {
|
||||
head: {
|
||||
ref: string;
|
||||
};
|
||||
draft: boolean;
|
||||
}
|
||||
|
||||
42
src/main.ts
42
src/main.ts
@@ -2,12 +2,19 @@ import * as core from '@actions/core';
|
||||
import {IssuesProcessor} from './classes/issues-processor';
|
||||
import {isValidDate} from './functions/dates/is-valid-date';
|
||||
import {IIssuesProcessorOptions} from './interfaces/issues-processor-options';
|
||||
import {Issue} from './classes/issue';
|
||||
|
||||
async function _run(): Promise<void> {
|
||||
try {
|
||||
const args = _getAndValidateArgs();
|
||||
|
||||
await new IssuesProcessor(args).processIssues();
|
||||
const issueProcessor: IssuesProcessor = new IssuesProcessor(args);
|
||||
await issueProcessor.processIssues();
|
||||
|
||||
await processOutput(
|
||||
issueProcessor.staleIssues,
|
||||
issueProcessor.closedIssues
|
||||
);
|
||||
} catch (error) {
|
||||
core.error(error);
|
||||
core.setFailed(error.message);
|
||||
@@ -50,15 +57,13 @@ function _getAndValidateArgs(): IIssuesProcessorOptions {
|
||||
core.getInput('remove-stale-when-updated') === 'false'
|
||||
),
|
||||
removeIssueStaleWhenUpdated: _toOptionalBoolean(
|
||||
core.getInput('remove-issue-stale-when-updated')
|
||||
'remove-issue-stale-when-updated'
|
||||
),
|
||||
removePrStaleWhenUpdated: _toOptionalBoolean(
|
||||
core.getInput('remove-pr-stale-when-updated')
|
||||
'remove-pr-stale-when-updated'
|
||||
),
|
||||
debugOnly: core.getInput('debug-only') === 'true',
|
||||
ascending: core.getInput('ascending') === 'true',
|
||||
skipStalePrMessage: core.getInput('skip-stale-pr-message') === 'true',
|
||||
skipStaleIssueMessage: core.getInput('skip-stale-issue-message') === 'true',
|
||||
deleteBranch: core.getInput('delete-branch') === 'true',
|
||||
startDate:
|
||||
core.getInput('start-date') !== ''
|
||||
@@ -76,7 +81,13 @@ function _getAndValidateArgs(): IIssuesProcessorOptions {
|
||||
exemptAllAssignees: core.getInput('exempt-all-assignees') === 'true',
|
||||
exemptAllIssueAssignees: _toOptionalBoolean('exempt-all-issue-assignees'),
|
||||
exemptAllPrAssignees: _toOptionalBoolean('exempt-all-pr-assignees'),
|
||||
enableStatistics: core.getInput('enable-statistics') === 'true'
|
||||
enableStatistics: core.getInput('enable-statistics') === 'true',
|
||||
labelsToRemoveWhenUnstale: core.getInput('labels-to-remove-when-unstale'),
|
||||
labelsToAddWhenUnstale: core.getInput('labels-to-add-when-unstale'),
|
||||
ignoreUpdates: core.getInput('ignore-updates') === 'true',
|
||||
ignoreIssueUpdates: _toOptionalBoolean('ignore-issue-updates'),
|
||||
ignorePrUpdates: _toOptionalBoolean('ignore-pr-updates'),
|
||||
exemptDraftPr: core.getInput('exempt-draft-pr') === 'true'
|
||||
};
|
||||
|
||||
for (const numberInput of [
|
||||
@@ -105,6 +116,25 @@ function _getAndValidateArgs(): IIssuesProcessorOptions {
|
||||
return args;
|
||||
}
|
||||
|
||||
async function processOutput(
|
||||
staledIssues: Issue[],
|
||||
closedIssues: Issue[]
|
||||
): Promise<void> {
|
||||
core.setOutput('staled-issues-prs', JSON.stringify(staledIssues));
|
||||
core.setOutput('closed-issues-prs', JSON.stringify(closedIssues));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description
|
||||
* From an argument name, get the value as an optional boolean
|
||||
* This is very useful for all the arguments that override others
|
||||
* It will allow us to easily use the original one when the return value is `undefined`
|
||||
* Which is different from `true` or `false` that consider the argument as set
|
||||
*
|
||||
* @param {Readonly<string>} argumentName The name of the argument to check
|
||||
*
|
||||
* @returns {boolean | undefined} The value matching the given argument name
|
||||
*/
|
||||
function _toOptionalBoolean(
|
||||
argumentName: Readonly<string>
|
||||
): boolean | undefined {
|
||||
|
||||
52
src/services/logger.service.ts
Normal file
52
src/services/logger.service.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import styles, {Modifier, ForegroundColor} from 'ansi-styles';
|
||||
|
||||
type Message = string | number | boolean;
|
||||
|
||||
export class LoggerService {
|
||||
static whiteBright(message: Readonly<Message>): string {
|
||||
return this._format(message, 'whiteBright');
|
||||
}
|
||||
|
||||
static yellowBright(message: Readonly<Message>): string {
|
||||
return this._format(message, 'yellowBright');
|
||||
}
|
||||
|
||||
static magenta(message: Readonly<Message>): string {
|
||||
return this._format(message, 'magenta');
|
||||
}
|
||||
|
||||
static cyan(message: Readonly<Message>): string {
|
||||
return this._format(message, 'cyan');
|
||||
}
|
||||
|
||||
static yellow(message: Readonly<Message>): string {
|
||||
return this._format(message, 'yellow');
|
||||
}
|
||||
|
||||
static white(message: Readonly<Message>): string {
|
||||
return this._format(message, 'white');
|
||||
}
|
||||
|
||||
static green(message: Readonly<Message>): string {
|
||||
return this._format(message, 'green');
|
||||
}
|
||||
|
||||
static red(message: Readonly<Message>): string {
|
||||
return this._format(message, 'red');
|
||||
}
|
||||
|
||||
static blue(message: Readonly<Message>): string {
|
||||
return this._format(message, 'blue');
|
||||
}
|
||||
|
||||
static bold(message: Readonly<Message>): string {
|
||||
return this._format(message, 'bold');
|
||||
}
|
||||
|
||||
private static _format(
|
||||
message: Readonly<Message>,
|
||||
style: keyof Modifier | keyof ForegroundColor
|
||||
): string {
|
||||
return `${styles[style].open}${message}${styles[style].close}`;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user