Skip to content

Commit 068e1f7

Browse files
committed
Update readme, definition and documentation
1 parent 6ca1e08 commit 068e1f7

File tree

8 files changed

+68
-103
lines changed

8 files changed

+68
-103
lines changed

README.md

+23-33
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,45 @@
1-
# PR TaskList Completed Checker Action
2-
A GitHub action that checks if all tasks are completed in the pull requests.
1+
# WP Media PR Checklist Action
2+
A GitHub action that performs checks on PR descriptions, according to WP Media PR template from https://github.com/wp-media/.github.
3+
4+
This action runs the following tests:
5+
- Description contains at least one text line that is not the one of the template.
6+
- Documentation contains at least one text line that is not one from the template.
7+
- At least one type of change is set.
8+
- All items in the checklist are ticked.
39

410
## Usage
511

612
### Create a workflow
713
```yml
8-
name: 'PR TaskList Completed Checker'
14+
name: 'PR Checklist'
915
on:
1016
pull_request:
1117
types: [edited, opened, synchronize, reopened]
1218

1319
jobs:
14-
task-check:
20+
pr-checklist:
1521
runs-on: ubuntu-latest
1622
steps:
17-
- uses: venkatsarvesh/pr-tasks-completed-action@v1.0.0
23+
- uses: wp-media/pr-checklist-action@test/adaptation-to-WPMedia-template
1824
with:
19-
repo-token: "${{ secrets.GITHUB_TOKEN }}"
20-
```
21-
22-
### Check whether tasks are completed
23-
Add a pull request template to your repository (`.github/pull_request_template.md`).
24-
25-
For example:
26-
```markdown
27-
## Checklist
28-
- [ ] Completed code review
29-
- [ ] Ran unit tests
30-
- [ ] Completed e2e tests
31-
*Delete options that are not relevant.*
32-
33-
- [ ] New feature (non-breaking change which adds functionality).
34-
- [ ] Bug fix (non-breaking change which fixes an issue).
35-
- [ ] Enhancement (non-breaking change which improves an existing functionality).
36-
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as before).
25+
repo-token: "${{ secrets.PR_CHECKLIST_TOKEN }}"
3726
```
3827
39-
Create a pull request that contained tasks list to your repository. This will start a workflow automatically to check whether tasks are completed.
40-
41-
Every update on a pull request will start a new workflow automatically to check pending tasks.
28+
### Token
4229
43-
All tasks completed:
44-
![All tasks completed](images/success.png)
30+
The PR_CHECKLIST_TOKEN must provide read access to Pull Requests of the repository this action is used in.
4531
46-
Some tasks are still pending:
32+
### Making the check mandatory to merge
4733
48-
![Some tasks are still pending](images/failure.png)
34+
Once the workflow file is commited, you can make the success mandatory before merging through branch protection:
35+
- Require status checks to pass before merging
36+
- Require branches to be up to date before merging
37+
- Search and select `pr-checklist`
4938

50-
You can check a list of uncompleted tasks at the Actions page on clicking Details.
51-
![List of pending tasks](images/pending_tasks.png)
39+
## Build
5240

41+
Modification to the sources must be done in the `src` folder.
42+
Once the changes are done, `run npm run build && npm run pack` to update the `lib` & `dist` folder.
5343

5444
## :memo: Licence
55-
MIT
45+
MIT

action.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
name: "PR TaskList Completed Checker"
2-
description: "An action that checks if all the tasks(if any) in the PR body are completed"
1+
name: "WP Media PR Checklist Action"
2+
description: "A GitHub action that performs checks on PR descriptions, according to WP Media PR template"
33
inputs:
44
repo-token:
5-
description: "The GITHUB_TOKEN secret"
5+
description: "The PR_CHECKLIST_TOKEN secret token with read access to Pull Requests."
66
required: true
77
runs:
88
using: "node20"

dist/index.js

+12-20
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,9 @@ const core = __nccwpck_require__(9935);
2020
const github = __nccwpck_require__(2835);
2121
const utils_1 = __nccwpck_require__(963);
2222
/**
23-
* This action will
24-
* 1. Read the PR body
25-
* 2. Get all the tasks
26-
* 3. Checks if all tasks are completed(checked)
27-
* 4. Return
28-
* success if
29-
* there is no pr body
30-
* no tasks in pr body
31-
* all tasks are completed(checked)
32-
* failure if
33-
* there are any pending tasks to be complated
23+
* This action will retrieve the PR body and
24+
* run custom tests. If one of them fails,
25+
* the action fails and returns immediately.
3426
*/
3527
function run() {
3628
var _a;
@@ -158,10 +150,10 @@ run();
158150
Object.defineProperty(exports, "__esModule", ({ value: true }));
159151
class Util {
160152
/**
161-
* This method will read the input string and match it with uncheck mark([ ]).
153+
* This method will read the input string and match it with uncheck mark(- [ ]).
162154
* Gets the pending tasks
163155
*
164-
* @param body PR body that has tasks
156+
* @param body PR body portion that has tasks
165157
*
166158
* Returns
167159
* empty string if there are no pending tasks
@@ -187,10 +179,10 @@ class Util {
187179
return responseString;
188180
}
189181
/**
190-
* This method will read the input string and match it with check mark([x]).
182+
* This method will read the input string and match it with check mark(- [x]).
191183
* Gets the completed tasks
192184
*
193-
* @param body PR body that has tasks
185+
* @param body PR body portion that has tasks
194186
*
195187
* Returns
196188
* empty string if there are no completed tasks
@@ -216,14 +208,14 @@ class Util {
216208
return responseString;
217209
}
218210
/**
219-
* This method will read the input string and match it with check mark([x]).
220-
* Gets the completed tasks
211+
* This method will extract the portion from a string between start and end strings.
221212
*
222-
* @param body PR body that has tasks
213+
* @param body The main string to extract from
214+
* @param startString The beginning of the portion to isolate. It will be excluded from the result.
215+
* @param endString optional The end of the portion to isolate. It will be excluded from the result. If not provided, the portion will go until end of file.
223216
*
224217
* Returns
225-
* empty string if there are no completed tasks
226-
* completed tasks string
218+
* If found, the sub-string in between startString and endString. Otherwise, an empty string.
227219
*/
228220
static extractString(body, startString, endString) {
229221
const startIndex = body.indexOf(startString);

lib/index.js

+3-11
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,9 @@ const core = require("@actions/core");
1313
const github = require("@actions/github");
1414
const utils_1 = require("./utils");
1515
/**
16-
* This action will
17-
* 1. Read the PR body
18-
* 2. Get all the tasks
19-
* 3. Checks if all tasks are completed(checked)
20-
* 4. Return
21-
* success if
22-
* there is no pr body
23-
* no tasks in pr body
24-
* all tasks are completed(checked)
25-
* failure if
26-
* there are any pending tasks to be complated
16+
* This action will retrieve the PR body and
17+
* run custom tests. If one of them fails,
18+
* the action fails and returns immediately.
2719
*/
2820
function run() {
2921
var _a;

lib/utils.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
Object.defineProperty(exports, "__esModule", { value: true });
33
class Util {
44
/**
5-
* This method will read the input string and match it with uncheck mark([ ]).
5+
* This method will read the input string and match it with uncheck mark(- [ ]).
66
* Gets the pending tasks
77
*
8-
* @param body PR body that has tasks
8+
* @param body PR body portion that has tasks
99
*
1010
* Returns
1111
* empty string if there are no pending tasks
@@ -31,10 +31,10 @@ class Util {
3131
return responseString;
3232
}
3333
/**
34-
* This method will read the input string and match it with check mark([x]).
34+
* This method will read the input string and match it with check mark(- [x]).
3535
* Gets the completed tasks
3636
*
37-
* @param body PR body that has tasks
37+
* @param body PR body portion that has tasks
3838
*
3939
* Returns
4040
* empty string if there are no completed tasks
@@ -60,14 +60,14 @@ class Util {
6060
return responseString;
6161
}
6262
/**
63-
* This method will read the input string and match it with check mark([x]).
64-
* Gets the completed tasks
63+
* This method will extract the portion from a string between start and end strings.
6564
*
66-
* @param body PR body that has tasks
65+
* @param body The main string to extract from
66+
* @param startString The beginning of the portion to isolate. It will be excluded from the result.
67+
* @param endString optional The end of the portion to isolate. It will be excluded from the result. If not provided, the portion will go until end of file.
6768
*
6869
* Returns
69-
* empty string if there are no completed tasks
70-
* completed tasks string
70+
* If found, the sub-string in between startString and endString. Otherwise, an empty string.
7171
*/
7272
static extractString(body, startString, endString) {
7373
const startIndex = body.indexOf(startString);

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "pr-tasks-completed-action",
2+
"name": "wpm-pr-checklist-action",
33
"version": "1.0.0",
44
"description": "",
55
"main": "index.js",
@@ -10,15 +10,15 @@
1010
},
1111
"repository": {
1212
"type": "git",
13-
"url": "git+https://github.com/venkatsarvesh/pr-tasks-completed-action.git"
13+
"url": "git+https://github.com/wp-media/pr-checklist-action.git"
1414
},
1515
"keywords": [],
1616
"author": "",
1717
"license": "ISC",
1818
"bugs": {
19-
"url": "https://github.com/venkatsarvesh/pr-tasks-completed-action/issues"
19+
"url": "https://github.com/wp-media/pr-checklist-action/issues"
2020
},
21-
"homepage": "https://github.com/venkatsarvesh/pr-tasks-completed-action#readme",
21+
"homepage": "https://github.com/wp-media/pr-checklist-action#readme",
2222
"dependencies": {
2323
"@actions/core": "^1.2.4",
2424
"@actions/github": "^4.0.0",

src/index.ts

+5-14
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,9 @@ import * as github from '@actions/github'
33
import Util from './utils'
44

55
/**
6-
* This action will
7-
* 1. Read the PR body
8-
* 2. Get all the tasks
9-
* 3. Checks if all tasks are completed(checked)
10-
* 4. Return
11-
* success if
12-
* there is no pr body
13-
* no tasks in pr body
14-
* all tasks are completed(checked)
15-
* failure if
16-
* there are any pending tasks to be complated
6+
* This action will retrieve the PR body and
7+
* run custom tests. If one of them fails,
8+
* the action fails and returns immediately.
179
*/
1810

1911
async function run(): Promise<void> {
@@ -26,6 +18,7 @@ async function run(): Promise<void> {
2618
core.info("PR don't have tasks to check");
2719
return
2820
}
21+
2922
// Ensure Description is modified
3023
core.debug('Checking Description...');
3124
let startString = "# Description";
@@ -90,7 +83,6 @@ async function run(): Promise<void> {
9083
core.setFailed(`Type of change section not found.`);
9184
return;
9285
}
93-
9486
// get ticked tasks
9587
core.debug('Getting a list of ticked tasks: ');
9688
let typeOfChange = Util.getCompletedTasks(typeOfChangePortion);
@@ -114,8 +106,7 @@ async function run(): Promise<void> {
114106
core.setFailed(`Checklist section not found.`);
115107
return;
116108
}
117-
118-
// get ticked tasks
109+
// get unticked tasks
119110
core.debug('Getting a list of unticked tasks: ');
120111
let uncompletedTasks = Util.getUncompletedTasks(checklistPortion);
121112
core.debug(uncompletedTasks);

src/utils.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
export default class Util {
22

33
/**
4-
* This method will read the input string and match it with uncheck mark([ ]).
4+
* This method will read the input string and match it with uncheck mark(- [ ]).
55
* Gets the pending tasks
66
*
7-
* @param body PR body that has tasks
7+
* @param body PR body portion that has tasks
88
*
99
* Returns
1010
* empty string if there are no pending tasks
@@ -33,10 +33,10 @@ export default class Util {
3333
return responseString;
3434
}
3535
/**
36-
* This method will read the input string and match it with check mark([x]).
36+
* This method will read the input string and match it with check mark(- [x]).
3737
* Gets the completed tasks
3838
*
39-
* @param body PR body that has tasks
39+
* @param body PR body portion that has tasks
4040
*
4141
* Returns
4242
* empty string if there are no completed tasks
@@ -65,14 +65,14 @@ export default class Util {
6565
return responseString;
6666
}
6767
/**
68-
* This method will read the input string and match it with check mark([x]).
69-
* Gets the completed tasks
68+
* This method will extract the portion from a string between start and end strings.
7069
*
71-
* @param body PR body that has tasks
70+
* @param body The main string to extract from
71+
* @param startString The beginning of the portion to isolate. It will be excluded from the result.
72+
* @param endString optional The end of the portion to isolate. It will be excluded from the result. If not provided, the portion will go until end of file.
7273
*
7374
* Returns
74-
* empty string if there are no completed tasks
75-
* completed tasks string
75+
* If found, the sub-string in between startString and endString. Otherwise, an empty string.
7676
*/
7777
static extractString(body: string, startString: string, endString?: string): string {
7878
const startIndex = body.indexOf(startString);

0 commit comments

Comments
 (0)