tenseleyflow/shithub / c214372

Browse files

actions/runners: standardize shared linux labels (S41j)

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
c214372f146ce37996ca731c49277e0f4ba8849e
Parents
9f6a689
Tree
cd1cdf4

6 changed files

StatusFile+-
M deploy/ansible/inventory/production.example 2 2
M deploy/ansible/inventory/staging.example 1 1
M deploy/ansible/roles/shithubd-runner/defaults/main.yml 1 0
M internal/actions/runnerlabels/labels.go 7 0
M internal/runner/config/config.go 1 1
M internal/runner/config/config_test.go 3 0
deploy/ansible/inventory/production.examplemodified
@@ -45,11 +45,11 @@ grafana_cloud_prom_user=REPLACE_ME # numeric tenant id
4545
 grafana_cloud_prom_token=REPLACE_ME   # access-policy token
4646
 
4747
 # Optional Actions runner on this host. Generate the token with:
48
-#   shithubd admin runner register --name prod-runner-1 --labels self-hosted,linux,ubuntu-latest --capacity 1
48
+#   shithubd admin runner register --name prod-runner-1 --labels self-hosted,linux,ubuntu-latest,x64 --capacity 1 --output json
4949
 # Store the real token in ansible-vault or your secret manager.
5050
 # shithub_runner_enabled=true
5151
 # shithub_runner_token=REPLACE_ME
52
-# shithub_runner_labels=self-hosted,linux,ubuntu-latest
52
+# shithub_runner_labels=self-hosted,linux,ubuntu-latest,x64
5353
 # shithub_runner_capacity=1
5454
 # shithub_runner_default_image=ghcr.io/shithub/runner-nix:1.0
5555
 # The role creates shithub-actions on shact0 (172.30.0.1/24), runs
deploy/ansible/inventory/staging.examplemodified
@@ -26,5 +26,5 @@ shithub_email_backend=stdout # no real outbound mail in staging
2626
 # Optional Actions runner on this host.
2727
 # shithub_runner_enabled=true
2828
 # shithub_runner_token=REPLACE_ME
29
-# shithub_runner_labels=self-hosted,linux,ubuntu-latest
29
+# shithub_runner_labels=self-hosted,linux,ubuntu-latest,x64
3030
 # shithub_runner_capacity=1
deploy/ansible/roles/shithubd-runner/defaults/main.ymlmodified
@@ -8,6 +8,7 @@ shithub_runner_labels:
88
   - self-hosted
99
   - linux
1010
   - ubuntu-latest
11
+  - x64
1112
 shithub_runner_capacity: 1
1213
 shithub_runner_poll_interval: 5s
1314
 shithub_runner_workspace_root: /var/lib/shithubd-runner/workspaces
internal/actions/runnerlabels/labels.gomodified
@@ -13,6 +13,13 @@ import (
1313
 
1414
 var labelRE = regexp.MustCompile(`^[A-Za-z0-9_.-]+$`)
1515
 
16
+var defaultSharedLabels = []string{"self-hosted", "linux", "ubuntu-latest", "x64"}
17
+
18
+// DefaultShared returns the labels for the built-in shared Linux runner pool.
19
+func DefaultShared() []string {
20
+	return append([]string(nil), defaultSharedLabels...)
21
+}
22
+
1623
 // ParseCSV parses a comma-separated label list.
1724
 func ParseCSV(raw string) ([]string, error) {
1825
 	raw = strings.TrimSpace(raw)
internal/runner/config/config.gomodified
@@ -100,7 +100,7 @@ func Defaults() Config {
100100
 			BaseURL: "http://127.0.0.1:8080",
101101
 		},
102102
 		Runner: RunnerConfig{
103
-			Labels:           []string{"self-hosted", "linux", "ubuntu-latest"},
103
+			Labels:           runnerlabels.DefaultShared(),
104104
 			Capacity:         1,
105105
 			PollInterval:     5 * time.Second,
106106
 			WorkspaceRoot:    "/var/lib/shithubd-runner/workspaces",
internal/runner/config/config_test.gomodified
@@ -40,6 +40,9 @@ func TestLoad_DefaultsWithToken(t *testing.T) {
4040
 	if cfg.Engine.PidsLimit != 512 {
4141
 		t.Fatalf("Engine.PidsLimit: %d", cfg.Engine.PidsLimit)
4242
 	}
43
+	if want := []string{"self-hosted", "linux", "ubuntu-latest", "x64"}; !reflect.DeepEqual(cfg.Runner.Labels, want) {
44
+		t.Fatalf("Labels: got %#v want %#v", cfg.Runner.Labels, want)
45
+	}
4346
 	if want := []string{"api.github.com", "auth.docker.io", "codeload.github.com", "github.com", "objects.githubusercontent.com", "production.cloudflare.docker.com", "registry-1.docker.io", "*.githubusercontent.com"}; !reflect.DeepEqual(cfg.Runner.NetworkAllowlist, want) {
4447
 		t.Fatalf("NetworkAllowlist: got %#v want %#v", cfg.Runner.NetworkAllowlist, want)
4548
 	}