Commit 7da0d08800

7da0d088004c5729bd52239e0f4ca3ba714cbb05

parent: 3398f2216b

Verified · cmc

cmc <hello@cleberg.net> · 2026-09-09 03:48 UTC

e2e: runners get their own config dir, and the unattached poll is tested

Every runner the suite starts now runs with XDG_CONFIG_HOME set to a
temp dir, so a developer's own ~/.config/gitbay-runner is not injected
into the test's remote, identity and repo scope.

TestAttachedRunnerBuildsOwnRepo polls once before the attach and asserts
the build is still pending, which is what its comment claimed.

Ref #184

Layout: unified · split

e2e/build_cancel_test.go +1 −1
@@ -124,7 +124,7 @@ func TestBuildCancelRunning(t *testing.T) {
124 runner := exec.Command(inst.runner, "-once", "-remote", "git@127.0.0.1", "-ssh-opts", opts, 124 runner := exec.Command(inst.runner, "-once", "-remote", "git@127.0.0.1", "-ssh-opts", opts,
125 "-isolation", "none", 125 "-isolation", "none",
126 "-clone-base", fmt.Sprintf("ssh://git@127.0.0.1:%d", inst.port), "-workdir", t.TempDir()) 126 "-clone-base", fmt.Sprintf("ssh://git@127.0.0.1:%d", inst.port), "-workdir", t.TempDir())
127 runner.Env = append(os.Environ(), "GIT_CONFIG_NOSYSTEM=1", "GIT_CONFIG_GLOBAL=/dev/null") 127 runner.Env = append(os.Environ(), "XDG_CONFIG_HOME="+t.TempDir(), "GIT_CONFIG_NOSYSTEM=1", "GIT_CONFIG_GLOBAL=/dev/null")
128 var runnerOut strings.Builder 128 var runnerOut strings.Builder
129 runner.Stdout, runner.Stderr = &runnerOut, &runnerOut 129 runner.Stdout, runner.Stderr = &runnerOut, &runnerOut
130 if err := runner.Start(); err != nil { 130 if err := runner.Start(); err != nil {
e2e/ci_test.go +2 −2
@@ -39,7 +39,7 @@ func (i *instance) runnerOnce(t *testing.T, key string, extra ...string) string
39 "-workdir", t.TempDir()} 39 "-workdir", t.TempDir()}
40 args = append(args, extra...) 40 args = append(args, extra...)
41 cmd := exec.Command(i.runner, args...) 41 cmd := exec.Command(i.runner, args...)
42 cmd.Env = append(os.Environ(), "GIT_CONFIG_NOSYSTEM=1", "GIT_CONFIG_GLOBAL=/dev/null") 42 cmd.Env = append(os.Environ(), "XDG_CONFIG_HOME="+t.TempDir(), "GIT_CONFIG_NOSYSTEM=1", "GIT_CONFIG_GLOBAL=/dev/null")
43 out, err := cmd.CombinedOutput() 43 out, err := cmd.CombinedOutput()
44 if err != nil { 44 if err != nil {
45 t.Fatalf("runner: %v\n%s", err, out) 45 t.Fatalf("runner: %v\n%s", err, out)
@@ -293,7 +293,7 @@ func (i *instance) runnerJobs(t *testing.T, key, repo string, jobs int) string {
293 "-ssh-opts", opts, 293 "-ssh-opts", opts,
294 "-clone-base", fmt.Sprintf("ssh://git@127.0.0.1:%d", i.port), 294 "-clone-base", fmt.Sprintf("ssh://git@127.0.0.1:%d", i.port),
295 "-workdir", t.TempDir()) 295 "-workdir", t.TempDir())
296 cmd.Env = append(os.Environ(), "GIT_CONFIG_NOSYSTEM=1", "GIT_CONFIG_GLOBAL=/dev/null") 296 cmd.Env = append(os.Environ(), "XDG_CONFIG_HOME="+t.TempDir(), "GIT_CONFIG_NOSYSTEM=1", "GIT_CONFIG_GLOBAL=/dev/null")
297 var buf bytes.Buffer 297 var buf bytes.Buffer
298 cmd.Stdout, cmd.Stderr = &buf, &buf 298 cmd.Stdout, cmd.Stderr = &buf, &buf
299 if err := cmd.Start(); err != nil { 299 if err := cmd.Start(); err != nil {
e2e/isolation_podman_test.go +1 −1
@@ -182,7 +182,7 @@ func runnerPodmanOnce(t *testing.T, inst *instance, key string) {
182 "-image", "localhost/gitbay-ci:1", 182 "-image", "localhost/gitbay-ci:1",
183 "-clone-base", fmt.Sprintf("ssh://git@127.0.0.1:%d", inst.port), 183 "-clone-base", fmt.Sprintf("ssh://git@127.0.0.1:%d", inst.port),
184 "-workdir", t.TempDir()) 184 "-workdir", t.TempDir())
185 cmd.Env = append(os.Environ(), "GIT_CONFIG_NOSYSTEM=1", "GIT_CONFIG_GLOBAL=/dev/null") 185 cmd.Env = append(os.Environ(), "XDG_CONFIG_HOME="+t.TempDir(), "GIT_CONFIG_NOSYSTEM=1", "GIT_CONFIG_GLOBAL=/dev/null")
186 if out, err := cmd.CombinedOutput(); err != nil { 186 if out, err := cmd.CombinedOutput(); err != nil {
187 t.Fatalf("runner: %v\n%s", err, out) 187 t.Fatalf("runner: %v\n%s", err, out)
188 } 188 }
e2e/runnerattach_test.go +4
@@ -74,6 +74,10 @@ func TestAttachedRunnerBuildsOwnRepo(t *testing.T) {
74 if out, _, _ := inst.ssh(t, aliceKey, "", "build", "list", "alice/app"); !strings.Contains(out, "unit\tpending") { 74 if out, _, _ := inst.ssh(t, aliceKey, "", "build", "list", "alice/app"); !strings.Contains(out, "unit\tpending") {
75 t.Fatalf("build not pending before attach: %s", out) 75 t.Fatalf("build not pending before attach: %s", out)
76 } 76 }
77 run()
78 if out, _, _ := inst.ssh(t, aliceKey, "", "build", "list", "alice/app"); !strings.Contains(out, "unit\tpending") {
79 t.Fatalf("unattached runner claimed the build: %s", out)
80 }
77 81
78 // Attach with the printed key. 82 // Attach with the printed key.
79 if _, errOut, code := inst.ssh(t, aliceKey, string(pub), "repo", "runner", "add", "alice/app"); code != 0 { 83 if _, errOut, code := inst.ssh(t, aliceKey, string(pub), "repo", "runner", "add", "alice/app"); code != 0 {
e2e/runnerstop_test.go +1 −1
@@ -81,7 +81,7 @@ func (i *instance) buildStatus(t *testing.T, key string) string {
81func TestRunnerDrainsOnSIGTERM(t *testing.T) { 81func TestRunnerDrainsOnSIGTERM(t *testing.T) {
82 inst, key := stopFixture(t) 82 inst, key := stopFixture(t)
83 cmd := exec.Command(inst.runner, inst.runnerArgs(t, key)...) 83 cmd := exec.Command(inst.runner, inst.runnerArgs(t, key)...)
84 cmd.Env = append(os.Environ(), "GIT_CONFIG_NOSYSTEM=1", "GIT_CONFIG_GLOBAL=/dev/null") 84 cmd.Env = append(os.Environ(), "XDG_CONFIG_HOME="+t.TempDir(), "GIT_CONFIG_NOSYSTEM=1", "GIT_CONFIG_GLOBAL=/dev/null")
85 var buf bytes.Buffer 85 var buf bytes.Buffer
86 cmd.Stdout, cmd.Stderr = &buf, &buf 86 cmd.Stdout, cmd.Stderr = &buf, &buf
87 if err := cmd.Start(); err != nil { 87 if err := cmd.Start(); err != nil {