File tree Expand file tree Collapse file tree 6 files changed +147
-40
lines changed
Expand file tree Collapse file tree 6 files changed +147
-40
lines changed Original file line number Diff line number Diff line change 1+ version : " 2"
2+
3+ run :
4+ timeout : 10m
5+
6+ formatters :
7+ enable :
8+ - gofmt
9+ - goimports
10+
11+ linters :
12+ default : standard
13+ enable :
14+ - bodyclose
15+ - errname
16+ - forbidigo
17+ - gocritic
18+ - gosec
19+ - importas
20+ - makezero
21+ - misspell
22+ - noctx
23+ - nolintlint
24+ - revive
25+ - unconvert
26+ - unparam
27+ - whitespace
Original file line number Diff line number Diff line change 1+ # syntax=docker/dockerfile:1
2+ # check=error=true
3+
4+ ARG GO_VERSION=1.26
5+ ARG XX_VERSION=1.9.0
6+
7+ ARG COVER_FILENAME="cover.out"
8+
9+ FROM --platform=${BUILDPLATFORM} tonistiigi/xx:${XX_VERSION} AS xx
10+
11+ FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION}-alpine AS golang
12+ COPY --link --from=xx / /
13+ WORKDIR /src
14+ ARG TARGETPLATFORM
15+
16+ FROM golang AS build
17+ RUN --mount=target=/root/.cache,type=cache \
18+ --mount=type=bind xx-go build ./...
19+
20+ FROM golang AS runtest
21+ ARG TESTFLAGS="-v"
22+ ARG COVER_FILENAME
23+ RUN --mount=target=/root/.cache,type=cache \
24+ --mount=type=bind \
25+ xx-go test -coverprofile=/tmp/${COVER_FILENAME} $TESTFLAGS ./...
26+
27+ FROM scratch AS test
28+ ARG COVER_FILENAME
29+ COPY --from=runtest /tmp/${COVER_FILENAME} /
30+
31+ FROM build
Original file line number Diff line number Diff line change 11PKGS := github.com/pkg/errors
2- SRCDIRS := $(shell go list -f '{{.Dir}}' $(PKGS ) )
32GO := go
43
5- check : test vet gofmt misspell unconvert staticcheck ineffassign unparam
6-
7- test :
4+ test :
85 $(GO ) test $(PKGS )
9-
10- vet : | test
11- $(GO ) vet $(PKGS )
12-
13- staticcheck :
14- $(GO ) get honnef.co/go/tools/cmd/staticcheck
15- staticcheck -checks all $(PKGS )
16-
17- misspell :
18- $(GO ) get github.com/client9/misspell/cmd/misspell
19- misspell \
20- -locale GB \
21- -error \
22- * .md * .go
23-
24- unconvert :
25- $(GO ) get github.com/mdempsky/unconvert
26- unconvert -v $(PKGS )
27-
28- ineffassign :
29- $(GO ) get github.com/gordonklaus/ineffassign
30- find $(SRCDIRS ) -name ' *.go' | xargs ineffassign
31-
32- pedantic : check errcheck
33-
34- unparam :
35- $(GO ) get mvdan.cc/unparam
36- unparam ./...
37-
38- errcheck :
39- $(GO ) get github.com/kisielk/errcheck
40- errcheck $(PKGS )
41-
42- gofmt :
43- @echo Checking code is gofmted
44- @test -z " $( shell gofmt -s -l -d -e $( SRCDIRS) | tee /dev/stderr) "
Original file line number Diff line number Diff line change 1+ variable "COVER_FILENAME" {
2+ default = null
3+ }
4+
5+ variable "GO_VERSION" {
6+ default = null
7+ }
8+
9+ target "default" {
10+ targets = [" build" ]
11+ }
12+
13+ target "_all_platforms" {
14+ platforms = [
15+ " linux/amd64" ,
16+ " linux/arm64" ,
17+ " linux/arm/v7" ,
18+ " linux/arm/v6" ,
19+ " linux/386" ,
20+ " linux/ppc64le" ,
21+ " linux/s390x" ,
22+ " linux/riscv64" ,
23+ " darwin/amd64" ,
24+ " darwin/arm64" ,
25+ " windows/amd64" ,
26+ " windows/arm64" ,
27+ ]
28+ }
29+
30+ target "build" {
31+ output = [" type=cacheonly" ]
32+ args = {
33+ GO_VERSION = GO_VERSION
34+ }
35+ }
36+
37+ target "build-all" {
38+ inherits = [" build" , " _all_platforms" ]
39+ }
40+
41+ target "test" {
42+ target = " test"
43+ args = {
44+ COVER_FILENAME = COVER_FILENAME
45+ GO_VERSION = GO_VERSION
46+ }
47+ output = [COVER_FILENAME != null ? " ." : " type=cacheonly" ]
48+ }
49+
50+ target "lint" {
51+ dockerfile = " hack/dockerfiles/lint.Dockerfile"
52+ output = [" type=cacheonly" ]
53+ }
54+
55+ target "lint-all" {
56+ inherits = [" lint" , " _all_platforms" ]
57+ }
Original file line number Diff line number Diff line change 1+ module github.com/pkg/errors
2+
3+ go 1.20
Original file line number Diff line number Diff line change 1+ # syntax=docker/dockerfile:1
2+ # check=error=true
3+
4+ ARG GO_VERSION=1.26
5+ ARG ALPINE_VERSION=3.23
6+ ARG XX_VERSION=1.9.0
7+ ARG GOLANGCI_LINT_VERSION=2.11.2
8+
9+ FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS golang-base
10+ FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
11+
12+ FROM golang-base AS base
13+ ENV GOFLAGS="-buildvcs=false"
14+ ARG GOLANGCI_LINT_VERSION
15+ RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v${GOLANGCI_LINT_VERSION}
16+ COPY --link --from=xx / /
17+ WORKDIR /go/src/github.com/pkg/errors
18+
19+ FROM base AS golangci-lint
20+ ARG TARGETPLATFORM
21+ RUN --mount=type=bind \
22+ --mount=target=/root/.cache,type=cache \
23+ xx-go --wrap && \
24+ golangci-lint run && \
25+ touch /golangci-lint.done
26+
27+ FROM scratch
28+ COPY --link --from=golangci-lint /golangci-lint.done /
You can’t perform that action at this time.
0 commit comments