From 27bb10e137c706508b81968af2f806ea9ebbc043 Mon Sep 17 00:00:00 2001 From: Alec Thomas Date: Tue, 14 Apr 2026 15:38:54 +1000 Subject: [PATCH] fix: flaky S3 test --- BUILD.bit | 57 ++++++++++++++++++++++----------------- bin/.bit-0.4.0.pkg | 1 + bin/bit | 1 + internal/cache/s3_test.go | 2 +- 4 files changed, 35 insertions(+), 26 deletions(-) create mode 120000 bin/.bit-0.4.0.pkg create mode 120000 bin/bit diff --git a/BUILD.bit b/BUILD.bit index 9b885346..c0b990f7 100644 --- a/BUILD.bit +++ b/BUILD.bit @@ -1,5 +1,12 @@ # Enable verbose mode -param verbose : bool = false +param verbose = false +param version = exec('git describe --tags --always --dirty 2>/dev/null || echo "dev"') +# Docker Registry to push production image to. +param registry : string #= "127.0.0.1:5000" +let git_commit = exec('git rev-parse HEAD') +let arch = ["amd64", "arm64"] +let command = ["cachew", "cachewd"] + # Build client and server binaries cachew = go.exe { @@ -12,23 +19,6 @@ cachewd = go.exe { 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 = "./..." @@ -39,12 +29,29 @@ test = go.test { # Lint lint = go.lint {} +cross-compile[arch, command] = go.exe { + package = "./cmd/${command}" + output = "dist/${command}-linux-${arch}" + cgo = false + goos = "linux" + goarch = arch +} + # Docker image image = docker.image { tag = "cachew:latest" context = "." dockerfile = "docker/Dockerfile" - depends_on = [cachew-linux, cachewd-linux] + depends_on = [cross-compile] +} + +# Build production image. +multi-arch-image = docker.image { + tag = "${registry}/cachew:latest" + context = "." + dockerfile = "docker/Dockerfile" + depends_on = [cross-compile] + platform = arch | prefix("linux/") } container = docker.container { @@ -54,11 +61,11 @@ container = docker.container { 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] + +# Build and push production image +target push = [multi-arch-image] + +# Build default targets +target default = [cachew, cachewd, test, lint] diff --git a/bin/.bit-0.4.0.pkg b/bin/.bit-0.4.0.pkg new file mode 120000 index 00000000..383f4511 --- /dev/null +++ b/bin/.bit-0.4.0.pkg @@ -0,0 +1 @@ +hermit \ No newline at end of file diff --git a/bin/bit b/bin/bit new file mode 120000 index 00000000..0da382e4 --- /dev/null +++ b/bin/bit @@ -0,0 +1 @@ +.bit-0.4.0.pkg \ No newline at end of file diff --git a/internal/cache/s3_test.go b/internal/cache/s3_test.go index e49e70ed..ede16eb2 100644 --- a/internal/cache/s3_test.go +++ b/internal/cache/s3_test.go @@ -32,7 +32,7 @@ func TestS3Cache(t *testing.T) { c, err := cache.NewS3(ctx, cache.S3Config{ Bucket: bucket, - MaxTTL: 100 * time.Millisecond, + MaxTTL: 500 * time.Millisecond, UploadPartSizeMB: 16, }, clientProvider) assert.NoError(t, err)