Skip to content

Commit

Permalink
ci: include better information in validate-pr action errors (#1634)
Browse files Browse the repository at this point in the history
* add release to valid pr types

* add more info to error messages
  • Loading branch information
a-b-r-o-w-n authored Nov 22, 2019
1 parent 7e84f05 commit 4be03bf
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions .github/actions/conventional-pr/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const validTypes = [
'ci',
'chore',
'revert',
'release',
];

const typeList = validTypes.map(t => ` - ${t}`).join('\n');
Expand All @@ -28,22 +29,25 @@ export function validateTitle(title: string): ValidationResult {
const hastype = validTypes.some(t => title.startsWith(`${t}: `));

if (!hastype) {
core.info(
`[Title] Missing type in title. Choose from the following:\n${typeList}`
errors.push(
`[Title] Must start with type (ex. 'feat: ').\nThe valid types are:\n${typeList}`
);
errors.push("[Title] Must start with type. i.e. 'feat: '");
}

return errors;
}

const refMatch = /(refs?|close(d|s)?|fix(ed|es)?) \#\d+/i;
const helpLink =
'https://help.github.com/en/github/managing-your-work-on-github/closing-issues-using-keywords';

export function validateBody(body: string): ValidationResult {
let errors: ValidationResult = [];

if (!refMatch.test(body)) {
errors.push('[Body] Must reference an issue.');
errors.push(
`[Body] Must reference an issue (ex. 'fixes #1234').\nSee ${helpLink} for more details.`
);
}

return errors;
Expand Down

0 comments on commit 4be03bf

Please sign in to comment.