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
45
 grafana_cloud_prom_token=REPLACE_ME   # access-policy token
45
 grafana_cloud_prom_token=REPLACE_ME   # access-policy token
46
 
46
 
47
 # Optional Actions runner on this host. Generate the token with:
47
 # 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
49
 # Store the real token in ansible-vault or your secret manager.
49
 # Store the real token in ansible-vault or your secret manager.
50
 # shithub_runner_enabled=true
50
 # shithub_runner_enabled=true
51
 # shithub_runner_token=REPLACE_ME
51
 # shithub_runner_token=REPLACE_ME
52
-# shithub_runner_labels=self-hosted,linux,ubuntu-latest
52
+# shithub_runner_labels=self-hosted,linux,ubuntu-latest,x64
53
 # shithub_runner_capacity=1
53
 # shithub_runner_capacity=1
54
 # shithub_runner_default_image=ghcr.io/shithub/runner-nix:1.0
54
 # shithub_runner_default_image=ghcr.io/shithub/runner-nix:1.0
55
 # The role creates shithub-actions on shact0 (172.30.0.1/24), runs
55
 # 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
26
 # Optional Actions runner on this host.
26
 # Optional Actions runner on this host.
27
 # shithub_runner_enabled=true
27
 # shithub_runner_enabled=true
28
 # shithub_runner_token=REPLACE_ME
28
 # shithub_runner_token=REPLACE_ME
29
-# shithub_runner_labels=self-hosted,linux,ubuntu-latest
29
+# shithub_runner_labels=self-hosted,linux,ubuntu-latest,x64
30
 # shithub_runner_capacity=1
30
 # shithub_runner_capacity=1
deploy/ansible/roles/shithubd-runner/defaults/main.ymlmodified
@@ -8,6 +8,7 @@ shithub_runner_labels:
8
   - self-hosted
8
   - self-hosted
9
   - linux
9
   - linux
10
   - ubuntu-latest
10
   - ubuntu-latest
11
+  - x64
11
 shithub_runner_capacity: 1
12
 shithub_runner_capacity: 1
12
 shithub_runner_poll_interval: 5s
13
 shithub_runner_poll_interval: 5s
13
 shithub_runner_workspace_root: /var/lib/shithubd-runner/workspaces
14
 shithub_runner_workspace_root: /var/lib/shithubd-runner/workspaces
internal/actions/runnerlabels/labels.gomodified
@@ -13,6 +13,13 @@ import (
13
 
13
 
14
 var labelRE = regexp.MustCompile(`^[A-Za-z0-9_.-]+$`)
14
 var labelRE = regexp.MustCompile(`^[A-Za-z0-9_.-]+$`)
15
 
15
 
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
+
16
 // ParseCSV parses a comma-separated label list.
23
 // ParseCSV parses a comma-separated label list.
17
 func ParseCSV(raw string) ([]string, error) {
24
 func ParseCSV(raw string) ([]string, error) {
18
 	raw = strings.TrimSpace(raw)
25
 	raw = strings.TrimSpace(raw)
internal/runner/config/config.gomodified
@@ -100,7 +100,7 @@ func Defaults() Config {
100
 			BaseURL: "http://127.0.0.1:8080",
100
 			BaseURL: "http://127.0.0.1:8080",
101
 		},
101
 		},
102
 		Runner: RunnerConfig{
102
 		Runner: RunnerConfig{
103
-			Labels:           []string{"self-hosted", "linux", "ubuntu-latest"},
103
+			Labels:           runnerlabels.DefaultShared(),
104
 			Capacity:         1,
104
 			Capacity:         1,
105
 			PollInterval:     5 * time.Second,
105
 			PollInterval:     5 * time.Second,
106
 			WorkspaceRoot:    "/var/lib/shithubd-runner/workspaces",
106
 			WorkspaceRoot:    "/var/lib/shithubd-runner/workspaces",
internal/runner/config/config_test.gomodified
@@ -40,6 +40,9 @@ func TestLoad_DefaultsWithToken(t *testing.T) {
40
 	if cfg.Engine.PidsLimit != 512 {
40
 	if cfg.Engine.PidsLimit != 512 {
41
 		t.Fatalf("Engine.PidsLimit: %d", cfg.Engine.PidsLimit)
41
 		t.Fatalf("Engine.PidsLimit: %d", cfg.Engine.PidsLimit)
42
 	}
42
 	}
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
+	}
43
 	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) {
46
 	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) {
44
 		t.Fatalf("NetworkAllowlist: got %#v want %#v", cfg.Runner.NetworkAllowlist, want)
47
 		t.Fatalf("NetworkAllowlist: got %#v want %#v", cfg.Runner.NetworkAllowlist, want)
45
 	}
48
 	}