mirror of
https://github.com/docker/docker-credential-helpers.git
synced 2026-06-13 16:01:28 +05:30
Dockerfile: add test stage
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
+12
@@ -30,6 +30,18 @@ FROM gobase AS base
|
|||||||
ARG TARGETPLATFORM
|
ARG TARGETPLATFORM
|
||||||
RUN xx-apk add musl-dev gcc libsecret-dev pass
|
RUN xx-apk add musl-dev gcc libsecret-dev pass
|
||||||
|
|
||||||
|
FROM base AS test
|
||||||
|
RUN --mount=type=bind,target=. \
|
||||||
|
--mount=type=cache,target=/root/.cache \
|
||||||
|
--mount=type=cache,target=/go/pkg/mod <<EOT
|
||||||
|
set -e
|
||||||
|
xx-go test -short -v -coverprofile=/tmp/coverage.txt -covermode=atomic ./...
|
||||||
|
xx-go tool cover -func=/tmp/coverage.txt
|
||||||
|
EOT
|
||||||
|
|
||||||
|
FROM scratch AS test-coverage
|
||||||
|
COPY --from=test /tmp/coverage.txt /coverage.txt
|
||||||
|
|
||||||
FROM base AS build-linux
|
FROM base AS build-linux
|
||||||
ARG TARGETOS
|
ARG TARGETOS
|
||||||
ARG TARGETARCH
|
ARG TARGETARCH
|
||||||
|
|||||||
+14
-2
@@ -1,8 +1,14 @@
|
|||||||
variable "GO_VERSION" {
|
variable "GO_VERSION" {
|
||||||
default = "1.16.7"
|
default = "1.16.7"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Defines the output folder
|
||||||
variable "DESTDIR" {
|
variable "DESTDIR" {
|
||||||
default = "./bin"
|
default = ""
|
||||||
|
}
|
||||||
|
function "bindir" {
|
||||||
|
params = [defaultdir]
|
||||||
|
result = DESTDIR != "" ? DESTDIR : "./bin/${defaultdir}"
|
||||||
}
|
}
|
||||||
|
|
||||||
target "_common" {
|
target "_common" {
|
||||||
@@ -15,10 +21,16 @@ group "default" {
|
|||||||
targets = ["binaries"]
|
targets = ["binaries"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
target "test" {
|
||||||
|
inherits = ["_common"]
|
||||||
|
target = "test-coverage"
|
||||||
|
output = [bindir("coverage")]
|
||||||
|
}
|
||||||
|
|
||||||
target "binaries" {
|
target "binaries" {
|
||||||
inherits = ["_common"]
|
inherits = ["_common"]
|
||||||
target = "binaries"
|
target = "binaries"
|
||||||
output = [DESTDIR]
|
output = [bindir("build")]
|
||||||
platforms = [
|
platforms = [
|
||||||
"darwin/amd64",
|
"darwin/amd64",
|
||||||
"darwin/arm64",
|
"darwin/arm64",
|
||||||
|
|||||||
Reference in New Issue
Block a user