feat: Updates to check if playbook is installed prior to running any of the commands, updates tests.
This commit is contained in:
11
Release.md
11
Release.md
@@ -2,8 +2,12 @@
|
|||||||
|
|
||||||
This is a reminder of the steps used to create a release and update the homebrew formula.
|
This is a reminder of the steps used to create a release and update the homebrew formula.
|
||||||
|
|
||||||
1. Push a tagged branch, this will initiate the release being created.
|
> Note: These steps apply to the version hosted on `gitea`, on `github` more of these steps can be
|
||||||
1. Don't forget to also update the version in `Sources/hpa/Version.swift`, prior.
|
> automated in `ci`, but there are no `macOS` host runners currently in `gitea`.
|
||||||
|
|
||||||
|
1. Update the version in `Sources/hpa/Version.swift`.
|
||||||
|
1. Tag the commit with the next version tag.
|
||||||
|
1. Push the tagged commit, this will initiate the release being created.
|
||||||
1. Get the `sha` of the `*.tar.gz` in the release.
|
1. Get the `sha` of the `*.tar.gz` in the release.
|
||||||
1. `just get-release-sha`
|
1. `just get-release-sha`
|
||||||
1. Update the homebrew formula url, sha256, and version at top of the homebrew formula.
|
1. Update the homebrew formula url, sha256, and version at top of the homebrew formula.
|
||||||
@@ -11,5 +15,8 @@ This is a reminder of the steps used to create a release and update the homebrew
|
|||||||
1. Build and generate a homebrew bottle.
|
1. Build and generate a homebrew bottle.
|
||||||
1. `just bottle`
|
1. `just bottle`
|
||||||
1. Update the `bottle do` section of homebrew formula with output during previous step.
|
1. Update the `bottle do` section of homebrew formula with output during previous step.
|
||||||
|
1. Also make sure the `root_url` in the bottle section points to the new release.
|
||||||
1. Upload the bottle `*.tar.gz` file that was created to the release.
|
1. Upload the bottle `*.tar.gz` file that was created to the release.
|
||||||
1. Generate a pull-request to the formula repo.
|
1. Generate a pull-request to the formula repo.
|
||||||
|
1. Remove the bottle from current directory.
|
||||||
|
1. `just remove-bottles`
|
||||||
|
|||||||
@@ -120,7 +120,11 @@ struct LiveFileClient: Sendable {
|
|||||||
|
|
||||||
func isDirectory(_ url: URL) -> Bool {
|
func isDirectory(_ url: URL) -> Bool {
|
||||||
var isDirectory: ObjCBool = false
|
var isDirectory: ObjCBool = false
|
||||||
manager.fileExists(atPath: url.cleanFilePath, isDirectory: &isDirectory)
|
#if os(Linux)
|
||||||
|
_ = manager.fileExists(atPath: url.cleanFilePath, isDirectory: &isDirectory)
|
||||||
|
#else
|
||||||
|
manager.fileExists(atPath: url.cleanFilePath, isDirectory: &isDirectory)
|
||||||
|
#endif
|
||||||
return isDirectory.boolValue
|
return isDirectory.boolValue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,8 @@ extension PlaybookClient.RunPlaybook.SharedRunOptions {
|
|||||||
) async throws -> T {
|
) async throws -> T {
|
||||||
@Dependency(\.commandClient) var commandClient
|
@Dependency(\.commandClient) var commandClient
|
||||||
|
|
||||||
|
try await ensurePlaybookExists()
|
||||||
|
|
||||||
return try await commandClient.run(
|
return try await commandClient.run(
|
||||||
logging: loggingOptions,
|
logging: loggingOptions,
|
||||||
quiet: quiet,
|
quiet: quiet,
|
||||||
@@ -101,6 +103,17 @@ extension PlaybookClient.RunPlaybook.SharedRunOptions {
|
|||||||
return (arguments, output)
|
return (arguments, output)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func ensurePlaybookExists() async throws {
|
||||||
|
@Dependency(\.fileClient) var fileClient
|
||||||
|
@Dependency(\.playbookClient.repository) var repository
|
||||||
|
|
||||||
|
let directory = try await repository.directory()
|
||||||
|
let exists = try await fileClient.isDirectory(URL(filePath: directory))
|
||||||
|
if !exists {
|
||||||
|
try await repository.install()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@_spi(Internal)
|
@_spi(Internal)
|
||||||
|
|||||||
@@ -23,7 +23,11 @@ struct FileClientTests {
|
|||||||
let fileClient = FileClient.liveValue
|
let fileClient = FileClient.liveValue
|
||||||
|
|
||||||
let vaultFilePath = url.appending(path: fileName)
|
let vaultFilePath = url.appending(path: fileName)
|
||||||
FileManager.default.createFile(atPath: vaultFilePath.cleanFilePath, contents: nil)
|
#if os(Linux)
|
||||||
|
_ = FileManager.default.createFile(atPath: vaultFilePath.cleanFilePath, contents: nil)
|
||||||
|
#else
|
||||||
|
FileManager.default.createFile(atPath: vaultFilePath.cleanFilePath, contents: nil)
|
||||||
|
#endif
|
||||||
let output = try await fileClient.findVaultFile(url)!
|
let output = try await fileClient.findVaultFile(url)!
|
||||||
|
|
||||||
#expect(output.cleanFilePath == vaultFilePath.cleanFilePath)
|
#expect(output.cleanFilePath == vaultFilePath.cleanFilePath)
|
||||||
@@ -43,7 +47,11 @@ struct FileClientTests {
|
|||||||
try await fileClient.createDirectory(subDir)
|
try await fileClient.createDirectory(subDir)
|
||||||
|
|
||||||
let vaultFilePath = subDir.appending(path: fileName)
|
let vaultFilePath = subDir.appending(path: fileName)
|
||||||
FileManager.default.createFile(atPath: vaultFilePath.cleanFilePath, contents: nil)
|
#if os(Linux)
|
||||||
|
_ = FileManager.default.createFile(atPath: vaultFilePath.cleanFilePath, contents: nil)
|
||||||
|
#else
|
||||||
|
FileManager.default.createFile(atPath: vaultFilePath.cleanFilePath, contents: nil)
|
||||||
|
#endif
|
||||||
let output = try await fileClient.findVaultFile(url)!
|
let output = try await fileClient.findVaultFile(url)!
|
||||||
|
|
||||||
#expect(output.cleanFilePath == vaultFilePath.cleanFilePath)
|
#expect(output.cleanFilePath == vaultFilePath.cleanFilePath)
|
||||||
|
|||||||
@@ -145,6 +145,7 @@ struct PlaybookClientTests: TestCase {
|
|||||||
@Test
|
@Test
|
||||||
func generateTemplate() async throws {
|
func generateTemplate() async throws {
|
||||||
try await withCapturingCommandClient("generateTemplate") {
|
try await withCapturingCommandClient("generateTemplate") {
|
||||||
|
$0.fileClient.isDirectory = { _ in true }
|
||||||
$0.configurationClient = .mock()
|
$0.configurationClient = .mock()
|
||||||
$0.playbookClient = .liveValue
|
$0.playbookClient = .liveValue
|
||||||
} run: {
|
} run: {
|
||||||
@@ -180,6 +181,7 @@ struct PlaybookClientTests: TestCase {
|
|||||||
operation: @Sendable @escaping () async throws -> Void
|
operation: @Sendable @escaping () async throws -> Void
|
||||||
) async rethrows {
|
) async rethrows {
|
||||||
try await withDependencies {
|
try await withDependencies {
|
||||||
|
$0.fileClient.isDirectory = { _ in true }
|
||||||
$0.configurationClient = .mock(configuration)
|
$0.configurationClient = .mock(configuration)
|
||||||
$0.commandClient = .capturing(capturing)
|
$0.commandClient = .capturing(capturing)
|
||||||
$0.playbookClient = .liveValue
|
$0.playbookClient = .liveValue
|
||||||
|
|||||||
Reference in New Issue
Block a user