-
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.
Merge pull request #52 from clutter/spm
Add SPM Support
- Loading branch information
Showing
62 changed files
with
1,119 additions
and
134 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,66 @@ | ||
version: 2 | ||
jobs: | ||
build-and-test: | ||
build-and-test-pods: | ||
macos: | ||
xcode: 12.5.1 | ||
working_directory: /Users/distiller/project | ||
environment: | ||
FL_OUTPUT_DIR: /Users/distiller/project/Example/fastlane/test_output | ||
FASTLANE_LANE: test | ||
xcode: 13.4.1 | ||
shell: /bin/bash --login -o pipefail | ||
steps: | ||
- checkout | ||
- run: mkdir $FL_OUTPUT_DIR | ||
- run: bundle install | ||
- run: | ||
name: Fastlane | ||
command: cd Example; bundle exec fastlane $FASTLANE_LANE; cd -- | ||
- run: | ||
command: cp $FL_OUTPUT_DIR/report.junit $FL_OUTPUT_DIR/results.xml | ||
when: always | ||
command: bundle exec fastlane ios test_pod | ||
- store_test_results: | ||
path: test_output/report.xml | ||
- store_artifacts: | ||
path: /Users/distiller/project/Example/fastlane | ||
path: /tmp/test-results | ||
destination: scan-test-results | ||
- store_artifacts: | ||
path: ~/Library/Logs/scan | ||
destination: scan-logs | ||
build-and-test-spm: | ||
macos: | ||
xcode: 13.4.1 | ||
shell: /bin/bash --login -o pipefail | ||
steps: | ||
- checkout | ||
- run: bundle install | ||
- run: | ||
name: Fastlane | ||
command: bundle exec fastlane ios test_spm | ||
- store_test_results: | ||
path: /Users/distiller/project/Example/fastlane/test_output | ||
path: test_output/report.xml | ||
- store_artifacts: | ||
path: /tmp/test-results | ||
destination: scan-test-results | ||
- store_artifacts: | ||
path: ~/Library/Logs/scan | ||
destination: scan-logs | ||
danger: | ||
macos: | ||
xcode: 13.4.1 | ||
working_directory: /Users/distiller/project | ||
shell: /bin/bash --login -o pipefail | ||
steps: | ||
- run: | ||
name: Setup Environment Variables | ||
command: | | ||
echo 'export PATH=~/.mint/bin:$PATH' >> $BASH_ENV | ||
- checkout | ||
- run: brew update | ||
- run: brew install mint | ||
- run: mint bootstrap --link --overwrite y | ||
- run: swiftlint version | ||
- run: brew tap danger/tap | ||
- run: brew install danger/tap/danger-swift | ||
- run: | ||
name: Danger | ||
command: danger-swift ci | ||
|
||
workflows: | ||
version: 2 | ||
build-test-adhoc: | ||
jobs: | ||
- build-and-test | ||
- build-and-test-pods | ||
- build-and-test-spm | ||
- danger |
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,40 @@ | ||
disabled_rules: # rule identifiers to exclude from running | ||
- todo | ||
- line_length | ||
- large_tuple | ||
opt_in_rules: | ||
- force_unwrapping | ||
|
||
custom_rules: | ||
weak_root_coordinator: | ||
name: "Weak Root Coordinator" | ||
message: "Root coordinators should be weak to avoid reference cycles." | ||
regex: "(?<!weak )var rootCoordinator: RootCoordinator\\?(?! \\{ get (set )?\\})" | ||
file_length: | ||
warning: 600 | ||
identifier_name: | ||
min_length: # only min_length | ||
error: 2 # only error | ||
excluded: # excluded via string array | ||
- id | ||
- f | ||
- s | ||
- i | ||
- j | ||
- x | ||
- y | ||
- vc | ||
- to | ||
function_body_length: | ||
- 60 | ||
- 60 | ||
nesting: | ||
type_level: | ||
warning: 2 | ||
private_over_fileprivate: | ||
validate_extensions: true | ||
|
||
excluded: | ||
- Pods/** | ||
- Example/PodApp/Pods/** | ||
- Sources/SplitScreenScanner/Classes/ScannerStyleKit.swift |
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,98 @@ | ||
import Foundation | ||
import Danger | ||
|
||
// MARK: Helper methods | ||
|
||
func validateTitleAllowsMerging(for pullRequest: GitHub.PullRequest) throws { | ||
let range = NSRange(pullRequest.title.startIndex..., in: pullRequest.title) | ||
|
||
let wipRegex = try NSRegularExpression(pattern: "\\bWIP\\b", options: .caseInsensitive) | ||
if wipRegex.firstMatch(in: pullRequest.title, range: range) != nil { | ||
print("Pull request title contains “WIP”.") | ||
} | ||
|
||
let doNotMergeRegex = try NSRegularExpression(pattern: "\\bdo not merge\\b", options: .caseInsensitive) | ||
if doNotMergeRegex.firstMatch(in: pullRequest.title, range: range) != nil { | ||
print("Pull request title contains “do not merge”.") | ||
} | ||
} | ||
|
||
func validateMessage(for ghCommit: GitHub.Commit, doesNotHavePrefixes prefixes: [String]) { | ||
let commitMessage = ghCommit.commit.message.lowercased() | ||
for prefix in prefixes where commitMessage.hasPrefix(prefix.lowercased()) { | ||
fail("Commit message \(ghCommit.sha) begins with `\(prefix)`. Squash before merging.") | ||
} | ||
} | ||
|
||
func messageIsGenerated(for ghCommit: GitHub.Commit) -> Bool { | ||
guard let firstWord = ghCommit.commit.message.components(separatedBy: " ").first else { | ||
return false | ||
} | ||
return firstWord == "Merge" || firstWord == "Revert" || firstWord == "fixup!" || firstWord == "squash!" | ||
} | ||
|
||
/// Fails if the commit’s message does not satisfy Chris Beams’s | ||
/// [“The seven rules of a great Git commit message”](https://chris.beams.io/posts/git-commit/). | ||
func validateMessageIsGreat(for ghCommit: GitHub.Commit) { | ||
guard !messageIsGenerated(for: ghCommit) else { return } | ||
|
||
let messageComponents = ghCommit.commit.message.components(separatedBy: "\n") | ||
let title = messageComponents[0] | ||
|
||
// Rule 1 | ||
if messageComponents.count > 1 { | ||
let separator = messageComponents[1] | ||
if !separator.isEmpty { | ||
fail("Commit message \(ghCommit.sha) is missing a blank line between title and body.") | ||
} | ||
} | ||
|
||
// Rule 2 | ||
if title.count > 50 { | ||
fail("Commit title \(ghCommit.sha) is \(title.count) characters long (title should be limited to 50 characters).") | ||
} | ||
|
||
// Rule 3 | ||
if title.first != title.capitalized.first { | ||
fail("Commit title \(ghCommit.sha) is not capitalized.") | ||
} | ||
|
||
// Rule 4 | ||
if title.hasSuffix(".") { | ||
fail("Commit title \(ghCommit.sha) ends with a period.") | ||
} | ||
|
||
// Rule 5 | ||
// Use the imperative mood in the subject line | ||
// Not validated here | ||
|
||
// Rule 6 | ||
let body = messageComponents.dropFirst() | ||
let lineNumbers = body.indices.map({ $0 + 1 }) | ||
for (lineNumber, line) in zip(lineNumbers, body) where line.count > 72 { | ||
fail("Commit message \(ghCommit.sha) line \(lineNumber) is \(line.count) characters long (body should be wrapped at 72 characters).") | ||
} | ||
|
||
// Rule 7 | ||
// Use the body to explain what and why vs. how | ||
// Not validated here | ||
} | ||
|
||
// MARK: - Validations | ||
|
||
let danger = Danger() | ||
let pullRequest = danger.github.pullRequest | ||
|
||
try validateTitleAllowsMerging(for: pullRequest) | ||
|
||
let unmergeablePrefixes = ["fixup!", "squash!", "WIP"] | ||
danger.github.commits.forEach { | ||
validateMessage(for: $0, doesNotHavePrefixes: unmergeablePrefixes) | ||
validateMessageIsGreat(for: $0) | ||
} | ||
|
||
if let additions = pullRequest.additions, let deletions = pullRequest.deletions, additions < deletions { | ||
message("🎉 This PR removes more code than it adds! (\(additions - deletions) net lines)") | ||
} | ||
|
||
SwiftLint.lint(inline: true, directory: "Session") |
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,7 @@ | ||
platform :ios, '14.0' | ||
use_frameworks! | ||
|
||
pod 'SplitScreenScanner', :path => '../..' | ||
|
||
target 'SplitScreenScanner_Example' | ||
target 'SplitScreenScanner_Tests' |
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,23 @@ | ||
PODS: | ||
- Sections (0.8.0) | ||
- SplitScreenScanner (10.0.0): | ||
- Sections | ||
|
||
DEPENDENCIES: | ||
- SplitScreenScanner (from `../..`) | ||
|
||
SPEC REPOS: | ||
trunk: | ||
- Sections | ||
|
||
EXTERNAL SOURCES: | ||
SplitScreenScanner: | ||
:path: "../.." | ||
|
||
SPEC CHECKSUMS: | ||
Sections: efc268a207d0e7afba82d2a0efd6cdf61872b5d4 | ||
SplitScreenScanner: 14f7388b33bb57afc2dfd1eab6af0bd18a45b9a2 | ||
|
||
PODFILE CHECKSUM: a50e47e37e36a517f8de6ae75d836fb0fdfdecfd | ||
|
||
COCOAPODS: 1.8.4 |
Oops, something went wrong.