mirror of
				https://github.com/NVIDIA/nvidia-container-toolkit
				synced 2025-06-26 18:18:24 +00:00 
			
		
		
		
	Replace check targets with golangci-lint
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
		
							parent
							
								
									b02d5538b0
								
							
						
					
					
						commit
						3eca7dfd7b
					
				| @ -25,43 +25,15 @@ build-dev-image: | |||||||
| 
 | 
 | ||||||
| .requires-build-image: | .requires-build-image: | ||||||
|   image: "${BUILDIMAGE}" |   image: "${BUILDIMAGE}" | ||||||
|  |   needs: | ||||||
|  |     - job: build-dev-image | ||||||
| 
 | 
 | ||||||
| .go-check: | check: | ||||||
|   extends: |   extends: | ||||||
|     - .requires-build-image |     - .requires-build-image | ||||||
|   stage: go-checks |   stage: go-checks | ||||||
| 
 |  | ||||||
| fmt: |  | ||||||
|   extends: |  | ||||||
|     - .go-check |  | ||||||
|   script: |   script: | ||||||
|     - make assert-fmt |     - make check | ||||||
| 
 |  | ||||||
| vet: |  | ||||||
|   extends: |  | ||||||
|     - .go-check |  | ||||||
|   script: |  | ||||||
|     - make vet |  | ||||||
| 
 |  | ||||||
| lint: |  | ||||||
|   extends: |  | ||||||
|     - .go-check |  | ||||||
|   script: |  | ||||||
|     - make lint |  | ||||||
|   allow_failure: true |  | ||||||
| 
 |  | ||||||
| ineffassign: |  | ||||||
|   extends: |  | ||||||
|     - .go-check |  | ||||||
|   script: |  | ||||||
|     - make ineffassign |  | ||||||
|   allow_failure: true |  | ||||||
| 
 |  | ||||||
| misspell: |  | ||||||
|   extends: |  | ||||||
|     - .go-check |  | ||||||
|   script: |  | ||||||
|     - make misspell |  | ||||||
| 
 | 
 | ||||||
| go-build: | go-build: | ||||||
|   extends: |   extends: | ||||||
|  | |||||||
							
								
								
									
										30
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										30
									
								
								Makefile
									
									
									
									
									
								
							| @ -38,7 +38,7 @@ EXAMPLE_TARGETS := $(patsubst %,example-%, $(EXAMPLES)) | |||||||
| CMDS := $(patsubst ./cmd/%/,%,$(sort $(dir $(wildcard ./cmd/*/)))) | CMDS := $(patsubst ./cmd/%/,%,$(sort $(dir $(wildcard ./cmd/*/)))) | ||||||
| CMD_TARGETS := $(patsubst %,cmd-%, $(CMDS)) | CMD_TARGETS := $(patsubst %,cmd-%, $(CMDS)) | ||||||
| 
 | 
 | ||||||
| CHECK_TARGETS := assert-fmt vet lint ineffassign misspell | CHECK_TARGETS := golangci-lint | ||||||
| MAKE_TARGETS := binaries build check fmt lint-internal test examples cmds coverage generate licenses $(CHECK_TARGETS) | MAKE_TARGETS := binaries build check fmt lint-internal test examples cmds coverage generate licenses $(CHECK_TARGETS) | ||||||
| 
 | 
 | ||||||
| TARGETS := $(MAKE_TARGETS) $(EXAMPLE_TARGETS) $(CMD_TARGETS) | TARGETS := $(MAKE_TARGETS) $(EXAMPLE_TARGETS) $(CMD_TARGETS) | ||||||
| @ -78,30 +78,8 @@ fmt: | |||||||
| 	go list -f '{{.Dir}}' $(MODULE)/... \
 | 	go list -f '{{.Dir}}' $(MODULE)/... \
 | ||||||
| 		| xargs gofmt -s -l -w | 		| xargs gofmt -s -l -w | ||||||
| 
 | 
 | ||||||
| assert-fmt: | golangci-lint: | ||||||
| 	go list -f '{{.Dir}}' $(MODULE)/... \
 | 	golangci-lint run ./... | ||||||
| 		| xargs gofmt -s -l > fmt.out |  | ||||||
| 	@if [ -s fmt.out ]; then \
 |  | ||||||
| 		echo "\nERROR: The following files are not formatted:\n"; \
 |  | ||||||
| 		cat fmt.out; \
 |  | ||||||
| 		rm fmt.out; \
 |  | ||||||
| 		exit 1; \
 |  | ||||||
| 	else \
 |  | ||||||
| 		rm fmt.out; \
 |  | ||||||
| 	fi |  | ||||||
| 
 |  | ||||||
| ineffassign: |  | ||||||
| 	ineffassign $(MODULE)/... |  | ||||||
| 
 |  | ||||||
| lint: |  | ||||||
| # We use `go list -f '{{.Dir}}' $(MODULE)/...` to skip the `vendor` folder.
 |  | ||||||
| 	go list -f '{{.Dir}}' $(MODULE)/... | xargs golint -set_exit_status |  | ||||||
| 
 |  | ||||||
| misspell: |  | ||||||
| 	misspell $(MODULE)/... |  | ||||||
| 
 |  | ||||||
| vet: |  | ||||||
| 	go vet $(MODULE)/... |  | ||||||
| 
 | 
 | ||||||
| licenses: | licenses: | ||||||
| 	go-licenses csv $(MODULE)/... | 	go-licenses csv $(MODULE)/... | ||||||
| @ -141,6 +119,7 @@ $(DOCKER_TARGETS): docker-%: .build-image | |||||||
| 	$(DOCKER) run \
 | 	$(DOCKER) run \
 | ||||||
| 		--rm \
 | 		--rm \
 | ||||||
| 		-e GOCACHE=/tmp/.cache \
 | 		-e GOCACHE=/tmp/.cache \
 | ||||||
|  | 		-e GOLANGCI_LINT_CACHE=/tmp/.cache \
 | ||||||
| 		-v $(PWD):$(PWD) \
 | 		-v $(PWD):$(PWD) \
 | ||||||
| 		-w $(PWD) \
 | 		-w $(PWD) \
 | ||||||
| 		--user $$(id -u):$$(id -g) \
 | 		--user $$(id -u):$$(id -g) \
 | ||||||
| @ -154,6 +133,7 @@ PHONY: .shell | |||||||
| 		--rm \
 | 		--rm \
 | ||||||
| 		-ti \
 | 		-ti \
 | ||||||
| 		-e GOCACHE=/tmp/.cache \
 | 		-e GOCACHE=/tmp/.cache \
 | ||||||
|  | 		-e GOLANGCI_LINT_CACHE=/tmp/.cache \
 | ||||||
| 		-v $(PWD):$(PWD) \
 | 		-v $(PWD):$(PWD) \
 | ||||||
| 		-w $(PWD) \
 | 		-w $(PWD) \
 | ||||||
| 		--user $$(id -u):$$(id -g) \
 | 		--user $$(id -u):$$(id -g) \
 | ||||||
|  | |||||||
| @ -12,6 +12,7 @@ | |||||||
| # See the License for the specific language governing permissions and | # See the License for the specific language governing permissions and | ||||||
| # limitations under the License. | # limitations under the License. | ||||||
| ARG GOLANG_VERSION=x.x.x | ARG GOLANG_VERSION=x.x.x | ||||||
|  | ARG GOLANGCI_LINT_VERSION=v1.54.1 | ||||||
| FROM golang:${GOLANG_VERSION} | FROM golang:${GOLANG_VERSION} | ||||||
| 
 | 
 | ||||||
| RUN go install golang.org/x/lint/golint@6edffad5e6160f5949cdefc81710b2706fbcd4f6 | RUN go install golang.org/x/lint/golint@6edffad5e6160f5949cdefc81710b2706fbcd4f6 | ||||||
| @ -19,3 +20,4 @@ RUN go install github.com/matryer/moq@latest | |||||||
| RUN go install github.com/gordonklaus/ineffassign@d2c82e48359b033cde9cf1307f6d5550b8d61321 | RUN go install github.com/gordonklaus/ineffassign@d2c82e48359b033cde9cf1307f6d5550b8d61321 | ||||||
| RUN go install github.com/client9/misspell/cmd/misspell@latest | RUN go install github.com/client9/misspell/cmd/misspell@latest | ||||||
| RUN go install github.com/google/go-licenses@latest | RUN go install github.com/google/go-licenses@latest | ||||||
|  | RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VERSION} | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user