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
e2e/build_cancel_test.go +1 −1
@@ -124,7 +124,7 @@ func TestBuildCancelRunning(t *testing.T) {
124124 runner := exec.Command(inst.runner, "-once", "-remote", "git@127.0.0.1", "-ssh-opts", opts,
125125 "-isolation", "none",
126126 "-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")
128128 var runnerOut strings.Builder
129129 runner.Stdout, runner.Stderr = &runnerOut, &runnerOut
130130 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
3939 "-workdir", t.TempDir()}
4040 args = append(args, extra...)
4141 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")
4343 out, err := cmd.CombinedOutput()
4444 if err != nil {
4545 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 {
293293 "-ssh-opts", opts,
294294 "-clone-base", fmt.Sprintf("ssh://git@127.0.0.1:%d", i.port),
295295 "-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")
297297 var buf bytes.Buffer
298298 cmd.Stdout, cmd.Stderr = &buf, &buf
299299 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) {
182182 "-image", "localhost/gitbay-ci:1",
183183 "-clone-base", fmt.Sprintf("ssh://git@127.0.0.1:%d", inst.port),
184184 "-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")
186186 if out, err := cmd.CombinedOutput(); err != nil {
187187 t.Fatalf("runner: %v\n%s", err, out)
188188 }
e2e/runnerattach_test.go +4
@@ -74,6 +74,10 @@ func TestAttachedRunnerBuildsOwnRepo(t *testing.T) {
7474 if out, _, _ := inst.ssh(t, aliceKey, "", "build", "list", "alice/app"); !strings.Contains(out, "unit\tpending") {
7575 t.Fatalf("build not pending before attach: %s", out)
7676 }
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 }
7781
7882 // Attach with the printed key.
7983 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 {
8181func TestRunnerDrainsOnSIGTERM(t *testing.T) {
8282 inst, key := stopFixture(t)
8383 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")
8585 var buf bytes.Buffer
8686 cmd.Stdout, cmd.Stderr = &buf, &buf
8787 if err := cmd.Start(); err != nil {