mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 13:37:11 +00:00
Various danger swift rule tweaks
* remove the ticket number check, it's noisy * remove signoff now that we have cla checks * fix description image attachments check
This commit is contained in:
parent
56ffe40e97
commit
e5da7ebd2d
1
.github/PULL_REQUEST_TEMPLATE.md
vendored
1
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
- [ ] I read the [contributing guide](https://github.com/element-hq/element-ios/blob/develop/CONTRIBUTING.md).
|
- [ ] I read the [contributing guide](https://github.com/element-hq/element-ios/blob/develop/CONTRIBUTING.md).
|
||||||
- [ ] Pull request contains a [changelog label](https://github.com/element-hq/element-x-ios/blob/develop/CONTRIBUTING.md#changelog).
|
- [ ] Pull request contains a [changelog label](https://github.com/element-hq/element-x-ios/blob/develop/CONTRIBUTING.md#changelog).
|
||||||
- [ ] Pull request includes a [sign off](https://github.com/matrix-org/matrix-ios-sdk/blob/develop/CONTRIBUTING.md#sign-off).
|
|
||||||
|
|
||||||
**UI changes have been tested with:**
|
**UI changes have been tested with:**
|
||||||
- [ ] iPhone and iPad simulators in portrait and landscape orientations.
|
- [ ] iPhone and iPad simulators in portrait and landscape orientations.
|
||||||
|
@ -24,47 +24,10 @@ if danger.github.pullRequest.body?.isEmpty ?? true {
|
|||||||
warn("Please provide a description for this PR.")
|
warn("Please provide a description for this PR.")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for a ticket number
|
|
||||||
if let ticketNumberRegex = try? NSRegularExpression(pattern: "#\\d+") {
|
|
||||||
let missingTicketNumber = !danger.git.commits.filter {
|
|
||||||
!$0.message.contains("element-hq/element-x-ios/issues/") &&
|
|
||||||
ticketNumberRegex.firstMatch(in: $0.message, options: [], range: .init(location: 0, length: $0.message.utf16.count)) == nil
|
|
||||||
}.isEmpty
|
|
||||||
|
|
||||||
if missingTicketNumber {
|
|
||||||
warn("Some of the commits are missing ticket numbers. Please consider squashing all commits that don't have a tracking number.")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for a sign-off
|
|
||||||
let signOff = "Signed-off-by:"
|
|
||||||
|
|
||||||
let allowList = ["stefanceriu",
|
|
||||||
"pixlwave",
|
|
||||||
"langleyd",
|
|
||||||
"manuroe",
|
|
||||||
"Velin92"]
|
|
||||||
|
|
||||||
let requiresSignOff = !allowList.contains(where: {
|
|
||||||
$0.caseInsensitiveCompare(danger.github.pullRequest.user.login) == .orderedSame
|
|
||||||
})
|
|
||||||
|
|
||||||
if requiresSignOff {
|
|
||||||
let hasPRBodySignOff = danger.github.pullRequest.body?.contains(signOff) ?? false
|
|
||||||
|
|
||||||
let isMissingCommitsSignOff = !danger.git.commits.filter {
|
|
||||||
!$0.message.contains(signOff)
|
|
||||||
}.isEmpty
|
|
||||||
|
|
||||||
if !hasPRBodySignOff, isMissingCommitsSignOff {
|
|
||||||
warn("Please add a sign-off to either the PR description or to the commits themselves.")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for screenshots on view changes
|
// Check for screenshots on view changes
|
||||||
let hasChangedViews = !editedFiles.filter { $0.lowercased().contains("/view") }.isEmpty
|
let hasChangedViews = !editedFiles.filter { $0.lowercased().contains("/view") }.isEmpty
|
||||||
if hasChangedViews {
|
if hasChangedViews {
|
||||||
if (danger.github.pullRequest.body?.contains("user-images") ?? false) == false {
|
if (danger.github.pullRequest.body?.contains("user-attachments") ?? false) == false {
|
||||||
warn("You seem to have made changes to views. Please consider adding screenshots.")
|
warn("You seem to have made changes to views. Please consider adding screenshots.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,11 +38,13 @@ if hasPngs {
|
|||||||
warn("You seem to have made changes to some resource images. Please consider using an SVG or PDF.")
|
warn("You seem to have made changes to some resource images. Please consider using an SVG or PDF.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for nice PR titles
|
||||||
let fixesRegex = try! Regex("(Fixes|Fix) #\\d+")
|
let fixesRegex = try! Regex("(Fixes|Fix) #\\d+")
|
||||||
if danger.github.pullRequest.title.hasSuffix("…") || danger.github.pullRequest.title.starts(with: fixesRegex) {
|
if danger.github.pullRequest.title.hasSuffix("…") || danger.github.pullRequest.title.starts(with: fixesRegex) {
|
||||||
fail("Please provide a complete title that can be used as a changelog entry.")
|
fail("Please provide a complete title that can be used as a changelog entry.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for changelog tags
|
||||||
if danger.github.issue.labels.filter({ $0.name.hasPrefix("pr-") }).count != 1 {
|
if danger.github.issue.labels.filter({ $0.name.hasPrefix("pr-") }).count != 1 {
|
||||||
fail("Please add a `pr-` label to categorise the changelog entry.")
|
fail("Please add a `pr-` label to categorise the changelog entry.")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user