|
| 1 | +# Copyright (c) 2024 Bryan Frimin <bryan@frimin.fr>. |
| 2 | +# |
| 3 | +# Permission to use, copy, modify, and/or distribute this software for any |
| 4 | +# purpose with or without fee is hereby granted, provided that the above |
| 5 | +# copyright notice and this permission notice appear in all copies. |
| 6 | +# |
| 7 | +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH |
| 8 | +# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY |
| 9 | +# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, |
| 10 | +# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM |
| 11 | +# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR |
| 12 | +# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 13 | +# PERFORMANCE OF THIS SOFTWARE. |
| 14 | + |
| 15 | +GO ?= go |
| 16 | +GOIMPORTS ?= goimports |
| 17 | +GOLANGCI_LINT ?= golangci-lint |
| 18 | + |
| 19 | +PACKAGES := ./... |
| 20 | + |
| 21 | +.DEFAULT_GOAL := all |
| 22 | + |
| 23 | +.PHONY: all |
| 24 | +all: vet lint test |
| 25 | + |
| 26 | +.PHONY: build |
| 27 | +build: |
| 28 | + $(GO) build $(PACKAGES) |
| 29 | + |
| 30 | +.PHONY: vet |
| 31 | +vet: |
| 32 | + $(GO) vet $(PACKAGES) |
| 33 | + |
| 34 | +.PHONY: lint |
| 35 | +lint: lint-golangci lint-goimports |
| 36 | + |
| 37 | +.PHONY: lint-golangci |
| 38 | +lint-golangci: |
| 39 | + $(GOLANGCI_LINT) run $(PACKAGES) |
| 40 | + |
| 41 | +.PHONY: lint-goimports |
| 42 | +lint-goimports: |
| 43 | + @diff=$$($(GOIMPORTS) -d .); \ |
| 44 | + if [ -n "$$diff" ]; then \ |
| 45 | + printf '%s\n' "$$diff"; \ |
| 46 | + exit 1; \ |
| 47 | + fi |
| 48 | + |
| 49 | +.PHONY: test |
| 50 | +test: |
| 51 | + $(GO) test -count=1 $(PACKAGES) |
| 52 | + |
| 53 | +.PHONY: test-verbose |
| 54 | +test-verbose: |
| 55 | + $(GO) test -v -count=1 $(PACKAGES) |
| 56 | + |
| 57 | +.PHONY: clean |
| 58 | +clean: |
| 59 | + $(GO) clean $(PACKAGES) |
0 commit comments