Makefile 972 B

12345678910111213141516171819202122232425262728293031323334
  1. GO_LINT=$(shell which golangci-lint 2> /dev/null || echo '')
  2. GO_LINT_URI=github.com/golangci/golangci-lint/cmd/golangci-lint@latest
  3. GO_SEC=$(shell which gosec 2> /dev/null || echo '')
  4. GO_SEC_URI=github.com/securego/gosec/v2/cmd/gosec@latest
  5. GO_VULNCHECK=$(shell which govulncheck 2> /dev/null || echo '')
  6. GO_VULNCHECK_URI=golang.org/x/vuln/cmd/govulncheck@latest
  7. .PHONY: golangci-lint
  8. golangci-lint:
  9. $(if $(GO_LINT), ,go install $(GO_LINT_URI))
  10. @echo "##### Running golangci-lint"
  11. golangci-lint run -v
  12. .PHONY: gosec
  13. gosec:
  14. $(if $(GO_SEC), ,go install $(GO_SEC_URI))
  15. @echo "##### Running gosec"
  16. gosec -exclude-dir examples ./...
  17. .PHONY: govulncheck
  18. govulncheck:
  19. $(if $(GO_VULNCHECK), ,go install $(GO_VULNCHECK_URI))
  20. @echo "##### Running govulncheck"
  21. govulncheck ./...
  22. .PHONY: verify
  23. verify: golangci-lint gosec govulncheck
  24. .PHONY: test
  25. test:
  26. @echo "##### Running tests"
  27. go test -race -cover -coverprofile=coverage.coverprofile -covermode=atomic -v ./...