diff --git a/Dockerfile b/Dockerfile index 46982f9..1735b04 100644 --- a/Dockerfile +++ b/Dockerfile @@ -47,3 +47,10 @@ RUN --mount=target=/context \ exit 1 fi EOT + +FROM base AS test +RUN apk add --no-cache make gcc musl-dev +WORKDIR /src +RUN --mount=target=. \ + --mount=target=/root/.cache,type=cache \ + CGO_ENABLED=1 make unit-tests diff --git a/Makefile b/Makefile index c1d4662..19a39a4 100644 --- a/Makefile +++ b/Makefile @@ -60,7 +60,7 @@ mock: unit-tests: @echo "Running unit tests..." - @go test -v ./... + @go test -race -v ./... @echo "Unit tests completed!" clean: diff --git a/docker-bake.hcl b/docker-bake.hcl index b0781b6..6b04422 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -17,7 +17,10 @@ group "default" { } group "validate" { - targets = ["validate-docs"] + targets = [ + "validate-docs", + "validate-tests" + ] } target "validate-docs" { @@ -37,3 +40,9 @@ target "update-docs" { target = "docs-update" output = ["./docs/reference"] } + +target "validate-tests" { + inherits = ["_common"] + target = "test" + output = ["type=cacheonly"] +}