1
0
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:
CrazyMax
2022-08-20 18:55:43 +02:00
parent 0e5dbc62ad
commit e7e9118856
2 changed files with 26 additions and 2 deletions
+12
View File
@@ -30,6 +30,18 @@ FROM gobase AS base
ARG TARGETPLATFORM
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
ARG TARGETOS
ARG TARGETARCH
+14 -2
View File
@@ -1,8 +1,14 @@
variable "GO_VERSION" {
default = "1.16.7"
}
# Defines the output folder
variable "DESTDIR" {
default = "./bin"
default = ""
}
function "bindir" {
params = [defaultdir]
result = DESTDIR != "" ? DESTDIR : "./bin/${defaultdir}"
}
target "_common" {
@@ -15,10 +21,16 @@ group "default" {
targets = ["binaries"]
}
target "test" {
inherits = ["_common"]
target = "test-coverage"
output = [bindir("coverage")]
}
target "binaries" {
inherits = ["_common"]
target = "binaries"
output = [DESTDIR]
output = [bindir("build")]
platforms = [
"darwin/amd64",
"darwin/arm64",