Skip to content

Commit ce689b5

Browse files
authored
chore(ci): add pr summary check (#14944)
1 parent a10bd38 commit ce689b5

File tree

2 files changed

+96
-13
lines changed

2 files changed

+96
-13
lines changed

.github/workflows/merge_group.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: "PR Assistant"
2+
3+
on:
4+
merge_group:
5+
6+
jobs:
7+
title:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Skip title check
11+
shell: bash
12+
run: exit 0
13+
14+
cla:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Skip CLA check
18+
shell: bash
19+
run: exit 0

.github/workflows/pr.yml

Lines changed: 77 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ on:
99
- edited
1010
- ready_for_review
1111
- converted_to_draft
12-
merge_group:
1312

1413
permissions:
1514
pull-requests: write
@@ -20,15 +19,10 @@ jobs:
2019
runs-on: ubuntu-latest
2120
steps:
2221
- name: Check PR title if not sematic
23-
uses: actions/github-script@v6
22+
uses: actions/github-script@v7
2423
id: check
2524
with:
2625
script: |
27-
if (!context.payload.pull_request) {
28-
core.info('PR payload is null');
29-
core.setOutput('title', 'ignore');
30-
return;
31-
}
3226
const title = context.payload.pull_request.title;
3327
const regex = /^(rfc|feat|fix|refactor|ci|docs|chore)(\([a-z0-9-]+\))?:/;
3428
const m = title.match(regex);
@@ -112,15 +106,10 @@ jobs:
112106
runs-on: ubuntu-latest
113107
steps:
114108
- name: Check CLA if not signed
115-
uses: actions/github-script@v6
109+
uses: actions/github-script@v7
116110
id: check
117111
with:
118112
script: |
119-
if (!context.payload.pull_request) {
120-
core.info('PR payload is null');
121-
core.setOutput('cla', 'ignore');
122-
return;
123-
}
124113
const body = context.payload.pull_request.body;
125114
const regex = /I hereby agree to the terms of the CLA available at: https:\/\/docs.databend.com\/dev\/policies\/cla\//;
126115
if (!regex.test(body)) {
@@ -154,3 +143,78 @@ jobs:
154143
155144
- Close #issue
156145
```
146+
147+
description:
148+
runs-on: ubuntu-latest
149+
steps:
150+
- name: Check PR description checkbox
151+
uses: actions/github-script@v7
152+
id: check
153+
with:
154+
script: |
155+
const body = context.payload.pull_request.body;
156+
const regex = /- [x] /;
157+
let section = "summary";
158+
let testsChecked = false;
159+
let changesChecked = false;
160+
for (const line of body.split('\n')) {
161+
if (line ==="## Tests") {
162+
section = "tests";
163+
continue;
164+
} else if (line === "## Type of change") {
165+
section = "changes";
166+
continue;
167+
}
168+
if (section === "tests") {
169+
if (regex.test(line)) {
170+
testsChecked = true;
171+
core.setOutput('tests', 'fulfilled');
172+
continue;
173+
}
174+
}
175+
if (section === "changes") {
176+
if (regex.test(line)) {
177+
changesChecked = true;
178+
core.setOutput('changes', 'fulfilled');
179+
continue;
180+
}
181+
}
182+
}
183+
if (!testsChecked) {
184+
core.setOutput('tests', 'not-fulfilled');
185+
core.error('Tests are not checked');
186+
}
187+
if (!changesChecked) {
188+
core.setOutput('changes', 'not-fulfilled');
189+
core.error('Type of Changes are not checked');
190+
}
191+
- name: Delete Comment for Tests
192+
if: steps.check.outputs.tests == 'fullfilled'
193+
uses: everpcpc/comment-on-pr-action@v1
194+
with:
195+
token: ${{ github.token }}
196+
identifier: 'pr-assistant-description-tests'
197+
delete: true
198+
- name: Delete Comment for Changes
199+
if: steps.check.outputs.changes == 'fullfilled'
200+
uses: everpcpc/comment-on-pr-action@v1
201+
with:
202+
token: ${{ github.token }}
203+
identifier: 'pr-assistant-description-changes'
204+
delete: true
205+
- name: Comment on PR for Tests
206+
if: steps.check.outputs.tests != 'fullfilled'
207+
uses: everpcpc/comment-on-pr-action@v1
208+
with:
209+
token: ${{ github.token }}
210+
identifier: 'pr-assistant-description-tests'
211+
body: |
212+
At least one test case must be checked in the PR description.
213+
- name: Comment on PR for Changes
214+
if: steps.check.outputs.changes != 'fullfilled'
215+
uses: everpcpc/comment-on-pr-action@v1
216+
with:
217+
token: ${{ github.token }}
218+
identifier: 'pr-assistant-description-changes'
219+
body: |
220+
At least one type of change must be checked in the PR description.

0 commit comments

Comments
 (0)