Skip to content

Commit 66dba2f

Browse files
authored
FDN-4209 Update pr-validator workflow (#856)
Resolves [FDN-4209] This PR adds the pr-validator workflow to ensure PRs have associated JIRA tickets. [FDN-4209]: https://flowio.atlassian.net/browse/FDN-4209?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Updated PR validation workflow with refined title format requirements and simplified validation logic. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 01a2f2e commit 66dba2f

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

.github/workflows/pr-validator.yml

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ on:
66
jobs:
77
check-title-and-description:
88
runs-on: ubuntu-latest
9-
if: ${{ !contains(github.event.pull_request.labels.*.name, 'scala-steward') }}
109
steps:
1110
- name: Check PR title and description
1211
uses: actions/github-script@v4
@@ -15,25 +14,23 @@ jobs:
1514
script: |
1615
const payload = context.payload;
1716
const prTitle = payload.pull_request.title;
18-
const prDescription = payload.pull_request.body;
1917
2018
// The pattern for JIRA ticket format
21-
const jiraPattern = /\b[A-Z]+-\d+\b|breakglass/gi;
19+
// Must be at the beginning of the PR title
20+
// Prefix must be at least 3 uppercase letters
21+
// Excludes tickets with only zeros after the prefix (e.g., XXX-000, XXX-0000)
22+
// Number must be 3 to 6 digits
23+
const jiraPattern = /^[A-Z]{3,}-(?!0+\b)\d{3,6}\b/;
2224
2325
// Check PR title
2426
const hasJiraTitle = jiraPattern.test(prTitle);
2527
console.log(`PR title: ${hasJiraTitle ? 'Valid' : 'Invalid'}`);
2628
27-
// Check PR description
28-
const hasJiraDescription = prDescription ? prDescription.match(jiraPattern) : false;
29-
console.log(`PR description: ${hasJiraDescription ? 'Valid' : 'Invalid'}`);
30-
31-
if (hasJiraTitle || hasJiraDescription) {
32-
console.log('PR title or description format is correct.');
29+
if (hasJiraTitle) {
30+
console.log('PR title format is correct.');
3331
} else {
34-
const errorMessage = [];
35-
errorMessage.push('The PR title and description do not include a valid JIRA ticket!');
36-
console.log(errorMessage.join('\n'));
32+
const errorMessage = 'The PR title must start with a valid JIRA ticket with 3-6 digits (e.g., ABC-123, DATAPLATFORM-12345). The ticket must be at the start, use at least 3 uppercase letters, and the number must not be all zeros.';
33+
console.log(errorMessage);
3734
38-
core.setFailed(errorMessage.join('\n'));
35+
core.setFailed(errorMessage);
3936
}

0 commit comments

Comments
 (0)