mirror of
https://github.com/distribution/distribution.git
synced 2026-10-28 10:15:27 +08:00
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>
This commit is contained in:
3 files changed
+48
-10
No files matched your search
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user