Skip to content

Commit

Permalink
Adopted latest Runner API
Browse files Browse the repository at this point in the history
  • Loading branch information
samdeane committed Sep 10, 2024
1 parent 0bed1ec commit 8fd3b54
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 37 deletions.
12 changes: 6 additions & 6 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/elegantchaos/ChaosByteStreams",
"state" : {
"revision" : "f8e1ae4bd95760dd96e0b877d1672c98e9eb1486",
"version" : "1.0.2"
"revision" : "dc5fc08a831e8e2878197418e3ed35f234bcfe07",
"version" : "1.0.6"
}
},
{
Expand Down Expand Up @@ -51,8 +51,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/elegantchaos/Runner.git",
"state" : {
"revision" : "c192968875db172d1560e53a3084dc8b04ef5f1c",
"version" : "2.1.0"
"revision" : "e5b8e0fc4b5119b238935343dc60171c0140ee1f",
"version" : "2.1.3"
}
},
{
Expand All @@ -69,8 +69,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/elegantchaos/Versionator.git",
"state" : {
"revision" : "00c24b0749348dc0692fab66eac9be5f55dbee3e",
"version" : "2.0.3"
"revision" : "4ca5288583f9cf0e7fa3b22ed933f2c340787f00",
"version" : "2.0.4"
}
},
{
Expand Down
8 changes: 4 additions & 4 deletions Sources/ReleaseTools/Commands/AppcastCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ enum GenerationError: Error, CustomStringConvertible {
}
}
}
enum AppcastError: RunnerError {
enum AppcastError: Runner.Error {
case buildAppcastGeneratorFailed
case appcastGeneratorFailed
case keyGenerationFailed
case keyImportFailed

func description(for session: Runner.Session) async -> String {
async let stderr = String(session.stderr)
async let stderr = session.stderr.string
switch self {
case .buildAppcastGeneratorFailed: return "Failed to build the generate_appcast tool.\n\n\(await stderr)"
case .appcastGeneratorFailed: return "Failed to generate the appcast.\n\n\(await stderr)"
Expand Down Expand Up @@ -84,11 +84,11 @@ struct AppcastCommand: AsyncParsableCommand {
let generator = Runner(for: URL(fileURLWithPath: ".build/Release/generate_appcast"))
let genResult = generator.run(["-n", keyName, "-k", keyChainPath, updates.path])

try await genResult.throwIfFailed(!(await String(genResult.stdout)).contains("Unable to load DSA private key") ? AppcastError.appcastGeneratorFailed : nil)
try await genResult.throwIfFailed(!(await genResult.stdout.string).contains("Unable to load DSA private key") ? AppcastError.appcastGeneratorFailed : nil)

for await state in genResult.state {
if state != .succeeded {
let output = await String(genResult.stdout)
let output = await genResult.stdout.string
if !output.contains("Unable to load DSA private key") {
throw AppcastError.appcastGeneratorFailed
}
Expand Down
5 changes: 2 additions & 3 deletions Sources/ReleaseTools/Commands/ArchiveCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ struct SchemesSpec: Decodable {
let workspace: WorkspaceSpec
}

enum ArchiveError: RunnerError {
enum ArchiveError: Runner.Error {
case archiveFailed

func description(for session: Runner.Session) async -> String {
async let stderr = String(session.stderr)
switch self {
case .archiveFailed: return "Archiving failed.\n\n\(await stderr)"
case .archiveFailed: return "Archiving failed.\n\n\(await session.stderr.string)"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/ReleaseTools/Commands/ChangesCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct ChangesCommand: AsyncParsableCommand {

do {
let result = git.run(arguments)
let output = await String(result.stdout)
let output = await result.stdout.string
try output.write(to: parsed.changesURL, atomically: true, encoding: .utf8)
NSWorkspace.shared.open(parsed.changesURL)
} catch {
Expand Down
4 changes: 2 additions & 2 deletions Sources/ReleaseTools/Commands/CompressCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import ArgumentParser
import Foundation
import Runner

enum CompressError: RunnerError {
enum CompressError: Runner.Error {
case compressFailed

func description(for session: Runner.Session) async -> String {
async let stderr = String(session.stderr)
async let stderr = session.stderr.string
switch self {
case .compressFailed: return "Compressing failed.\n\(await stderr)"
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/ReleaseTools/Commands/ExportCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ enum ExportError: Error {
}
}

enum ExportRunnerError: RunnerError {
enum ExportRunnerError: Runner.Error {
case exportFailed

func description(for session: Runner.Session) async -> String {
async let stderr = String(session.stderr)
async let stderr = session.stderr.string
switch self {
case .exportFailed: return "Exporting failed.\n\(await stderr)"
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/ReleaseTools/Commands/NotarizeCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ enum NotarizeError: Error {
}
}

enum NotarizeRunnerError: RunnerError {
enum NotarizeRunnerError: Runner.Error {
case compressingFailed
case notarizingFailed

func description(for session: Runner.Session) async -> String {
async let stderr = String(session.stderr)
async let stderr = session.stderr.string
switch self {
case .compressingFailed: return "Compressing failed.\n\(await stderr)"
case .notarizingFailed: return "Notarizing failed.\n\(await stderr)"
Expand Down Expand Up @@ -72,7 +72,7 @@ struct NotarizeCommand: AsyncParsableCommand {

parsed.log("Requested notarization.")
do {
let output = await String(result.stdout)
let output = await result.stdout.string
try output.write(to: parsed.notarizingReceiptURL, atomically: true, encoding: .utf8)
} catch {
throw NotarizeError.savingNotarizationReceiptFailed(error)
Expand Down
4 changes: 2 additions & 2 deletions Sources/ReleaseTools/Commands/PublishCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import ArgumentParser
import Foundation
import Runner

enum PublishError: RunnerError {
enum PublishError: Runner.Error {
case commitFailed
case pushFailed

func description(for session: Runner.Session) async -> String {
async let stderr = String(session.stderr)
async let stderr = session.stderr.string
switch self {
case .commitFailed: return "Failed to commit the appcast feed and updates.\n\n\(await stderr)"
case .pushFailed: return "Failed to push the appcast feed and updates.\n\n\(await stderr)"
Expand Down
8 changes: 4 additions & 4 deletions Sources/ReleaseTools/Commands/UpdateBuildCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import Foundation
import Resources
import Runner

enum UpdateBuildError: RunnerError {
enum UpdateBuildError: Runner.Error {
case gettingBuildFailed
case gettingCommitFailed
case writingConfigFailed
case updatingIndexFailed

func description(for session: Runner.Session) async -> String {
async let stderr = String(session.stderr)
async let stderr = session.stderr.string
switch self {
case .gettingBuildFailed: return "Failed to get the build number from git.\n\n\(await stderr)"
case .gettingCommitFailed: return "Failed to get the commit from git.\n\n\(await stderr)"
Expand Down Expand Up @@ -65,11 +65,11 @@ struct UpdateBuildCommand: AsyncParsableCommand {
var result = git.run(["rev-list", "--count", "HEAD"])
try await result.throwIfFailed(UpdateBuildError.gettingBuildFailed)

let build = await String(result.stdout).trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
let build = await result.stdout.string.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)

result = git.run(["rev-list", "--max-count", "1", "HEAD"])
try await result.throwIfFailed(UpdateBuildError.gettingCommitFailed)
let commit = await String(result.stdout).trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
let commit = await result.stdout.string.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)

return (build, commit)
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/ReleaseTools/Commands/UploadCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ enum UploadError: Error {
}
}

enum UploadRunnerError: RunnerError {
enum UploadRunnerError: Runner.Error {
case uploadingFailed

func description(for session: Runner.Session) async -> String {
async let stderr = String(session.stderr)
async let stderr = session.stderr.string
switch self {
case .uploadingFailed: return "Uploading failed.\n\(await stderr)"
}
Expand Down Expand Up @@ -80,7 +80,7 @@ struct UploadCommand: AsyncParsableCommand {

parsed.log("Finished uploading.")
do {
let output = await String(uploadResult.stdout)
let output = await uploadResult.stdout.string
try output.write(
to: parsed.uploadingReceiptURL, atomically: true, encoding: .utf8)
} catch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ enum WaitForNotarizationError: Error {
}
}

enum WaitForNotarizationRunnerError: RunnerError {
enum WaitForNotarizationRunnerError: Runner.Error {
case fetchingNotarizationStatusFailed
case exportingNotarizedAppFailed

func description(for session: Runner.Session) async -> String {
async let stderr = String(session.stderr)
async let stderr = session.stderr.string
switch self {
case .fetchingNotarizationStatusFailed:
return "Fetching notarization status failed.\n\(await stderr)"
Expand Down Expand Up @@ -89,6 +89,7 @@ struct WaitForNotarizationCommand: AsyncParsableCommand {

parsed.log("Tagging.")
let git = GitRunner()
let tagResult = git.run([
let tagResult = git.run([
"tag", parsed.versionTag, "-f", "-m", "Uploaded with \(CommandLine.name)",
])
Expand Down Expand Up @@ -138,7 +139,7 @@ struct WaitForNotarizationCommand: AsyncParsableCommand {
try await result.throwIfFailed(WaitForNotarizationRunnerError.fetchingNotarizationStatusFailed)

parsed.log("Received response.")
let data = await Data(await result.stdout)
let data = await result.stdout.data
if let receipt = try? PropertyListSerialization.propertyList(
from: data, options: [], format: nil) as? [String: Any],
let info = receipt["notarization-info"] as? [String: Any],
Expand Down
2 changes: 1 addition & 1 deletion Sources/ReleaseTools/Runners/DittoRunner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DittoRunner: Runner {
parsed.log("ditto " + arguments.joined(separator: " "))
}

let mode: ProcessStream.Mode = parsed.showOutput ? .both : .capture
let mode: Runner.Output.Mode = parsed.showOutput ? .both : .capture
return run(arguments, stdoutMode: mode, stderrMode: mode)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/ReleaseTools/Runners/XCRunRunner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class XCRunRunner: Runner {
parsed.log("xcrun " + arguments.joined(separator: " "))
}

let mode: ProcessStream.Mode = parsed.showOutput ? .both : .capture
let mode: Runner.Output.Mode = parsed.showOutput ? .both : .capture
return run(arguments, stdoutMode: mode, stderrMode: mode)
}
}
4 changes: 2 additions & 2 deletions Sources/ReleaseTools/Runners/XCodeBuildRunner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class XCodeBuildRunner: Runner {

func schemes(workspace: String) async throws -> [String] {
let result = run(["-workspace", workspace, "-list", "-json"])
let output = await Data(result.stdout)
let output = await result.stdout.data
for await state in result.state {
if state == .succeeded {
let decoder = JSONDecoder()
Expand All @@ -35,7 +35,7 @@ class XCodeBuildRunner: Runner {
parsed.log("\n> xcodebuild \(arguments.joined(separator: " "))\n")
}

let mode: ProcessStream.Mode = parsed.showOutput ? .both : .capture
let mode: Runner.Output.Mode = parsed.showOutput ? .both : .capture
return run(arguments, stdoutMode: mode, stderrMode: mode)
}
}

0 comments on commit 8fd3b54

Please sign in to comment.