Skip to content

Commit d6d9770

Browse files
committed
Add input one_pass_all_pass
If "true", as long as one commit in the pull-request passes the check, all pass. Signed-off-by: Tim Zhang <[email protected]>
1 parent 171c827 commit d6d9770

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,14 @@ jobs:
6666
commits: ${{ steps.get-pr-commits.outputs.commits }}
6767
pattern: '\s*Fixes\s*:?\s*(#\d+|github\.com\/kata-containers\/[a-z-.]*#\d+)'
6868
error: 'No "Fixes" found'
69+
one_pass_all_pass: 'true'
6970

7071
- name: Check subsystem
7172
if: ${{ success() || failure() }}
7273
uses: tim-actions/[email protected]
7374
with:
7475
commits: ${{ steps.get-pr-commits.outputs.commits }}
75-
pattern: '^[\h]*([^:\h]+)[\h]*:'
76+
pattern: '^[\h]*([^:\h\n]+)[\h]*:'
7677
error: 'Failed to find subsystem in subject'
7778

7879

action.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,18 @@ inputs:
1616
description: 'A error message which will be returned in case of an error.'
1717
required: true
1818
pre_error:
19-
description: 'A error message which will be showed in the begin of errors'
19+
description: 'A error message which will be showed in the begin of errors.'
2020
required: false
2121
default: ''
2222
post_error:
23-
description: 'A error message which will be showed in the end of errors'
23+
description: 'A error message which will be showed in the end of errors.'
2424
required: false
2525
default: ''
26+
one_pass_all_pass:
27+
description: 'If "true", as long as one commit in the pull-request passes the check, all pass.'
28+
required: false
29+
default: "false"
30+
2631
runs:
2732
using: node12
2833
main: dist/index.js

dist/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ const commitMessageChecker = __importStar(__webpack_require__(413));
112112
function run() {
113113
return __awaiter(this, void 0, void 0, function* () {
114114
try {
115+
const onePassAllPass = core.getInput('one_pass_all_pass');
115116
const commitsString = core.getInput('commits');
116117
const commits = JSON.parse(commitsString);
117118
const checkerArguments = inputHelper.getInputs();
@@ -125,6 +126,9 @@ function run() {
125126
failed.push({ sha, message: errMsg });
126127
}
127128
}
129+
if (onePassAllPass === 'true' && commits.length > failed.length) {
130+
return;
131+
}
128132
if (failed.length > 0) {
129133
const summary = inputHelper.genOutput(failed, preErrorMsg, postErrorMsg);
130134
core.setFailed(summary);

src/main.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import * as commitMessageChecker from './commit-message-checker'
2727
*/
2828
async function run(): Promise<void> {
2929
try {
30+
const onePassAllPass = core.getInput('one_pass_all_pass')
3031
const commitsString = core.getInput('commits')
3132
const commits = JSON.parse(commitsString)
3233
const checkerArguments = inputHelper.getInputs()
@@ -45,12 +46,15 @@ async function run(): Promise<void> {
4546
}
4647
}
4748

49+
if (onePassAllPass === 'true' && commits.length > failed.length) {
50+
return
51+
}
52+
4853
if (failed.length > 0) {
4954
const summary = inputHelper.genOutput(failed, preErrorMsg, postErrorMsg)
5055
core.setFailed(summary)
5156
}
5257

53-
5458
} catch (error) {
5559
core.error(error)
5660
core.setFailed(error.message)

0 commit comments

Comments
 (0)