Skip to content

Commit 054daab

Browse files
authored
Merge pull request moby#4070 from jedevc/enable-linter-for-nydus
2 parents 115e149 + f663123 commit 054daab

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

.golangci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ run:
55

66
modules-download-mode: vendor
77

8-
build-tags:
9-
- dfrunsecurity
10-
118
linters:
129
enable:
1310
- depguard

docker-bake.hcl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,22 @@ group "validate" {
7979
}
8080

8181
target "lint" {
82+
name = "lint-${buildtags.name}"
8283
inherits = ["_common"]
8384
dockerfile = "./hack/dockerfiles/lint.Dockerfile"
8485
output = ["type=cacheonly"]
86+
target = buildtags.target
87+
args = {
88+
BUILDTAGS = buildtags.tags
89+
}
90+
matrix = {
91+
buildtags = [
92+
{ name = "default", tags = "", target = "golangci-lint" },
93+
{ name = "labs", tags = "dfrunsecurity", target = "golangci-lint" },
94+
{ name = "nydus", tags = "nydus", target = "golangci-lint" },
95+
{ name = "yaml", tags = "", target = "yamllint" },
96+
]
97+
}
8598
}
8699

87100
target "validate-vendor" {

hack/dockerfiles/lint.Dockerfile

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,24 @@
22

33
ARG GO_VERSION=1.20
44

5-
FROM golang:${GO_VERSION}-alpine
5+
FROM golang:${GO_VERSION}-alpine AS base
66
ENV GOFLAGS="-buildvcs=false"
77
RUN apk add --no-cache gcc musl-dev yamllint
88
RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.52.2
99
WORKDIR /go/src/github.com/moby/buildkit
10+
11+
FROM base as golangci-lint
12+
ARG BUILDTAGS
13+
RUN --mount=target=/go/src/github.com/moby/buildkit --mount=target=/root/.cache,type=cache,sharing=locked \
14+
GOARCH=amd64 golangci-lint run --build-tags "${BUILDTAGS}" && \
15+
GOARCH=arm64 golangci-lint run --build-tags "${BUILDTAGS}" && \
16+
touch /golangci-lint.done
17+
18+
FROM base as yamllint
1019
RUN --mount=target=/go/src/github.com/moby/buildkit --mount=target=/root/.cache,type=cache \
11-
GOARCH=amd64 golangci-lint run && \
12-
GOARCH=arm64 golangci-lint run
13-
RUN --mount=target=/go/src/github.com/moby/buildkit --mount=target=/root/.cache,type=cache \
14-
yamllint -c .yamllint.yml --strict .
20+
yamllint -c .yamllint.yml --strict . && \
21+
touch /yamllint.done
22+
23+
FROM scratch
24+
COPY --link --from=golangci-lint /golangci-lint.done /
25+
COPY --link --from=yamllint /yamllint.done /

0 commit comments

Comments
 (0)