Skip to content

Commit e6d4b8e

Browse files
authored
chore(ci): fix set failure for pr check (#14946)
1 parent ce689b5 commit e6d4b8e

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

.github/workflows/pr.yml

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
const regex = /^(rfc|feat|fix|refactor|ci|docs|chore)(\([a-z0-9-]+\))?:/;
2828
const m = title.match(regex);
2929
if (!m) {
30-
core.error('PR title is not semantic');
30+
core.setFailed('PR title is not semantic');
3131
core.setOutput('title', 'not-semantic');
3232
return;
3333
}
@@ -66,14 +66,14 @@ jobs:
6666
});
6767
core.setOutput('title', 'semantic');
6868
- name: Delete Comment
69-
if: steps.check.outputs.title == 'semantic'
69+
if: always() && steps.check.outputs.title == 'semantic'
7070
uses: everpcpc/comment-on-pr-action@v1
7171
with:
7272
token: ${{ github.token }}
7373
identifier: 'pr-assistant-title'
7474
delete: true
7575
- name: Comment on PR
76-
if: steps.check.outputs.title == 'not-semantic'
76+
if: always() && steps.check.outputs.title == 'not-semantic'
7777
uses: everpcpc/comment-on-pr-action@v1
7878
with:
7979
token: ${{ github.token }}
@@ -113,20 +113,20 @@ jobs:
113113
const body = context.payload.pull_request.body;
114114
const regex = /I hereby agree to the terms of the CLA available at: https:\/\/docs.databend.com\/dev\/policies\/cla\//;
115115
if (!regex.test(body)) {
116-
core.error('CLA is not signed');
116+
core.setFailed('CLA is not signed');
117117
core.setOutput('cla', 'not-signed');
118118
} else {
119119
core.setOutput('cla', 'signed');
120120
}
121121
- name: Delete Comment
122-
if: steps.check.outputs.cla == 'signed'
122+
if: always() && steps.check.outputs.cla == 'signed'
123123
uses: everpcpc/comment-on-pr-action@v1
124124
with:
125125
token: ${{ github.token }}
126126
identifier: 'pr-assistant-cla'
127127
delete: true
128128
- name: Comment on PR
129-
if: steps.check.outputs.cla == 'not-signed'
129+
if: always() && steps.check.outputs.cla == 'not-signed'
130130
uses: everpcpc/comment-on-pr-action@v1
131131
with:
132132
token: ${{ github.token }}
@@ -153,7 +153,6 @@ jobs:
153153
with:
154154
script: |
155155
const body = context.payload.pull_request.body;
156-
const regex = /- [x] /;
157156
let section = "summary";
158157
let testsChecked = false;
159158
let changesChecked = false;
@@ -166,14 +165,14 @@ jobs:
166165
continue;
167166
}
168167
if (section === "tests") {
169-
if (regex.test(line)) {
168+
if (line.startsWith("- [x] ")) {
170169
testsChecked = true;
171170
core.setOutput('tests', 'fulfilled');
172171
continue;
173172
}
174173
}
175174
if (section === "changes") {
176-
if (regex.test(line)) {
175+
if (line.startsWith("- [x] ")) {
177176
changesChecked = true;
178177
core.setOutput('changes', 'fulfilled');
179178
continue;
@@ -182,39 +181,41 @@ jobs:
182181
}
183182
if (!testsChecked) {
184183
core.setOutput('tests', 'not-fulfilled');
185-
core.error('Tests are not checked');
184+
core.setFailed('Tests are not checked');
186185
}
187186
if (!changesChecked) {
188187
core.setOutput('changes', 'not-fulfilled');
189-
core.error('Type of Changes are not checked');
188+
core.setFailed('Type of Changes are not checked');
190189
}
191190
- name: Delete Comment for Tests
192-
if: steps.check.outputs.tests == 'fullfilled'
191+
if: always() && steps.check.outputs.tests == 'fullfilled'
193192
uses: everpcpc/comment-on-pr-action@v1
194193
with:
195194
token: ${{ github.token }}
196195
identifier: 'pr-assistant-description-tests'
197196
delete: true
198197
- name: Delete Comment for Changes
199-
if: steps.check.outputs.changes == 'fullfilled'
198+
if: always() && steps.check.outputs.changes == 'fullfilled'
200199
uses: everpcpc/comment-on-pr-action@v1
201200
with:
202201
token: ${{ github.token }}
203202
identifier: 'pr-assistant-description-changes'
204203
delete: true
205204
- name: Comment on PR for Tests
206-
if: steps.check.outputs.tests != 'fullfilled'
205+
if: always() && steps.check.outputs.tests != 'fullfilled'
207206
uses: everpcpc/comment-on-pr-action@v1
208207
with:
209208
token: ${{ github.token }}
210209
identifier: 'pr-assistant-description-tests'
211210
body: |
212-
At least one test case must be checked in the PR description.
211+
At least one test kind must be checked in the PR description.
212+
@${{ github.event.pull_request.user.login }} please update it 🙏.
213213
- name: Comment on PR for Changes
214-
if: steps.check.outputs.changes != 'fullfilled'
214+
if: always() && steps.check.outputs.changes != 'fullfilled'
215215
uses: everpcpc/comment-on-pr-action@v1
216216
with:
217217
token: ${{ github.token }}
218218
identifier: 'pr-assistant-description-changes'
219219
body: |
220220
At least one type of change must be checked in the PR description.
221+
@${{ github.event.pull_request.user.login }} please update it 🙏.

0 commit comments

Comments
 (0)