Skip to content

Commit

Permalink
Merge pull request distribution#3640 from crazy-max/lint
Browse files Browse the repository at this point in the history
lint target and workflow job
  • Loading branch information
milosgajdos authored May 4, 2022
2 parents 7846381 + 7548c31 commit 7a6b9e3
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 25 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ jobs:
working-directory: ./src/github.com/distribution/distribution
run: |
DCO_VERBOSITY=-q script/validate/dco
GO111MODULE=on script/setup/install-dev-tools
go build -i .
make check
make build
make binaries
if [ "$GOOS" = "linux" ]; then make coverage ; fi
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
fail-fast: false
matrix:
target:
- lint
- validate-vendor
steps:
-
Expand Down
16 changes: 9 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ BINARIES=$(addprefix bin/,$(COMMANDS))
TESTFLAGS ?= -v $(TESTFLAGS_RACE)
TESTFLAGS_PARALLEL ?= 8

.PHONY: all build binaries check clean test test-race test-full integration coverage validate-vendor vendor mod-outdated
.PHONY: all build binaries clean test test-race test-full integration coverage validate lint validate-vendor vendor mod-outdated
.DEFAULT: all

all: binaries
Expand All @@ -48,10 +48,6 @@ version/version.go:
@echo "$(WHALE) $@"
./version/version.sh > $@

check: ## run all linters (TODO: enable "unused", "varcheck", "ineffassign", "unconvert", "staticheck", "goimports", "structcheck")
@echo "$(WHALE) $@"
@golangci-lint run

test: ## run tests, except integration test with test.short
@echo "$(WHALE) $@"
@go test ${GO_TAGS} -test.short ${TESTFLAGS} $(filter-out ${INTEGRATION_PACKAGE},${PACKAGES})
Expand Down Expand Up @@ -101,8 +97,14 @@ clean: ## clean up binaries
@echo "$(WHALE) $@"
@rm -f $(BINARIES)

validate: ## run all validators
docker buildx bake $@

lint: ## run all linters
docker buildx bake $@

validate-vendor: ## validate vendor
docker buildx bake validate-vendor
docker buildx bake $@

vendor: ## update vendor
$(eval $@_TMP_OUT := $(shell mktemp -d -t buildx-output.XXXXXXXXXX))
Expand All @@ -112,4 +114,4 @@ vendor: ## update vendor
rm -rf $($@_TMP_OUT)/*

mod-outdated: ## check outdated dependencies
docker buildx bake mod-outdated
docker buildx bake $@
7 changes: 6 additions & 1 deletion docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ group "default" {
}

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

target "lint" {
dockerfile = "./dockerfiles/lint.Dockerfile"
output = ["type=cacheonly"]
}

target "validate-vendor" {
Expand Down
16 changes: 16 additions & 0 deletions dockerfiles/lint.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# syntax=docker/dockerfile:1

ARG GO_VERSION=1.17
ARG GOLANGCI_LINT_VERSION=v1.44

FROM golangci/golangci-lint:${GOLANGCI_LINT_VERSION}-alpine AS golangci-lint

FROM golang:${GO_VERSION}-alpine AS base
RUN apk add --no-cache gcc musl-dev
WORKDIR /src

FROM base
RUN --mount=type=bind,target=. \
--mount=type=cache,target=/root/.cache \
--mount=from=golangci-lint,source=/usr/bin/golangci-lint,target=/usr/bin/golangci-lint \
golangci-lint run
15 changes: 0 additions & 15 deletions script/setup/install-dev-tools

This file was deleted.

0 comments on commit 7a6b9e3

Please sign in to comment.