From e6b58d3cf28355de994aca91fcb90f849945bfc1 Mon Sep 17 00:00:00 2001 From: Franco Meloni Date: Sat, 5 Mar 2022 19:25:35 +0000 Subject: [PATCH] Create a script to change is develop variable on Package.swift --- Scripts/change_is_develop.sh | 6 ++++++ Sources/RunnerLib/Runtime.swift | 4 ++-- Sources/RunnerLib/VersionChecker.swift | 10 +++++----- Tests/RunnerLibTests/VersionCheckerTests.swift | 5 ++--- Tests/RunnerLibTests/XCTestManifests.swift | 11 +++++++++++ 5 files changed, 26 insertions(+), 10 deletions(-) create mode 100755 Scripts/change_is_develop.sh diff --git a/Scripts/change_is_develop.sh b/Scripts/change_is_develop.sh new file mode 100755 index 00000000..bd0ab3e5 --- /dev/null +++ b/Scripts/change_is_develop.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +IS_DEVELOP=$1 + +sed "s/let isDevelop = .*/let isDevelop = $IS_DEVELOP/" Package.swift > tmpPackage.swift +mv -f tmpPackage.swift Package.swift \ No newline at end of file diff --git a/Sources/RunnerLib/Runtime.swift b/Sources/RunnerLib/Runtime.swift index 34b679d4..5840994c 100644 --- a/Sources/RunnerLib/Runtime.swift +++ b/Sources/RunnerLib/Runtime.swift @@ -7,7 +7,7 @@ public enum Runtime { "Dangerfile.swift", "Danger.swift", "danger/Dangerfile.swift", - "Danger/Dangerfile.swift" + "Danger/Dangerfile.swift", ] /// Finds a Dangerfile from the current working directory @@ -21,7 +21,7 @@ public enum Runtime { ".build/x86_64-unknown-linux/debug", // Danger Swift's CI ".build/release", // Testing prod "/usr/local/lib/danger", // Intel Homebrew installs lib stuff to here - "/opt/homebrew/lib/danger" // Apple Silicon Homebrew installs lib stuff to here + "/opt/homebrew/lib/danger", // Apple Silicon Homebrew installs lib stuff to here ] /// Finds a path to add at runtime to the compiler, which links diff --git a/Sources/RunnerLib/VersionChecker.swift b/Sources/RunnerLib/VersionChecker.swift index 4040ffd1..b42ecac0 100644 --- a/Sources/RunnerLib/VersionChecker.swift +++ b/Sources/RunnerLib/VersionChecker.swift @@ -1,7 +1,7 @@ import DangerShellExecutor +import Foundation import Logger import Version -import Foundation public struct VersionChecker { private let shellExecutor: ShellExecuting @@ -40,11 +40,11 @@ private extension VersionChecker { do { let latest = try shellExecutor.execute("curl", arguments: [ - "-s", - "https://api.github.com/repos/danger/swift/releases/latest" + "-s", + "https://api.github.com/repos/danger/swift/releases/latest", ]) - .data(using: .utf8) - .flatMap { try decoder.decode(Release.self, from: $0) } + .data(using: .utf8) + .flatMap { try decoder.decode(Release.self, from: $0) } return latest?.tagName } catch { logger.debug(error) diff --git a/Tests/RunnerLibTests/VersionCheckerTests.swift b/Tests/RunnerLibTests/VersionCheckerTests.swift index da9eb9b3..8a698bcb 100644 --- a/Tests/RunnerLibTests/VersionCheckerTests.swift +++ b/Tests/RunnerLibTests/VersionCheckerTests.swift @@ -1,6 +1,6 @@ // // VersionCheckerTests.swift -// +// // // Created by 417.72KI on 2022/02/20. // @@ -10,7 +10,6 @@ import Logger import XCTest final class VersionCheckerTests: XCTestCase { - private var executor: MockedExecutor! private var spyPrinter: SpyPrinter! @@ -52,6 +51,6 @@ final class VersionCheckerTests: XCTestCase { private extension VersionCheckerTests { func mockResult(tagName: String) -> (String) -> String { - { _ in #"{"tagName": "\#(tagName)"}"# } + { _ in #"{"tagName": "\#(tagName)"}"# } } } diff --git a/Tests/RunnerLibTests/XCTestManifests.swift b/Tests/RunnerLibTests/XCTestManifests.swift index d827f3e6..4cf830a0 100644 --- a/Tests/RunnerLibTests/XCTestManifests.swift +++ b/Tests/RunnerLibTests/XCTestManifests.swift @@ -124,6 +124,16 @@ ] } + extension VersionCheckerTests { + // DO NOT MODIFY: This is autogenerated, use: + // `swift test --generate-linuxmain` + // to regenerate. + static let __allTests__VersionCheckerTests = [ + ("testItNotShowNotificationIfRunningIsLatest", testItNotShowNotificationIfRunningIsLatest), + ("testItShowsNotificationIfNewVersionIsAvailable", testItShowsNotificationIfNewVersionIsAvailable), + ] + } + public func __allTests() -> [XCTestCaseEntry] { [ testCase(CliParserTests.__allTests__CliParserTests), @@ -137,6 +147,7 @@ testCase(ImportsFinderTests.__allTests__ImportsFinderTests), testCase(SPMDangerTests.__allTests__SPMDangerTests), testCase(StringPathExtensionTests.__allTests__StringPathExtensionTests), + testCase(VersionCheckerTests.__allTests__VersionCheckerTests), ] } #endif