Skip to content

Commit c5e686d

Browse files
aledbfclaude
andcommitted
fix(release): ignore BuildKit configs written into the checkout
The release job's useblacksmith/setup-docker-builder step writes its BuildKit daemon config with a relative path, so buildkitd.toml lands in the repository checkout. GoReleaser validates a clean tree before releasing and failed with "git is in a dirty state" on the untracked file, aborting the release. Ignore buildkitd.toml and the fallback builder's docker-container-buildkitd.toml at the repo root. Ignored files do not count as dirty, and the daemon keeps the config it was started with. TestReleaseBuilderConfigsAreGitIgnored checks both paths with `git check-ignore --no-index`, without touching the working tree. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent fdb9e71 commit c5e686d

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

‎.gitignore‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,9 @@ coverage.xml
77
*.test
88
.claude/
99
.task/
10+
11+
# BuildKit daemon configs that useblacksmith/setup-docker-builder writes into the
12+
# job's working directory (the repo checkout) in the release workflow. Left
13+
# untracked they make the tree dirty and GoReleaser refuses to release.
14+
/buildkitd.toml
15+
/docker-container-buildkitd.toml
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package cli
2+
3+
import (
4+
"errors"
5+
"os/exec"
6+
"path/filepath"
7+
"testing"
8+
)
9+
10+
// TestReleaseBuilderConfigsAreGitIgnored guards the release job against a dirty
11+
// tree. useblacksmith/setup-docker-builder writes its BuildKit daemon config with
12+
// a relative path, so it lands in the job's working directory — the repository
13+
// checkout. GoReleaser validates that the tree is clean before releasing, and an
14+
// untracked buildkitd.toml made `goreleaser release` fail with "git is in a dirty
15+
// state". Ignored files do not count as dirty, so the configs must stay ignored.
16+
//
17+
// `git check-ignore --no-index` evaluates the ignore rules for a path without the
18+
// file existing, so the test never touches the working tree.
19+
func TestReleaseBuilderConfigsAreGitIgnored(t *testing.T) {
20+
gitPath, err := exec.LookPath("git")
21+
if err != nil {
22+
t.Skip("git not available")
23+
}
24+
repoRoot, err := filepath.Abs(filepath.Join("..", ".."))
25+
if err != nil {
26+
t.Fatalf("resolve repo root: %v", err)
27+
}
28+
29+
for _, name := range []string{
30+
"buildkitd.toml", // setup_builder.ts: writeTomlConfig("buildkitd.toml", ...)
31+
"docker-container-buildkitd.toml", // setup_builder.ts: the docker-container fallback builder
32+
} {
33+
cmd := exec.Command(gitPath, "check-ignore", "--quiet", "--no-index", name)
34+
cmd.Dir = repoRoot
35+
err := cmd.Run()
36+
var exitErr *exec.ExitError
37+
switch {
38+
case err == nil:
39+
// Exit 0: the path is ignored.
40+
case errors.As(err, &exitErr) && exitErr.ExitCode() == 1:
41+
t.Errorf("%s is not git-ignored: the release job's builder writes it into the checkout and GoReleaser then fails on a dirty tree", name)
42+
default:
43+
t.Fatalf("git check-ignore %s: %v", name, err)
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)