Skip to content

Commit

Permalink
Merge pull request #4070 from jedevc/enable-linter-for-nydus
Browse files Browse the repository at this point in the history
  • Loading branch information
jedevc authored Jul 27, 2023
2 parents 115e149 + f663123 commit 054daab
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
3 changes: 0 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ run:

modules-download-mode: vendor

build-tags:
- dfrunsecurity

linters:
enable:
- depguard
Expand Down
13 changes: 13 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,22 @@ group "validate" {
}

target "lint" {
name = "lint-${buildtags.name}"
inherits = ["_common"]
dockerfile = "./hack/dockerfiles/lint.Dockerfile"
output = ["type=cacheonly"]
target = buildtags.target
args = {
BUILDTAGS = buildtags.tags
}
matrix = {
buildtags = [
{ name = "default", tags = "", target = "golangci-lint" },
{ name = "labs", tags = "dfrunsecurity", target = "golangci-lint" },
{ name = "nydus", tags = "nydus", target = "golangci-lint" },
{ name = "yaml", tags = "", target = "yamllint" },
]
}
}

target "validate-vendor" {
Expand Down
21 changes: 16 additions & 5 deletions hack/dockerfiles/lint.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,24 @@

ARG GO_VERSION=1.20

FROM golang:${GO_VERSION}-alpine
FROM golang:${GO_VERSION}-alpine AS base
ENV GOFLAGS="-buildvcs=false"
RUN apk add --no-cache gcc musl-dev yamllint
RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.52.2
WORKDIR /go/src/github.com/moby/buildkit

FROM base as golangci-lint
ARG BUILDTAGS
RUN --mount=target=/go/src/github.com/moby/buildkit --mount=target=/root/.cache,type=cache,sharing=locked \
GOARCH=amd64 golangci-lint run --build-tags "${BUILDTAGS}" && \
GOARCH=arm64 golangci-lint run --build-tags "${BUILDTAGS}" && \
touch /golangci-lint.done

FROM base as yamllint
RUN --mount=target=/go/src/github.com/moby/buildkit --mount=target=/root/.cache,type=cache \
GOARCH=amd64 golangci-lint run && \
GOARCH=arm64 golangci-lint run
RUN --mount=target=/go/src/github.com/moby/buildkit --mount=target=/root/.cache,type=cache \
yamllint -c .yamllint.yml --strict .
yamllint -c .yamllint.yml --strict . && \
touch /yamllint.done

FROM scratch
COPY --link --from=golangci-lint /golangci-lint.done /
COPY --link --from=yamllint /yamllint.done /

0 comments on commit 054daab

Please sign in to comment.