Skip to content

Commit

Permalink
Add options to disable runner updates
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhnroyal committed Feb 3, 2025
1 parent e6bcb76 commit 5d17c51
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public final class AppStorageSettingsStore: SettingsStore {
static let numberOfVirtualMachines = "numberOfVirtualMachines"
static let startVirtualMachinesOnLaunch = "startVirtualMachinesOnLaunch"
static let gitHubPrivateKeyName = "gitHubPrivateKeyName"
static let gitHubRunnerDisableUpdates = "gitHubRunnerDisableUpdates"
static let gitHubRunnerLabels = "gitHubRunnerLabels"
static let gitHubRunnerGroup = "gitHubRunnerGroup"
static let githubRunnerScope = "githubRunnerScope"
Expand Down Expand Up @@ -91,6 +92,17 @@ public final class AppStorageSettingsStore: SettingsStore {
}
}
}
public var gitHubRunnerDisableUpdates: Bool {
get {
access(keyPath: \.gitHubRunnerDisableUpdates)
return userDefaults.bool(forKey: AppStorageKey.gitHubRunnerDisableUpdates)
}
set {
withMutation(keyPath: \.gitHubRunnerDisableUpdates) {
userDefaults.setValue(newValue, forKey: AppStorageKey.gitHubRunnerDisableUpdates)
}
}
}
public var gitHubRunnerLabels: String {
get {
access(keyPath: \.gitHubRunnerLabels)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public protocol SettingsStore: AnyObject {
var numberOfVirtualMachines: Int { get set }
var startVirtualMachinesOnLaunch: Bool { get set }
var gitHubPrivateKeyName: String? { get set }
var gitHubRunnerDisableUpdates: Bool { get set }
var gitHubRunnerLabels: String { get set }
var gitHubRunnerGroup: String { get set }
var githubRunnerScope: GitHubRunnerScope { get set }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ struct GitHubRunnerSettingsView<SettingsStoreType: SettingsStore & Observable>:
)
.disabled(!isSettingsEnabled)
}
Section {
Toggle(
L10n.Settings.GithubRunner.disableUpdates,
isOn: $settingsStore.gitHubRunnerDisableUpdates
)
.disabled(!isSettingsEnabled)
}
}
.formStyle(.grouped)
}
Expand Down
2 changes: 2 additions & 0 deletions Packages/Settings/Sources/SettingsUI/Internal/L10n.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ internal enum L10n {
}
}
internal enum GithubRunner {
/// Auto-update
internal static let disableUpdates = L10n.tr("Localizable", "settings.github_runner.disableUpdates", fallback: "Disable runner auto-update")
/// Group
internal static let group = L10n.tr("Localizable", "settings.github_runner.group", fallback: "Group")
/// Labels
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"settings.github.create_app" = "Create GitHub App";

"settings.github_runner" = "Runner";
"settings.github_runner.disableUpdates" = "Disable runner auto-update";
"settings.github_runner.labels" = "Labels";
"settings.github_runner.labels.prompt" = "comma,separated,list";
"settings.github_runner.labels.footer" = "Comma-separated list of labels.";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import GitHubDomain

public protocol GitHubActionsRunnerConfiguration {
var runnerDisableUpdates: Bool { get }
var runnerScope: GitHubRunnerScope { get }
var runnerLabels: String { get }
var runnerGroup: String { get }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ cd \\$ACTIONS_RUNNER_DIRECTORY
--name "\(virtualMachine.name)"\\\\
--runnergroup "\(configuration.runnerGroup)"\\\\
--work "_work"\\\\
--token "\(runnerToken.rawValue)"
--token "\(runnerToken.rawValue)"\\\\
\(configuration.runnerDisableUpdates ? "--disableUpdates" : "")
./run.sh
EOF
""")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ struct SettingsGitHubActionsRunnerConfiguration<
SettingsStoreType: SettingsStore
>: GitHubActionsRunnerConfiguration {
let settingsStore: SettingsStoreType
var runnerDisableUpdates: Bool {
settingsStore.gitHubRunnerDisableUpdates
}
var runnerScope: GitHubRunnerScope {
settingsStore.githubRunnerScope
}
Expand Down

0 comments on commit 5d17c51

Please sign in to comment.