beam-chat/Dangerfile.swift

53 lines
1.9 KiB
Swift
Raw Normal View History

import Danger
import Foundation
SwiftLint.lint(.modifiedAndCreatedFiles(directory: nil),
inline: true,
configFile: nil,
strict: false,
quiet: true,
swiftlintPath: nil,
markdownAction: { _ in })
let danger = Danger()
// All of the new and modified files together.
let editedFiles = danger.git.modifiedFiles + danger.git.createdFiles
// Warn when there is a big PR
if (danger.github.pullRequest.additions ?? 0) > 1000 {
warn("This pull request seems relatively large. Please consider splitting it into multiple smaller ones.")
}
// Check that the PR has a description
if danger.github.pullRequest.body?.isEmpty ?? true {
warn("Please provide a description for this PR.")
}
// Check for screenshots on view changes
let hasChangedViews = !editedFiles.filter { $0.lowercased().contains("/view") }.isEmpty
if hasChangedViews {
if (danger.github.pullRequest.body?.contains("user-attachments") ?? false) == false {
warn("You seem to have made changes to views. Please consider adding screenshots.")
}
}
2022-06-21 18:49:02 +03:00
// Check for pngs on resources
Screenshot tests (#130) * #9 Add snapshot testing library * #9 Create script to boot test simulators * #9 Create the UI test plan * #9 Create shared schemes for test targets * #9 Disable split view for UI tests * #9 Fix fastlane dependencies * #9 Add snapshot testing to the application * #9 assert screenshots * #9 fix swipe gestures on iPad * #9 Fix accessing items in session verification screen * #9 Workaround for flaky unit test * #9 Specify scheme for alpha build * #9 Add reference screenshots * Update python script path and check assets for png check * Update script path * Use static timezone for simulator time * Fix build after SwiftFormat * Add changelog * Upload failed screenshots artifact * Always upload artifacts * Update boot simulator script * Update simulator overridden time * Install pytz before tests * Get time from Ruby script * Disable SwiftUI animation when running UI tests * Update screenshots after animation setting * Include reference images in the artifact * Update matching precision * Update image matching precision & revert artifact content * Include Xcode result in the artifact * Update test output directory * Disable gradient on splash screen for tests * Tap next button explicitly * Wait a bit before checking alert * Wait 1 second * Run SwiftFormat on project * Ignore temporary screenshots * Fix most of the PR remarks * Fix conflicts * Bump Python version to 3 * Update reference screenshots for authentication screens * Update SwiftFormat * Fix flakey session verification test. * Update scheme. Co-authored-by: Doug <douglase@element.io>
2022-08-11 15:02:47 +03:00
let hasPngs = !editedFiles.filter { $0.lowercased().contains(".xcassets") && $0.lowercased().hasSuffix(".png") }.isEmpty
2022-06-21 18:49:02 +03:00
if hasPngs {
Screenshot tests (#130) * #9 Add snapshot testing library * #9 Create script to boot test simulators * #9 Create the UI test plan * #9 Create shared schemes for test targets * #9 Disable split view for UI tests * #9 Fix fastlane dependencies * #9 Add snapshot testing to the application * #9 assert screenshots * #9 fix swipe gestures on iPad * #9 Fix accessing items in session verification screen * #9 Workaround for flaky unit test * #9 Specify scheme for alpha build * #9 Add reference screenshots * Update python script path and check assets for png check * Update script path * Use static timezone for simulator time * Fix build after SwiftFormat * Add changelog * Upload failed screenshots artifact * Always upload artifacts * Update boot simulator script * Update simulator overridden time * Install pytz before tests * Get time from Ruby script * Disable SwiftUI animation when running UI tests * Update screenshots after animation setting * Include reference images in the artifact * Update matching precision * Update image matching precision & revert artifact content * Include Xcode result in the artifact * Update test output directory * Disable gradient on splash screen for tests * Tap next button explicitly * Wait a bit before checking alert * Wait 1 second * Run SwiftFormat on project * Ignore temporary screenshots * Fix most of the PR remarks * Fix conflicts * Bump Python version to 3 * Update reference screenshots for authentication screens * Update SwiftFormat * Fix flakey session verification test. * Update scheme. Co-authored-by: Doug <douglase@element.io>
2022-08-11 15:02:47 +03:00
warn("You seem to have made changes to some resource images. Please consider using an SVG or PDF.")
2022-06-21 18:49:02 +03:00
}
// Check for nice PR titles
let prTitle = danger.github.pullRequest.title
let fixesRegex = try! Regex("(Fixes|Fix) #\\d+")
let semanticRegex = try! Regex("\\w+\\(\\w+\\):")
if prTitle.hasSuffix("") || prTitle.starts(with: fixesRegex) || prTitle.starts(with: semanticRegex) {
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 {
fail("Please add a `pr-` label to categorise the changelog entry.")
}