Skip to content

Add options to disable runner updates #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.DS_Store
.build
.index-build
.swiftpm
xcuserdata
Tartelet.xcodeproj
Expand Down
1 change: 1 addition & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ excluded:
- Packages/Settings/Sources/SettingsUI/Internal/Assets.swift
- Packages/Settings/Sources/SettingsUI/Internal/L10n.swift
- "**/.build"
- "**/.index-build"
opt_in_rules:
- anonymous_argument_in_multiline_closure
- array_init
Expand Down
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(isOn: $settingsStore.gitHubRunnerDisableUpdates) {
Text(L10n.Settings.GithubRunner.disableUpdates)
Text(L10n.Settings.GithubRunner.DisableUpdates.subtitle)
}
.disabled(!isSettingsEnabled)
}
}
.formStyle(.grouped)
}
Expand Down
6 changes: 6 additions & 0 deletions Packages/Settings/Sources/SettingsUI/Internal/L10n.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,16 @@ internal enum L10n {
}
}
internal enum GithubRunner {
/// Disable runner 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
internal static let labels = L10n.tr("Localizable", "settings.github_runner.labels", fallback: "Labels")
internal enum DisableUpdates {
/// This is meant to be used when a fixed version is pre-installed, otherwise Tartelet will install the latest version when the VM starts.
internal static let subtitle = L10n.tr("Localizable", "settings.github_runner.disableUpdates.subtitle", fallback: "This is meant to be used when a fixed version is pre-installed, otherwise Tartelet will install the latest version when the VM starts.")
}
internal enum Group {
/// acme
internal static let prompt = L10n.tr("Localizable", "settings.github_runner.group.prompt", fallback: "acme")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
"settings.github.create_app" = "Create GitHub App";

"settings.github_runner" = "Runner";
"settings.github_runner.disableUpdates" = "Disable runner auto-update";
"settings.github_runner.disableUpdates.subtitle" = "This is meant to be used when a fixed version is pre-installed, otherwise Tartelet will install the latest version when the VM starts.";
"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 ? "--disableupdate" : "")
./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