forked from guacsec/guac
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
57 lines (42 loc) · 1.67 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
VERSION=$(shell git describe --tags --always)
COMMIT=$(shell git rev-parse HEAD)
BUILD=$(shell date +%FT%T%z)
PKG=github.com/guacsec/guac
LDFLAGS="-X $(PKG).version=$(VERSION) -X $(PKG).commit=$(COMMIT) -X $(PKG).date=$(BUILD)"
.DEFAULT_GOAL := build
.PHONY: all
all: test cover fmt lint ci build
.PHONY: test
test: ## Run the unit tests
echo 'mode: atomic' > coverage.txt && go test -covermode=atomic -coverprofile=coverage.txt -v -race -timeout=30s ./...
.PHONY: integration-test
integration-test: ## Run the integration tests
go test -tags=integration ./...
.PHONY: cover
cover: test ## Run all the tests and opens the coverage report
go tool cover -html=coverage.txt
.PHONY: fmt
fmt: ## Check the formatting
test -z "$(shell goimports -l -e .)"
test -z "$(shell find . -name '*.go' -not -wholename './vendor/*' -exec .github/scripts/copywrite.sh {} \;)"
.PHONY: lint
lint: ## Run all the linters
golangci-lint run ./...
.PHONY: ci
ci: fmt lint test ## Run all the tests and code checks
.PHONY: build
build: ## Build a version
go build -ldflags ${LDFLAGS} -o bin/collector cmd/collector/main.go
go build -ldflags ${LDFLAGS} -o bin/ingest cmd/ingest/main.go
go build -ldflags ${LDFLAGS} -o bin/guacone cmd/guacone/main.go
.PHONY: clean
clean: ## Remove temporary files
go clean
# Absolutely awesome: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY:format fmt-md
format: fmt-md ## Run all the formatting tasks
fmt-md: ## Format all the markdown files
npx --yes prettier --write --prose-wrap always **/*.md