chore(executor): lint fixes for the container code
- commit
- 9596a7326953aec7a2f7935eb0c5f8509bb07ccc
- author
- brice · · 2026-10-14 06:00 UTC
- parent
- 59a9c3a
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
3 files · +4 -36
M internal/executor/containers_fake_test.go +0 -9
| @@ -5,7 +5,6 @@ package executor | |||
| 5 | 5 | import ( | |
| 6 | 6 | "os" | |
| 7 | 7 | "path/filepath" | |
| 8 | - | "strings" | |
| 9 | 8 | "testing" | |
| 10 | 9 | "time" | |
| 11 | 10 | ) | |
| @@ -104,14 +103,6 @@ func ctrRunC(t *testing.T, f *fakeCtr, cancel *Canceller, jobYAML, steps string, | |||
| 104 | 103 | }) | |
| 105 | 104 | } | |
| 106 | 105 | ||
| 107 | - | func joinCalls(cs [][]string) string { | |
| 108 | - | var b strings.Builder | |
| 109 | - | for _, c := range cs { | |
| 110 | - | b.WriteString(strings.Join(c, " ") + "\n") | |
| 111 | - | } | |
| 112 | - | return b.String() | |
| 113 | - | } | |
| 114 | - | ||
| 115 | 106 | // concl is the conclusion of the step called name. | |
| 116 | 107 | func (r *recorder) concl(name string) Conclusion { | |
| 117 | 108 | r.mu.Lock() | |
| @@ -5,7 +5,6 @@ package executor | |||||
| 5 | import ( | 5 | import ( | ||
| 6 | "os" | 6 | "os" | ||
| 7 | "path/filepath" | 7 | "path/filepath" | ||
| 8 | - | "strings" | |||
| 9 | "testing" | 8 | "testing" | ||
| 10 | "time" | 9 | "time" | ||
| 11 | ) | 10 | ) | ||
| @@ -104,14 +103,6 @@ func ctrRunC(t *testing.T, f *fakeCtr, cancel *Canceller, jobYAML, steps string, | |||||
| 104 | }) | 103 | }) | ||
| 105 | } | 104 | } | ||
| 106 | 105 | ||||
| 107 | - | func joinCalls(cs [][]string) string { | |||
| 108 | - | var b strings.Builder | |||
| 109 | - | for _, c := range cs { | |||
| 110 | - | b.WriteString(strings.Join(c, " ") + "\n") | |||
| 111 | - | } | |||
| 112 | - | return b.String() | |||
| 113 | - | } | |||
| 114 | - | ||||
| 115 | // concl is the conclusion of the step called name. | 106 | // concl is the conclusion of the step called name. | ||
| 116 | func (r *recorder) concl(name string) Conclusion { | 107 | func (r *recorder) concl(name string) Conclusion { | ||
| 117 | r.mu.Lock() | 108 | r.mu.Lock() | ||
M internal/executor/containers_init.go +4 -4
| @@ -50,10 +50,10 @@ func (j *job) initContainersStep() qstep { | |||
| 50 | 50 | // (StepsRunner.cs:314-340): a cancellation is logged and cancels the step, | |
| 51 | 51 | // anything else is logged with its message and fails it. | |
| 52 | 52 | func (j *job) containerResult(s *stepRun, err error) stepResult { | |
| 53 | - | switch { | |
| 54 | - | case err == nil: | |
| 53 | + | if err == nil { | |
| 55 | 54 | return resSucceeded | |
| 56 | - | case err == errCancelled: | |
| 55 | + | } | |
| 56 | + | if err == errCancelled { | |
| 57 | 57 | return j.cancelledStep(s) | |
| 58 | 58 | } | |
| 59 | 59 | j.errorf(s.num, "%s", err.Error()) | |
| @@ -210,7 +210,7 @@ func (j *job) registryLogin(s *stepRun, c *container, cancel <-chan struct{}) (s | |||
| 210 | 210 | j.addMask(c.credPass) | |
| 211 | 211 | dir := filepath.Join(j.state.Layout().Temp, ".docker_"+strings.ReplaceAll(newImageTag(""), ":", "")) | |
| 212 | 212 | if err := os.MkdirAll(dir, 0o700); err != nil { | |
| 213 | - | return "", fmt.Errorf("Failed to create directory to store registry client credentials: %v", err) | |
| 213 | + | return "", ghErrorf("Failed to create directory to store registry client credentials: %v", err) | |
| 214 | 214 | } | |
| 215 | 215 | j.own(dir) | |
| 216 | 216 | args := []string{j.dockerPath(), "--config", dir, "login"} | |
| @@ -50,10 +50,10 @@ func (j *job) initContainersStep() qstep { | |||||
| 50 | // (StepsRunner.cs:314-340): a cancellation is logged and cancels the step, | 50 | // (StepsRunner.cs:314-340): a cancellation is logged and cancels the step, | ||
| 51 | // anything else is logged with its message and fails it. | 51 | // anything else is logged with its message and fails it. | ||
| 52 | func (j *job) containerResult(s *stepRun, err error) stepResult { | 52 | func (j *job) containerResult(s *stepRun, err error) stepResult { | ||
| 53 | - | switch { | 53 | + | if err == nil { |
| 54 | - | case err == nil: | |||
| 55 | return resSucceeded | 54 | return resSucceeded | ||
| 56 | - | case err == errCancelled: | 55 | + | } |
| 56 | + | if err == errCancelled { | |||
| 57 | return j.cancelledStep(s) | 57 | return j.cancelledStep(s) | ||
| 58 | } | 58 | } | ||
| 59 | j.errorf(s.num, "%s", err.Error()) | 59 | j.errorf(s.num, "%s", err.Error()) | ||
| @@ -210,7 +210,7 @@ func (j *job) registryLogin(s *stepRun, c *container, cancel <-chan struct{}) (s | |||||
| 210 | j.addMask(c.credPass) | 210 | j.addMask(c.credPass) | ||
| 211 | dir := filepath.Join(j.state.Layout().Temp, ".docker_"+strings.ReplaceAll(newImageTag(""), ":", "")) | 211 | dir := filepath.Join(j.state.Layout().Temp, ".docker_"+strings.ReplaceAll(newImageTag(""), ":", "")) | ||
| 212 | if err := os.MkdirAll(dir, 0o700); err != nil { | 212 | if err := os.MkdirAll(dir, 0o700); err != nil { | ||
| 213 | - | return "", fmt.Errorf("Failed to create directory to store registry client credentials: %v", err) | 213 | + | return "", ghErrorf("Failed to create directory to store registry client credentials: %v", err) |
| 214 | } | 214 | } | ||
| 215 | j.own(dir) | 215 | j.own(dir) | ||
| 216 | args := []string{j.dockerPath(), "--config", dir, "login"} | 216 | args := []string{j.dockerPath(), "--config", dir, "login"} | ||
D internal/executor/zz_dump_test.go +0 -23
| @@ -1,23 +0,0 @@ | |||
| 1 | - | package executor | |
| 2 | - | ||
| 3 | - | import ( | |
| 4 | - | "os" | |
| 5 | - | "strings" | |
| 6 | - | "testing" | |
| 7 | - | ) | |
| 8 | - | ||
| 9 | - | func TestZZDump(t *testing.T) { | |
| 10 | - | docker := realDocker(t) | |
| 11 | - | y, _ := os.ReadFile(os.Getenv("DUMP_YAML")) | |
| 12 | - | rec, _ := runLocal(t, string(y), os.Getenv("DUMP_JOB"), func(c *Config) { | |
| 13 | - | c.Actions.DockerPath = docker | |
| 14 | - | c.BaseEnv = append(c.BaseEnv, "XDG_RUNTIME_DIR="+os.Getenv("XDG_RUNTIME_DIR")) | |
| 15 | - | c.Actions.ExternalsDir = fakeNode(t) | |
| 16 | - | c.Runner.Environment = "github-hosted" | |
| 17 | - | }) | |
| 18 | - | var b strings.Builder | |
| 19 | - | for _, s := range rec.steps { | |
| 20 | - | b.WriteString("=== STEP " + s.Name + " " + string(s.Conclusion) + "\n" + logOf(s) + "\n") | |
| 21 | - | } | |
| 22 | - | os.WriteFile(os.Getenv("DUMP_OUT"), []byte(b.String()), 0o644) | |
| 23 | - | } | |
| @@ -1,23 +0,0 @@ | |||||
| 1 | - | package executor | |||
| 2 | - | ||||
| 3 | - | import ( | |||
| 4 | - | "os" | |||
| 5 | - | "strings" | |||
| 6 | - | "testing" | |||
| 7 | - | ) | |||
| 8 | - | ||||
| 9 | - | func TestZZDump(t *testing.T) { | |||
| 10 | - | docker := realDocker(t) | |||
| 11 | - | y, _ := os.ReadFile(os.Getenv("DUMP_YAML")) | |||
| 12 | - | rec, _ := runLocal(t, string(y), os.Getenv("DUMP_JOB"), func(c *Config) { | |||
| 13 | - | c.Actions.DockerPath = docker | |||
| 14 | - | c.BaseEnv = append(c.BaseEnv, "XDG_RUNTIME_DIR="+os.Getenv("XDG_RUNTIME_DIR")) | |||
| 15 | - | c.Actions.ExternalsDir = fakeNode(t) | |||
| 16 | - | c.Runner.Environment = "github-hosted" | |||
| 17 | - | }) | |||
| 18 | - | var b strings.Builder | |||
| 19 | - | for _, s := range rec.steps { | |||
| 20 | - | b.WriteString("=== STEP " + s.Name + " " + string(s.Conclusion) + "\n" + logOf(s) + "\n") | |||
| 21 | - | } | |||
| 22 | - | os.WriteFile(os.Getenv("DUMP_OUT"), []byte(b.String()), 0o644) | |||
| 23 | - | } | |||