-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
20b7a9a
commit 6896d7a
Showing
4 changed files
with
1,183 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { danger, fail } from 'danger' | ||
|
||
import { ProjectPrefix } from './project.config.js' | ||
|
||
let appsPattern = ProjectPrefix.APPS.join(`|`) | ||
let environmentsPattern = ProjectPrefix.ENVIRONMENTS.join(`|`) | ||
|
||
let Config = /** @type {const} */ ({ | ||
BRANCH_PATTERN: new RegExp( | ||
`^((${appsPattern})-[0-9]{1,6})-[a-zA-Z0-9-]+$|(${environmentsPattern})$`, | ||
), | ||
IS_ASSIGNEE_REQUIRED: true, | ||
TITLE_PATTERN: new RegExp( | ||
`^((${appsPattern})-[0-9]{1,6}): (.*\\S)$|(${environmentsPattern}) to (${environmentsPattern})$`, | ||
), | ||
}) | ||
|
||
let isTitleValid = Config.TITLE_PATTERN.test(danger.github.pr.title) | ||
|
||
if (!isTitleValid) { | ||
fail( | ||
`Pull Request title should match the following pattern – ${Config.TITLE_PATTERN}.`, | ||
) | ||
} | ||
|
||
let isBranchValid = Config.BRANCH_PATTERN.test(danger.github.pr.head.ref) | ||
|
||
if (!isBranchValid) { | ||
fail( | ||
`Pull Request branch should match the following pattern – ${Config.BRANCH_PATTERN}.`, | ||
) | ||
} | ||
|
||
let hasAssignee = Boolean(danger.github.pr.assignee) | ||
|
||
if (Config.IS_ASSIGNEE_REQUIRED && !hasAssignee) { | ||
fail(`Pull Request should have at least one assignee.`) | ||
} |
Oops, something went wrong.