Skip to content

Commit

Permalink
Merge pull request docker#2594 from tonistiigi/golangci-validate
Browse files Browse the repository at this point in the history
fix issues in .golangci.yml and add validation check
  • Loading branch information
crazy-max authored Jul 15, 2024
2 parents d64d3a4 + 0d37d68 commit 3005743
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
12 changes: 5 additions & 7 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
run:
timeout: 30m
skip-files:
- ".*\\.pb\\.go$"

modules-download-mode: vendor

build-tags:

linters:
enable:
- gofmt
Expand Down Expand Up @@ -57,6 +53,8 @@ linters-settings:
G306: "0644"

issues:
exclude-files:
- ".*\\.pb\\.go$"
exclude-rules:
- linters:
- revive
Expand All @@ -77,6 +75,6 @@ issues:
- revive
text: "if-return"

# show all
max-issues-per-linter: 0
max-same-issues: 0
# show all
max-issues-per-linter: 0
max-same-issues: 0
10 changes: 9 additions & 1 deletion docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ group "default" {
}

group "validate" {
targets = ["lint", "lint-gopls", "validate-vendor", "validate-docs"]
targets = ["lint", "lint-gopls", "validate-golangci", "validate-vendor", "validate-docs"]
}

target "lint" {
Expand All @@ -51,6 +51,14 @@ target "lint" {
] : []
}

target "validate-golangci" {
description = "Validate .golangci.yml schema (does not run Go linter)"
inherits = ["_common"]
dockerfile = "./hack/dockerfiles/lint.Dockerfile"
target = "validate-golangci"
output = ["type=cacheonly"]
}

target "lint-gopls" {
inherits = ["lint"]
target = "gopls-analyze"
Expand Down
8 changes: 7 additions & 1 deletion hack/dockerfiles/lint.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,24 @@ FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine AS golang-base
RUN apk add --no-cache git gcc musl-dev

FROM golang-base AS lint
FROM golang-base AS lint-base
ENV GOFLAGS="-buildvcs=false"
ARG GOLANGCI_LINT_VERSION
RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v${GOLANGCI_LINT_VERSION}
COPY --link --from=xx / /
WORKDIR /go/src/github.com/docker/buildx
ARG TARGETPLATFORM

FROM lint-base AS lint
RUN --mount=target=/go/src/github.com/docker/buildx \
--mount=target=/root/.cache,type=cache,id=lint-cache-$TARGETPLATFORM \
xx-go --wrap && \
golangci-lint run

FROM lint-base AS validate-golangci
RUN --mount=target=/go/src/github.com/docker/buildx \
golangci-lint config verify

FROM golang-base AS gopls
RUN apk add --no-cache git
ARG GOPLS_VERSION
Expand Down

0 comments on commit 3005743

Please sign in to comment.