From cf25a54ab368cc056ceba203cb918d6cb8df8a11 Mon Sep 17 00:00:00 2001 From: CrazyMax <1951866+crazy-max@users.noreply.github.com> Date: Wed, 14 Oct 2026 12:02:04 +0200 Subject: [PATCH] ci: run unit tests on Linux and Windows Run make test across Ubuntu and Windows with the latest Go 1.26 and 1.27 patch releases. This includes filesystem driver tests, which the existing coverage target excludes, and catches Windows regressions before release. Keep coverage and the Docker-backed S3 and Azure tests in a Linux-only job, and require both test jobs before building artifacts. Make the file health checks portable by using temporary directories and closing the marker file before removing it. Check removal errors so a failed deletion is reported directly. Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> --- .github/workflows/build.yml | 43 ++++++++++++++++++++++++++++---- health/checks/checks_test.go | 5 ++-- registry/handlers/health_test.go | 10 +++++--- 3 files changed, 48 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bc923e03c..8242e95f4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,19 +22,50 @@ permissions: jobs: test: + runs-on: ${{ matrix.os }} env: - # Setting GOTOOLCHAIN to local tells go - # to to use the bundled Go version rather - # than fetching the toolchain according to - # toolchain directive found in go.mod. GOTOOLCHAIN: local + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + - windows-latest + go: + - 1.26.x + - 1.27.x + steps: + - + name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - + name: Set up Go + uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 + with: + go-version: ${{ matrix.go }} + cache: false + check-latest: true + - + name: Install Make + if: runner.os == 'Windows' + run: choco install make --no-progress -y + - + name: Test + shell: bash + run: make SHELL=bash test + + test-linux: runs-on: ubuntu-latest + env: + GOTOOLCHAIN: local strategy: fail-fast: false matrix: go: - 1.26.x - - 1.27.1 + - 1.27.x target: - test-coverage - test-s3-storage @@ -51,6 +82,7 @@ jobs: with: go-version: ${{ matrix.go }} cache: false + check-latest: true - name: Test run: | @@ -69,6 +101,7 @@ jobs: runs-on: ubuntu-latest needs: - test + - test-linux steps: - name: Checkout diff --git a/health/checks/checks_test.go b/health/checks/checks_test.go index 60332f180..e760fcc64 100644 --- a/health/checks/checks_test.go +++ b/health/checks/checks_test.go @@ -6,8 +6,9 @@ import ( ) func TestFileChecker(t *testing.T) { - if err := FileChecker("/tmp").Check(context.Background()); err == nil { - t.Errorf("/tmp was expected as exists") + dir := t.TempDir() + if err := FileChecker(dir).Check(context.Background()); err == nil { + t.Errorf("%s was expected as exists", dir) } if err := FileChecker("NoSuchFileFromMoon").Check(context.Background()); err != nil { diff --git a/registry/handlers/health_test.go b/registry/handlers/health_test.go index 52b197549..b0697b65c 100644 --- a/registry/handlers/health_test.go +++ b/registry/handlers/health_test.go @@ -17,11 +17,13 @@ import ( func TestFileHealthCheck(t *testing.T) { interval := time.Second - tmpfile, err := os.CreateTemp(os.TempDir(), "healthcheck") + tmpfile, err := os.CreateTemp(t.TempDir(), "healthcheck") if err != nil { t.Fatalf("could not create temporary file: %v", err) } - defer tmpfile.Close() + if err := tmpfile.Close(); err != nil { + t.Fatal(err) + } config := &configuration.Configuration{ Storage: configuration.Storage{ @@ -57,7 +59,9 @@ func TestFileHealthCheck(t *testing.T) { t.Fatal(`did not get "file exists" result for health check`) } - os.Remove(tmpfile.Name()) + if err := os.Remove(tmpfile.Name()); err != nil { + t.Fatal(err) + } <-time.After(2 * interval) if len(healthRegistry.CheckStatus(ctx)) != 0 {