-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
77 lines (60 loc) · 3.06 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
include golang.mk
.DEFAULT_GOAL := test # override default goal set in library makefile
.PHONY: test benchmark-data clean bump-major bump-minor bump-patch tag-version $(PKGS)
SHELL := /bin/bash
export PATH := $(PWD)/bin:$(PATH)
PKGS = $(shell go list ./... | grep -v /vendor | grep -v /tools)
$(eval $(call golang-version-check,1.13))
export _DEPLOY_ENV=testing
export _EXECUTION_NAME=abc123
define set-version
@echo $(VERS) > VERSION
@echo "// Code generated by Makefile. DO NOT EDIT." > version.go
@echo >> version.go
@echo "package kayvee" >> version.go
@echo >> version.go
@echo "// Version is a string containing the version of this library." >> version.go
@echo "var Version = \"$(VERS)\"" >> version.go
@git add VERSION version.go
@git commit -m "Bump to v$(VERS)"
endef
bump-major:
$(eval VERS := $(shell head -n1 VERSION | awk 'BEGIN{FS="."} {print $$1+1 ".0.0"}'))
$(eval MAJOR_VERS := $(firstword $(subst ., ,$(VERS))))
@find . -path ./.git -prune -o -path ./vendor -prune -o -type f -exec sed -i.bak -e 's@github\.com/Clever/kayvee-go/v[[:digit:]]\{1,\}@github\.com/Clever/kayvee-go/v$(MAJOR_VERS)@g' {} ';' -exec rm {}.bak ';' -exec git add {} ';'
$(call set-version)
bump-minor:
$(eval VERS := $(shell cat VERSION | awk 'BEGIN{FS="."} {print $$1 "." $$2+1 ".0"}'))
$(call set-version)
bump-patch:
$(eval VERS := $(shell cat VERSION | awk 'BEGIN{FS="."} {print $$1 "." $$2 "." $$3+1}'))
$(call set-version)
tag-version:
$(eval VERS := $(shell cat VERSION))
@git tag v$(VERS)
generate:
go generate ./...
test: generate tests.json benchmark-data $(PKGS)
clean:
rm ./benchmarks/data/*.json ./benchmarks/data/*.yml
benchmark-data:
@# Only download if the files don't exist
@[ -f ./benchmarks/data/corpus-basic.json ] || curl https://raw.githubusercontent.com/Clever/kayvee/master/data/corpus-basic.json > ./benchmarks/data/corpus-basic.json
@[ -f ./benchmarks/data/corpus-pathological.json ] || curl https://raw.githubusercontent.com/Clever/kayvee/master/data/corpus-pathological.json > ./benchmarks/data/corpus-pathological.json
@[ -f ./benchmarks/data/corpus-realistic.json ] || curl https://raw.githubusercontent.com/Clever/kayvee/master/data/corpus-realistic.json > ./benchmarks/data/corpus-realistic.json
@[ -f ./benchmarks/data/kvconfig-basic.yml ] || curl https://raw.githubusercontent.com/Clever/kayvee/master/data/kvconfig-basic.yml > ./benchmarks/data/kvconfig-basic.yml
@[ -f ./benchmarks/data/kvconfig-pathological.yml ] || curl https://raw.githubusercontent.com/Clever/kayvee/master/data/kvconfig-pathological.yml > ./benchmarks/data/kvconfig-pathological.yml
@[ -f ./benchmarks/data/kvconfig-realistic.yml ] || curl https://raw.githubusercontent.com/Clever/kayvee/master/data/kvconfig-realistic.yml > ./benchmarks/data/kvconfig-realistic.yml
benchmarks: benchmark-data
@go test -v -bench=./benchmarks
$(PKGS): golang-test-all-strict-deps
@go get -d -t $@
@go generate
$(call golang-test-all-strict,$@)
tests.json:
cp tests.json test/tests.json
test-local-otel:
@./test/otelcol-test.sh
install_deps:
go mod vendor
go build -o bin/mockgen github.com/golang/mock/mockgen