forked from docker/cli-docs-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
- Loading branch information
Showing
9 changed files
with
108 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/coverage.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/coverage.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
variable "GO_VERSION" { | ||
default = "1.16" | ||
} | ||
|
||
group "default" { | ||
targets = ["test"] | ||
} | ||
|
||
group "validate" { | ||
targets = ["lint", "vendor-validate"] | ||
} | ||
|
||
target "lint" { | ||
args = { | ||
GO_VERSION = GO_VERSION | ||
} | ||
dockerfile = "./hack/lint.Dockerfile" | ||
target = "lint" | ||
output = ["type=cacheonly"] | ||
} | ||
|
||
target "vendor-validate" { | ||
args = { | ||
GO_VERSION = GO_VERSION | ||
} | ||
dockerfile = "./hack/vendor.Dockerfile" | ||
target = "validate" | ||
output = ["type=cacheonly"] | ||
} | ||
|
||
target "vendor-update" { | ||
args = { | ||
GO_VERSION = GO_VERSION | ||
} | ||
dockerfile = "./hack/vendor.Dockerfile" | ||
target = "update" | ||
output = ["."] | ||
} | ||
|
||
target "test" { | ||
args = { | ||
GO_VERSION = GO_VERSION | ||
} | ||
dockerfile = "./hack/test.Dockerfile" | ||
target = "test-coverage" | ||
output = ["."] | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# syntax=docker/dockerfile:1.3 | ||
ARG GO_VERSION | ||
|
||
FROM golang:${GO_VERSION}-alpine AS base | ||
RUN apk add --no-cache linux-headers | ||
WORKDIR /src | ||
|
||
FROM golangci/golangci-lint:v1.37-alpine AS golangci-lint | ||
|
||
FROM base AS lint | ||
RUN --mount=type=bind,target=. \ | ||
--mount=type=cache,target=/root/.cache/go-build \ | ||
--mount=type=cache,target=/root/.cache/golangci-lint \ | ||
--mount=from=golangci-lint,source=/usr/bin/golangci-lint,target=/usr/bin/golangci-lint \ | ||
golangci-lint run --timeout 10m0s ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# syntax=docker/dockerfile:1.2 | ||
ARG GO_VERSION | ||
|
||
FROM golang:${GO_VERSION}-alpine AS base | ||
RUN apk add --no-cache gcc linux-headers musl-dev | ||
WORKDIR /src | ||
|
||
FROM base AS gomod | ||
RUN --mount=type=bind,target=.,rw \ | ||
--mount=type=cache,target=/go/pkg/mod \ | ||
go mod tidy && go mod download | ||
|
||
FROM gomod AS test | ||
RUN --mount=type=bind,target=. \ | ||
--mount=type=cache,target=/go/pkg/mod \ | ||
--mount=type=cache,target=/root/.cache/go-build \ | ||
go test -v -coverprofile=/tmp/coverage.txt -covermode=atomic -race ./... | ||
|
||
FROM scratch AS test-coverage | ||
COPY --from=test /tmp/coverage.txt /coverage.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# syntax=docker/dockerfile:1.3 | ||
ARG GO_VERSION | ||
|
||
FROM golang:${GO_VERSION}-alpine AS base | ||
RUN apk add --no-cache git | ||
WORKDIR /src | ||
|
||
FROM base AS vendored | ||
RUN --mount=type=bind,target=.,rw \ | ||
--mount=type=cache,target=/go/pkg/mod \ | ||
go mod tidy && go mod download && \ | ||
mkdir /out && cp go.mod go.sum /out | ||
|
||
FROM scratch AS update | ||
COPY --from=vendored /out / | ||
|
||
FROM vendored AS validate | ||
RUN --mount=type=bind,target=.,rw \ | ||
git add -A && cp -rf /out/* .; \ | ||
if [ -n "$(git status --porcelain -- go.mod go.sum)" ]; then \ | ||
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor-update"'; \ | ||
git status --porcelain -- go.mod go.sum; \ | ||
exit 1; \ | ||
fi |