Skip to content

Commit 918d87e

Browse files
feat: Add actions for checking title and description (#3631)
* Add action for checking title * Add action for checking title * Add action for checking title * Add action for checking title * Add action for checking title * Add action for checking title * Add action for checking title * Add action for checking title * Add action for checking title * Add action for checking title * Add action for checking title * Add action for checking title * Add action for checking title * Add action for checking title * Check PR description * Check PR description * Check PR description * Check PR description * Test description * Test description * Test description * Test description * Test description * Test description * Test description * Test description * Test description * Test description * Test description * Test description * Test description * Test description * Test description * Test description * Test description * Test description * Test description * Test GH actions * Test GH actions * Test GH actions * Test GH actions * Test GH actions * Test GH actions * Test GH actions * Test GH actions * Test GH actions * Test GH actions * Test GH actions * Test GH actions * Test GH actions * Test GH actions * Test GH actions * Test GH actions * Test GH actions * Test GH actions * Added documentation and PR correction * Docs corrected
1 parent 86b9ab4 commit 918d87e

File tree

5 files changed

+121
-0
lines changed

5 files changed

+121
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Description Check
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, synchronize, reopened, ready_for_review]
6+
7+
jobs:
8+
check-description:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/github-script@v6
12+
with:
13+
script: |
14+
const prBody = context?.payload?.pull_request?.body;
15+
const descriptionSubtitle = "Changes proposed in this pull request";
16+
const subString = prBody.substring(prBody.search(/Changes proposed in this pull request/) + descriptionSubtitle.length, prBody.search(/Related issue/));
17+
const regExp = /[a-zA-Z]/g;
18+
if(regExp.test(subString)){
19+
core.info('SUCCESS: Some description found');
20+
} else {
21+
core.setFailed('FAILED: No description found!');
22+
}

.github/workflows/pr-dod-check.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Definition of done Check
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, synchronize, reopened, ready_for_review]
6+
7+
jobs:
8+
check-unchecked-tasks:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/github-script@v6
12+
with:
13+
script: |
14+
const getPendingTasks = (body) => {
15+
let responseString = "";
16+
try {
17+
const uncompletedTasks = body.match(/(- \[[ ]\].+)/g);
18+
if (uncompletedTasks != undefined) {
19+
responseString += 'Uncompleted Tasks\n';
20+
uncompletedTasks.forEach(u => {
21+
responseString += `${u}\n`;
22+
});
23+
}
24+
} catch (e) {
25+
responseString = "";
26+
}
27+
return responseString;
28+
}
29+
(async () => {
30+
try {
31+
const prBody = context?.payload?.pull_request?.body;
32+
if (!prBody) {
33+
core.info("PR don't have tasks to check");
34+
return
35+
}
36+
core.debug('Getting a list of uncompleted tasks: ');
37+
let pendingTasks = getPendingTasks(prBody);
38+
core.debug(pendingTasks);
39+
let isTaskListCompleted = false;
40+
if (!pendingTasks) {
41+
isTaskListCompleted = true;
42+
}
43+
core.debug(`All tasks completed: ${isTaskListCompleted}`);
44+
45+
if (isTaskListCompleted) {
46+
core.info(`SUCCESS: All tasks completed`);
47+
return;
48+
} else {
49+
core.setFailed(`FAILED: Some tasks are still pending! \n${pendingTasks}\nLength: ${pendingTasks.length}`);
50+
}
51+
} catch (error) {
52+
core.setFailed(error.message)
53+
}
54+
})();
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Check linked issues
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, synchronize, reopened, ready_for_review]
6+
7+
jobs:
8+
check-linked-issue:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
issues: read
12+
steps:
13+
- uses: nearform-actions/github-action-check-linked-issues@v1
14+
id: check-linked-issues
15+
with:
16+
comment: false
17+
- name: Get the output
18+
run: echo "Number of linked issues ${{ steps.check-linked-issues.outputs.linked_issues_count }}"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: PR Title Check
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, synchronize, reopened, ready_for_review]
6+
7+
jobs:
8+
check-pr-type:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: amannn/action-semantic-pull-request@47b15d52c5c30e94a17ec87eb8dd51ff5221fed9
12+
env:
13+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14+
with:
15+
types: |
16+
feat
17+
fix
18+
docs
19+
refactor
20+
test
21+
chore
22+
requireScope: false
23+
subjectPattern: ^([A-Z].*[^.]|bump .*)$

docs/contributor/testing-strategy.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ Each pull request (PR) to the repository triggers CI/CD jobs that verify the Bus
1515
- `PR Unit and Component Tests / run-unit-and-component-test` - Performs unit and component tests of Busola.
1616
- `Lint Markdown Links PR / markdown-link-check` - Checks links in documentation.
1717
- `CodeQL / Analyze (javascript)` - Code quality static code check.
18+
- `PR Title Check / check-pr-type` - Checks the PR title prefix.
19+
- `Check linked issues / check-linked-issue` - Checks if PR is linked to the issue.
20+
- `Definition of done Check / check-unchecked-tasks` - Checks if all definitions of done boxes are checked.
21+
- `Description Check / check-description` - Checks if the description is not empty.
1822

1923
After the pull request is merged, the following CI/CD jobs are executed:
2024

0 commit comments

Comments
 (0)