Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions BUILD.bit
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Enable verbose mode
param verbose : bool = false

# Build client and server binaries
cachew = go.exe {
package = "./cmd/cachew"
output = "dist/cachew"
}

cachewd = go.exe {
package = "./cmd/cachewd"
output = "dist/cachewd"
}

# Cross-compile Linux binaries for Docker
cachew-linux = go.exe {
package = "./cmd/cachew"
output = "dist/cachew-linux-arm64"
cgo = false
goos = "linux"
goarch = "amd64"
}

cachewd-linux = go.exe {
package = "./cmd/cachewd"
output = "dist/cachewd-linux-arm64"
cgo = false
goos = "linux"
goarch = "arm64"
}

# Tests
test = go.test {
package = "./..."
flags = ["-timeout", "30s", "-race"]
verbose = verbose
}

# Lint
lint = go.lint {}

# Docker image
image = docker.image {
tag = "cachew:latest"
context = "."
dockerfile = "docker/Dockerfile"
depends_on = [cachew-linux, cachewd-linux]
}

container = docker.container {
image = image.ref
name = "cachew"
ports = ["8080:8080"]
healthcheck = "curl -sf http://localhost:8080/_readiness"
}

# Build binaries
target build = [cachew, cachewd]

# Run tests and linting
target test = [test, lint]

# Build and run Docker container
target docker = [container]
14 changes: 10 additions & 4 deletions internal/s3client/s3clienttest/s3clienttest.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,16 @@ func startContainer(t *testing.T) {
"-e", "MINIO_ROOT_PASSWORD="+Password,
"minio/minio", "server", "/data",
)
if output, err := cmd.CombinedOutput(); err != nil {
if !strings.Contains(string(output), "already in use") {
t.Fatalf("failed to start minio container: %v\n%s", err, output)
}
output, err := cmd.CombinedOutput()
if err == nil {
return
}
if !strings.Contains(string(output), "already in use") {
t.Fatalf("failed to start minio container: %v\n%s", err, output)
}
// Container exists but may be stopped — try restarting it.
if restartOut, restartErr := exec.CommandContext(t.Context(), "docker", "start", containerName).CombinedOutput(); restartErr != nil {
t.Fatalf("failed to restart existing minio container: %v\n%s", restartErr, restartOut)
}
}

Expand Down