2017-06-27 08:42:46 +00:00
|
|
|
COVERAGE_REPORT := coverage.txt
|
|
|
|
COVERAGE_PROFILE := profile.out
|
|
|
|
COVERAGE_MODE := atomic
|
|
|
|
|
2017-04-05 16:38:42 +00:00
|
|
|
LINGUIST_PATH = .linguist
|
2016-07-13 20:21:18 +00:00
|
|
|
|
2017-07-07 09:20:54 +00:00
|
|
|
# build CLI
|
|
|
|
VERSION := $(shell git describe --tags --abbrev=0)
|
|
|
|
COMMIT := $(shell git rev-parse --short HEAD)
|
|
|
|
LDFLAGS = -s -X main.Version=$(VERSION) -X main.GitHash=$(COMMIT)
|
|
|
|
|
2017-04-05 16:38:42 +00:00
|
|
|
$(LINGUIST_PATH):
|
2017-04-05 17:27:19 +00:00
|
|
|
git clone https://github.com/github/linguist.git $@
|
2017-04-05 16:38:42 +00:00
|
|
|
|
|
|
|
test: $(LINGUIST_PATH)
|
|
|
|
go test -v ./...
|
|
|
|
|
2017-06-27 08:42:46 +00:00
|
|
|
test-coverage: $(LINGUIST_PATH)
|
|
|
|
@echo "mode: $(COVERAGE_MODE)" > $(COVERAGE_REPORT); \
|
|
|
|
for dir in `find . -name "*.go" | grep -o '.*/' | sort -u | grep -v './fixtures/' | grep -v './.linguist/'`; do \
|
|
|
|
go test $$dir -coverprofile=$(COVERAGE_PROFILE) -covermode=$(COVERAGE_MODE); \
|
|
|
|
if [ $$? != 0 ]; then \
|
|
|
|
exit 2; \
|
|
|
|
fi; \
|
|
|
|
if [ -f $(COVERAGE_PROFILE) ]; then \
|
|
|
|
tail -n +2 $(COVERAGE_PROFILE) >> $(COVERAGE_REPORT); \
|
|
|
|
rm $(COVERAGE_PROFILE); \
|
|
|
|
fi; \
|
|
|
|
done;
|
|
|
|
|
2017-04-05 16:38:42 +00:00
|
|
|
code-generate: $(LINGUIST_PATH)
|
2017-06-08 10:28:36 +00:00
|
|
|
mkdir -p data
|
2017-04-05 16:38:42 +00:00
|
|
|
go run internal/code-generator/main.go
|
|
|
|
|
|
|
|
clean:
|
2017-06-08 10:28:36 +00:00
|
|
|
rm -rf $(LINGUIST_PATH)
|
2017-07-07 09:20:54 +00:00
|
|
|
|
|
|
|
build-cli:
|
|
|
|
go build -o enry -ldflags "$(LDFLAGS)" cli/enry/main.go
|