Skip to content

Commit

Permalink
ci: edit dangerjs config wd-149
Browse files Browse the repository at this point in the history
  • Loading branch information
what1s1ove committed Nov 19, 2023
1 parent 4771778 commit 02196c0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npx danger ci --dangerfile ./dangerfile --failOnErrors --text-only
npx danger ci --dangerfile dangerfile.cjs --failOnErrors --text-only
60 changes: 31 additions & 29 deletions dangerfile.cjs
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
let { danger, fail } = require(`danger`)
let { danger, warn } = require(`danger`)

let APP_PREFIX = /** @type {const} */ (`wd`)
let ENVIRONMENTS = /** @type {const} */ ([`production`, `development`])
warn(danger.github.pr.title)

let environmentsPattern = ENVIRONMENTS.join(`|`)
// let APP_PREFIX = /** @type {const} */ (`wd`)
// let ENVIRONMENTS = /** @type {const} */ ([`production`, `development`])

let Config = /** @type {const} */ ({
BRANCH_PATTERN: new RegExp(
`^((${APP_PREFIX})-[0-9]{1,6})-[a-zA-Z0-9-]+$|(${environmentsPattern})$`,
),
IS_ASSIGNEE_REQUIRED: true,
TITLE_PATTERN: new RegExp(
`^((${APP_PREFIX})-[0-9]{1,6}): (.*\\S)$|(${environmentsPattern}) to (${environmentsPattern})$`,
),
})
// let environmentsPattern = ENVIRONMENTS.join(`|`)

let isTitleValid = Config.TITLE_PATTERN.test(danger.github.pr.title)
// let Config = /** @type {const} */ ({
// BRANCH_PATTERN: new RegExp(
// `^((${APP_PREFIX})-[0-9]{1,6})-[a-zA-Z0-9-]+$|(${environmentsPattern})$`,
// ),
// IS_ASSIGNEE_REQUIRED: true,
// TITLE_PATTERN: new RegExp(
// `^((${APP_PREFIX})-[0-9]{1,6}): (.*\\S)$|(${environmentsPattern}) to (${environmentsPattern})$`,
// ),
// })

if (!isTitleValid) {
fail(
`Pull Request title should match the following pattern – ${Config.TITLE_PATTERN}.`,
)
}
// let isTitleValid = Config.TITLE_PATTERN.test(danger.github.pr.title)

let isBranchValid = Config.BRANCH_PATTERN.test(danger.github.pr.head.ref)
// if (!isTitleValid) {
// fail(
// `Pull Request title should match the following pattern – ${Config.TITLE_PATTERN}.`,
// )
// }

if (!isBranchValid) {
fail(
`Pull Request branch should match the following pattern – ${Config.BRANCH_PATTERN}.`,
)
}
// let isBranchValid = Config.BRANCH_PATTERN.test(danger.github.pr.head.ref)

let hasAssignee = Boolean(danger.github.pr.assignee)
// if (!isBranchValid) {
// fail(
// `Pull Request branch should match the following pattern – ${Config.BRANCH_PATTERN}.`,
// )
// }

if (Config.IS_ASSIGNEE_REQUIRED && !hasAssignee) {
fail(`Pull Request should have at least one assignee.`)
}
// let hasAssignee = Boolean(danger.github.pr.assignee)

// if (Config.IS_ASSIGNEE_REQUIRED && !hasAssignee) {
// fail(`Pull Request should have at least one assignee.`)
// }

0 comments on commit 02196c0

Please sign in to comment.