|
1 |
| -GO_CMD=go |
2 |
| -GO_BUILD=$(GO_CMD) build |
3 |
| -GO_BUILD_RACE=$(GO_CMD) build -race |
4 |
| -GO_TEST=$(GO_CMD) test |
5 |
| -GO_TEST_VERBOSE=$(GO_CMD) test -v |
6 |
| -GO_INSTALL=$(GO_CMD) install -v |
7 |
| -GO_CLEAN=$(GO_CMD) clean |
8 |
| -GO_DEPS=$(GO_CMD) get -d -v |
9 |
| -GO_DEPS_UPDATE=$(GO_CMD) get -d -v -u |
10 |
| -GO_VET=$(GO_CMD) vet |
11 |
| -GO_FMT=$(GO_CMD) fmt |
12 |
| - |
13 |
| -.PHONY: all test lint dep |
14 |
| - |
15 |
| -all: dep test lint |
| 1 | +.DEFAULT_GOAL:=help |
| 2 | +-include .makerc |
16 | 3 |
|
| 4 | +# --- Targets ----------------------------------------------------------------- |
| 5 | + |
| 6 | +# This allows us to accept extra arguments |
| 7 | +%: |
| 8 | + @: |
| 9 | + |
| 10 | +## === Tasks === |
| 11 | + |
| 12 | +.PHONY: doc |
| 13 | +## Run tests |
| 14 | +doc: |
| 15 | + @open "http://localhost:6060/pkg/github.com/foomo/contentful/" |
| 16 | + @godoc -http=localhost:6060 -play |
| 17 | + |
| 18 | +.PHONY: test |
| 19 | +## Run tests |
17 | 20 | test:
|
18 |
| - ./tools/test.sh |
| 21 | + @go test -p 1 -coverprofile=coverage.out -race -json ./... | gotestfmt |
19 | 22 |
|
| 23 | +.PHONY: lint |
| 24 | +## Run linter |
20 | 25 | lint:
|
21 |
| - ./tools/lint.sh |
| 26 | + @golangci-lint run |
| 27 | + |
| 28 | +.PHONY: lint.fix |
| 29 | +## Fix lint violations |
| 30 | +lint.fix: |
| 31 | + @golangci-lint run --fix |
| 32 | + |
| 33 | +.PHONY: tidy |
| 34 | +## Run go mod tidy |
| 35 | +tidy: |
| 36 | + @go mod tidy |
| 37 | + |
| 38 | +.PHONY: outdated |
| 39 | +## Show outdated direct dependencies |
| 40 | +outdated: |
| 41 | + @go list -u -m -json all | go-mod-outdated -update -direct |
| 42 | + |
| 43 | +## === Utils === |
22 | 44 |
|
23 |
| -dep: |
24 |
| - curl -fsSL -o /tmp/dep https://github.com/golang/dep/releases/download/v0.3.2/dep-linux-amd64 |
25 |
| - chmod +x /tmp/dep |
26 |
| - /tmp/dep ensure -vendor-only |
| 45 | +## Show help text |
| 46 | +help: |
| 47 | + @awk '{ \ |
| 48 | + if ($$0 ~ /^.PHONY: [a-zA-Z\-\_0-9]+$$/) { \ |
| 49 | + helpCommand = substr($$0, index($$0, ":") + 2); \ |
| 50 | + if (helpMessage) { \ |
| 51 | + printf "\033[36m%-23s\033[0m %s\n", \ |
| 52 | + helpCommand, helpMessage; \ |
| 53 | + helpMessage = ""; \ |
| 54 | + } \ |
| 55 | + } else if ($$0 ~ /^[a-zA-Z\-\_0-9.]+:/) { \ |
| 56 | + helpCommand = substr($$0, 0, index($$0, ":")); \ |
| 57 | + if (helpMessage) { \ |
| 58 | + printf "\033[36m%-23s\033[0m %s\n", \ |
| 59 | + helpCommand, helpMessage"\n"; \ |
| 60 | + helpMessage = ""; \ |
| 61 | + } \ |
| 62 | + } else if ($$0 ~ /^##/) { \ |
| 63 | + if (helpMessage) { \ |
| 64 | + helpMessage = helpMessage"\n "substr($$0, 3); \ |
| 65 | + } else { \ |
| 66 | + helpMessage = substr($$0, 3); \ |
| 67 | + } \ |
| 68 | + } else { \ |
| 69 | + if (helpMessage) { \ |
| 70 | + print "\n "helpMessage"\n" \ |
| 71 | + } \ |
| 72 | + helpMessage = ""; \ |
| 73 | + } \ |
| 74 | + }' \ |
| 75 | + $(MAKEFILE_LIST) |
0 commit comments