Merge pull request #21 from xcbuddy/danger

Add Danger
This commit is contained in:
Pedro Piñera Buendía 2018-04-27 17:32:19 +02:00 committed by GitHub
commit 7af367275b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 90 additions and 10 deletions

View File

@ -22,10 +22,14 @@ jobs:
name: Install Dependencies
command: |
bundle config build.sqlite3 --with-sqlite3-dir=/opt/local
brew install swiftlint
bundle install --path vendor/bundle
- run:
name: Run tests
command: bundle exec rake test
- run:
name: Danger
command: bundle exec danger
- run:
name: Send test coverage report
command: bash <(curl -s https://codecov.io/bash)

16
.swiftlint.yml Normal file
View File

@ -0,0 +1,16 @@
included:
- App/xcbuddykit/Sources
- App/Sources
excluded:
- Sources
- Tests
- .build
disabled_rules:
- trailing_whitespace
- nesting
- cyclomatic_complexity
- file_length
- todo
line_length:
warning: 150
error: 170

View File

@ -745,6 +745,7 @@
buildPhases = (
B915ED152063AFBC004B6630 /* Sources */,
B915ED162063AFBC004B6630 /* Frameworks */,
B918A2322093756700E64FBE /* Swift lint */,
);
buildRules = (
);
@ -904,6 +905,20 @@
shellPath = /bin/sh;
shellScript = "if which sentry-cli >/dev/null; then\nexport SENTRY_ORG=xcbuddy\nexport SENTRY_PROJECT=app\nERROR=$(bin/sentry-cli upload-dsym 2>&1 >/dev/null)\nif [ ! $? -eq 0 ]; then\necho \"warning: sentry-cli - $ERROR\"\nfi\nelse\necho \"warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases\"\nfi";
};
B918A2322093756700E64FBE /* Swift lint */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Swift lint";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\nswiftlint\nelse\necho \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi";
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */

View File

@ -2,7 +2,7 @@ import Basic
import Darwin
import Foundation
let system_glob = Darwin.glob
let systemGlob = Darwin.glob
extension AbsolutePath {
static var current: AbsolutePath {
@ -18,7 +18,7 @@ extension AbsolutePath {
}
let flags = GLOB_TILDE | GLOB_BRACE | GLOB_MARK
if system_glob(cPattern, flags, nil, &gt) == 0 {
if systemGlob(cPattern, flags, nil, &gt) == 0 {
let matchc = gt.gl_matchc
return (0 ..< Int(matchc)).compactMap { index in
if let path = String(validatingUTF8: gt.gl_pathv[index]!) {

View File

@ -62,7 +62,10 @@ class GraphManifestLoader: GraphManifestLoading {
}
let swiftPath = AbsolutePath(swiftOutput)
let manifestFrameworkPath = try context.resourceLocator.projectDescription()
let jsonString: String! = try context.shell.run(swiftPath.asString, "-F", manifestFrameworkPath.parentDirectory.asString, "-framework", "ProjectDescription", path.asString, "--dump").chuzzle()
let jsonString: String! = try context.shell.run(swiftPath.asString, "-F",
manifestFrameworkPath.parentDirectory.asString,
"-framework", "ProjectDescription",
path.asString, "--dump").chuzzle()
if jsonString == nil {
throw GraphManifestLoaderError.unexpectedOutput(path)
}

View File

@ -138,7 +138,7 @@ class PrecompiledNode: GraphNode {
/// - armv7: armv7 (OS device)
/// - armv7s: armv7s (OS device)
enum Architecture: String {
case x86_64
case x8664 = "x86_64"
case i386
case armv7
case armv7s

View File

@ -1,7 +1,7 @@
import Foundation
import Sparkle
fileprivate var _app: SPUStandardUpdaterController!
private var _app: SPUStandardUpdaterController!
// MARK: - SPUStandardUpdaterController (App)

View File

@ -54,7 +54,9 @@ class SPUCommandLineUserDriver: NSObject, SPUUserDriver {
}
}
func showInformationalUpdateFound(with appcastItem: SUAppcastItem, userInitiated _: Bool, reply: @escaping (SPUInformationalUpdateAlertChoice) -> Void) {
func showInformationalUpdateFound(with appcastItem: SUAppcastItem,
userInitiated _: Bool,
reply: @escaping (SPUInformationalUpdateAlertChoice) -> Void) {
DispatchQueue.main.async {
print("Found information for new update: %s", appcastItem.infoURL.absoluteString.utf8)
reply(.dismissInformationalNoticeChoice)

View File

@ -1,7 +1,7 @@
import Basic
import Foundation
fileprivate class Dummy {}
private class Dummy {}
enum BundleError: Error {
case frameworkNotEmbedded(AbsolutePath)

View File

@ -57,8 +57,10 @@ final class ErrorHandler: ErrorHandling {
/// - Parameter printer: printer.
init(printer: Printing = Printer()) {
if let sentryDsn = Bundle(for: ErrorHandler.self).infoDictionary?["SENTRY_DSN"] as? String, !sentryDsn.isEmpty {
// swiftlint:disable force_try
client = try! Client(dsn: sentryDsn)
try! client?.startCrashHandler()
// swiftlint:enable force_try
} else {
client = nil
}

View File

@ -26,7 +26,9 @@ protocol Printing: AnyObject {
/// Default printer that conforms the printing protocol.
class Printer: Printing {
// swiftlint:disable force_cast
let terminalController: TerminalController = TerminalController(stream: stdoutStream as! LocalFileOutputByteStream)!
// swiftlint:enable force_cast
/// Prints a message on the console.
///

View File

@ -12,7 +12,7 @@ final class PrecompiledNodeTests: XCTestCase {
}
func test_architecture_rawValues() {
XCTAssertEqual(PrecompiledNode.Architecture.x86_64.rawValue, "x86_64")
XCTAssertEqual(PrecompiledNode.Architecture.x8664.rawValue, "x86_64")
XCTAssertEqual(PrecompiledNode.Architecture.i386.rawValue, "i386")
XCTAssertEqual(PrecompiledNode.Architecture.armv7.rawValue, "armv7")
XCTAssertEqual(PrecompiledNode.Architecture.armv7s.rawValue, "armv7s")
@ -42,7 +42,7 @@ final class FrameworkNodeTests: XCTestCase {
}
return ""
}
try XCTAssertEqual(subject.architectures(shell: shell).first, .x86_64)
try XCTAssertEqual(subject.architectures(shell: shell).first, .x8664)
}
func test_linking() {
@ -79,7 +79,7 @@ final class LibraryNodeTests: XCTestCase {
}
return ""
}
try XCTAssertEqual(subject.architectures(shell: shell).first, .x86_64)
try XCTAssertEqual(subject.architectures(shell: shell).first, .x8664)
}
func test_linking() {

View File

@ -15,6 +15,7 @@ Please, check out guidelines: https://keepachangelog.com/en/1.0.0/
* Base context https://github.com/xcbuddy/xcbuddy/pull/17/files by @pepibumur.
* Add `ResourceLocator` https://github.com/xcbuddy/xcbuddy/pull/18 by @pepibumur.
* Add `ErrorHandler` https://github.com/xcbuddy/xcbuddy/pull/20 by @pepibumur.
* Add Danger https://github.com/xcbuddy/xcbuddy/pull/21 by @pepibumur.
### Changed

2
Dangerfile Normal file
View File

@ -0,0 +1,2 @@
# Swift lint
swiftlint.lint_files

View File

@ -13,3 +13,5 @@ gem 'rake'
gem 'rubocop'
gem 'semantic'
gem 'sparklecast'
gem 'danger'
gem 'danger-swiftlint'

View File

@ -13,6 +13,10 @@ GEM
atomos (0.1.2)
byebug (10.0.1)
claide (1.0.2)
claide-plugins (0.9.2)
cork
nap
open4 (~> 1.3)
cocoapods (1.4.0)
activesupport (>= 4.0.2, < 5)
claide (>= 1.0.2, < 2.0)
@ -48,10 +52,30 @@ GEM
cocoapods-try (1.1.0)
colored2 (3.1.2)
concurrent-ruby (1.0.5)
cork (0.3.0)
colored2 (~> 3.1)
danger (5.5.12)
claide (~> 1.0)
claide-plugins (>= 0.9.2)
colored2 (~> 3.1)
cork (~> 0.1)
faraday (~> 0.9)
faraday-http-cache (~> 1.0)
git (~> 1)
kramdown (~> 1.5)
no_proxy_fix
octokit (~> 4.7)
terminal-table (~> 1)
danger-swiftlint (0.16.0)
danger
rake (> 10)
thor (~> 0.19)
dotenv (2.2.1)
escape (0.0.4)
faraday (0.14.0)
multipart-post (>= 1.2, < 3)
faraday-http-cache (1.3.1)
faraday (~> 0.8)
ffi (1.9.23)
fourflusher (2.0.1)
fuzzy_match (2.0.4)
@ -68,6 +92,7 @@ GEM
sass (~> 3.4)
sqlite3 (~> 1.3)
xcinvoke (~> 0.3.0)
kramdown (1.16.2)
liferaft (0.0.6)
mini_portile2 (2.3.0)
minitest (5.11.3)
@ -77,6 +102,7 @@ GEM
nanaimo (0.2.3)
nap (1.1.0)
netrc (0.11.0)
no_proxy_fix (0.1.2)
nokogiri (1.8.2)
mini_portile2 (~> 2.3.0)
octokit (4.8.0)
@ -115,6 +141,9 @@ GEM
sparklecast (0.0.1)
nokogiri
sqlite3 (1.3.13)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
thor (0.20.0)
thread_safe (0.3.6)
tzinfo (1.2.5)
thread_safe (~> 0.1)
@ -133,6 +162,8 @@ PLATFORMS
DEPENDENCIES
byebug
danger
danger-swiftlint
dotenv
git
jazzy