Dangerfile 2.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. # send a welcome message for the user
  2. message "Hey, @#{github.pr_author} 👋."
  3. # Just to let people know
  4. warn("PR is classed as Work in Progress.") if github.pr_title.include? "[WIP]"
  5. # Warn when there is a big PR
  6. warn("Big PR") if git.lines_of_code > 500
  7. # ensure there is a summary for a PR
  8. fail "Please provide a summary in the Pull Request description." if github.pr_body.length < 5
  9. # Changelog entries are required for changes to library files.
  10. fail("Please include a CHANGELOG entry. You can find it at [CHANGELOG.md](https://github.com/httpswift/swifter/blob/stable/CHANGELOG.md).") unless git.modified_files.include?("CHANGELOG.md") || git.added_files.include?("CHANGELOG.md")
  11. # Don't accept PR on master for now
  12. fail "Please re-submit this PR to stable, you're trying to merge the PR on master." if github.branch_for_base == "master"
  13. # If these are all empty something has gone wrong, better to raise it in a comment
  14. if git.modified_files.empty? && git.added_files.empty? && git.deleted_files.empty?
  15. fail "This PR has no changes at all, this is likely a developer issue."
  16. end
  17. # Run SwiftLint
  18. swiftlint.config_file = '.swiftlint.yml'
  19. swiftlint.lint_files
  20. # Warn when new tests are added but the XCTestManifests wasn't updated to run on Linux
  21. tests_added_or_modified = git.modified_files.grep(/XCode\/Tests/).empty? || git.added_files.grep(/XCode\/Tests/).empty?
  22. xc_manifest_updated = !git.modified_files.grep(/XCode\/Tests\/XCTestManifests.swift/).empty?
  23. if tests_added_or_modified && !xc_manifest_updated
  24. warn("It seems like you've added new tests to the library. If that's the case, please update the [XCTestManifests.swift](https://github.com/httpswift/swifter/blob/stable/XCode/Tests/XCTestManifests.swift) file running in your terminal the command `swift test --generate-linuxmain`.")
  25. # This is a temporary warning to remove the entry for the failed test until we solve the issue in Linux
  26. warn("If you ran the command `swift test --generate-linuxmain` in your terminal, please remove the line `testCase(IOSafetyTests.__allTests__IOSafetyTests),` from `public func __allTests() -> [XCTestCaseEntry]` in the bottom of the file. For more reference see [#366](https://github.com/httpswift/swifter/issues/366).")
  27. end