2019-06-20 16:36:40 -07:00
OS := $( shell uname -s | tr A-Z a-z)
BINARY_PREFIX_DIRECTORY := $( OS) _amd64_stripped
2019-06-26 11:57:21 -07:00
BAZEL = $( HOME) /bin/bazel
2019-06-26 14:31:43 -07:00
BAZELOPTS = --repository_cache= " $$ HOME/.bzrepos " \
--test_output= errors \
--noshow_progress \
--noshow_loading_progress
2019-06-20 16:36:40 -07:00
.PHONY : all
all : build check
.PHONY : info
.SILENT : info
info :
2019-06-26 11:57:21 -07:00
${ BAZEL } build @io_bazel_rules_go//:go_info
2019-06-20 16:36:40 -07:00
cat bazel-bin/external/io_bazel_rules_go/linux_amd64_stripped/go_info%/go_info_report
.PHONY : setup -base
setup-base :
swag -v || go get -u github.com/swaggo/swag/cmd/swag
swag init -g pkg/api/routes.go
.PHONY : fmt -bazel
fmt-bazel :
2019-06-26 11:57:21 -07:00
${ BAZEL } run //:buildozer
${ BAZEL } run //:buildifier
2019-06-20 16:36:40 -07:00
.PHONY : update -bazel
update-bazel :
2019-06-26 11:57:21 -07:00
${ BAZEL } run //:gazelle
2019-08-28 15:58:00 -07:00
.PHONY : update -mod
update-mod :
2019-06-26 11:57:21 -07:00
${ BAZEL } run //:gazelle -- update-repos -from_file= go.mod
2019-06-20 16:36:40 -07:00
.PHONY : init
init : setup -base update -bazel fmt -bazel
.PHONY : build
build :
2019-06-26 14:31:43 -07:00
${ BAZEL } build ${ BAZELOPTS } //...
${ BAZEL } test ${ BAZELOPTS } //...
2019-06-20 16:36:40 -07:00
.PHONY : check
check :
2019-06-26 11:57:21 -07:00
${ BAZEL } run //:golangcilint
2019-06-20 16:36:40 -07:00
.PHONY : bench
.SILENT : bench
bench :
2019-06-26 11:57:21 -07:00
for i in $$ ( ${ BAZEL } query 'tests(//...)' ) ; do \
${ BAZEL } run $$ i -- -test.bench= .; \
2019-06-20 16:36:40 -07:00
done
.PHONY : coverage
.SILENT : coverage
coverage :
2019-06-26 11:57:21 -07:00
${ BAZEL } coverage //...
2019-06-20 16:36:40 -07:00
for c in $$ ( find ./bazel-out/ -name 'coverage.dat' ) ; do \
go tool cover --html= $$ c -o /tmp/cover.html; \
cat /tmp/cover.html | grep 'option value="file' | sed 's/<[^>]*>//g' | sed 's/^[ \t]*//' ; \
done
.PHONY : clean
clean :
2019-06-26 11:57:21 -07:00
${ BAZEL } clean