2019-05-19 02:27:10 +02:00
|
|
|
.PHONY: test format vet staticcheck magneticod magneticow image image-magneticow image-magneticod
|
2018-08-07 09:31:26 +02:00
|
|
|
|
2018-08-27 10:15:01 +02:00
|
|
|
all: test magneticod magneticow
|
2017-11-03 00:15:13 +01:00
|
|
|
|
|
|
|
magneticod:
|
2019-05-19 12:20:17 +02:00
|
|
|
go install --tags fts5 "-ldflags=-s -w -X main.compiledOn=`date -u +%Y-%m-%dT%H:%M:%SZ`" ./cmd/magneticod
|
2017-11-03 00:15:13 +01:00
|
|
|
|
|
|
|
magneticow:
|
|
|
|
# TODO: minify files!
|
2018-12-25 16:38:13 +01:00
|
|
|
# https://github.com/kevinburke/go-bindata
|
2018-08-27 10:15:01 +02:00
|
|
|
go-bindata -o="cmd/magneticow/bindata.go" -prefix="cmd/magneticow/data/" cmd/magneticow/data/...
|
2020-11-27 19:06:43 +01:00
|
|
|
# Prepend the linter instruction to the beginning of the file
|
|
|
|
sed -i '1s;^;//lint:file-ignore * Ignore file altogether\n;' cmd/magneticow/bindata.go
|
2019-05-19 12:20:17 +02:00
|
|
|
go install --tags fts5 "-ldflags=-s -w -X main.compiledOn=`date -u +%Y-%m-%dT%H:%M:%SZ`" ./cmd/magneticow
|
2018-08-03 14:40:04 +02:00
|
|
|
|
2019-11-14 12:52:37 +01:00
|
|
|
.PHONY: docker
|
|
|
|
docker: docker_up docker_logs
|
|
|
|
|
|
|
|
.PHONY: docker_up
|
|
|
|
docker_up:
|
|
|
|
docker-compose up -d
|
|
|
|
|
|
|
|
.PHONY: docker_down
|
|
|
|
docker_down:
|
|
|
|
docker-compose down
|
|
|
|
|
|
|
|
.PHONY: docker_logs
|
|
|
|
docker_logs:
|
|
|
|
docker-compose logs -ft --tail=10
|
|
|
|
|
2018-08-27 10:15:01 +02:00
|
|
|
image-magneticod:
|
2019-09-18 03:27:04 +02:00
|
|
|
docker build -t boramalper/magneticod -f Dockerfile.magneticod .
|
2018-08-27 10:15:01 +02:00
|
|
|
|
|
|
|
image-magneticow:
|
2019-09-18 03:27:04 +02:00
|
|
|
docker build -t boramalper/magneticow -f Dockerfile.magneticow .
|
2018-08-27 10:15:01 +02:00
|
|
|
|
|
|
|
image: image-magneticod image-magneticow
|
|
|
|
|
2018-12-30 06:21:56 +01:00
|
|
|
vet:
|
2019-05-19 18:22:22 +02:00
|
|
|
go vet ./...
|
2018-08-27 10:15:01 +02:00
|
|
|
|
2018-12-30 06:21:56 +01:00
|
|
|
staticcheck:
|
2020-11-27 19:06:43 +01:00
|
|
|
./misc/staticcheck/staticcheck -fail all ./...
|
2018-08-27 10:15:01 +02:00
|
|
|
|
2018-12-30 06:21:56 +01:00
|
|
|
test:
|
2019-05-19 18:22:22 +02:00
|
|
|
go test ./...
|
2018-08-27 10:15:01 +02:00
|
|
|
|
2018-08-03 14:40:04 +02:00
|
|
|
format:
|
2019-05-19 18:22:22 +02:00
|
|
|
gofmt -w ./cmd/
|
|
|
|
gofmt -w ./pkg/
|
2018-12-30 06:21:56 +01:00
|
|
|
|
|
|
|
# Formatting Errors
|
|
|
|
# Since gofmt returns zero even if there are files to be formatted, we use:
|
|
|
|
#
|
|
|
|
# ! gofmt -d ${GOPATH}/path/ 2>&1 | read
|
|
|
|
#
|
|
|
|
# to return 1 if there are files to be formatted, and 0 if not.
|
|
|
|
# https://groups.google.com/forum/#!topic/Golang-Nuts/pdrN4zleUio
|
|
|
|
#
|
|
|
|
# How can I use Bash syntax in Makefile targets?
|
|
|
|
# Because `read` is a bash command.
|
|
|
|
# https://stackoverflow.com/a/589300/4466589
|
|
|
|
#
|
2020-11-27 20:49:26 +01:00
|
|
|
# How to ignore bindata.go
|
|
|
|
# Due to irrational insistence of some Go developers, gofmt, like many
|
|
|
|
# other tools of Go ecosystem, does not have flags for common scenarios
|
|
|
|
# such as ignoring certain files by pattern etc. Thus we use `go list`
|
|
|
|
# and grep together to achieve the desired result.
|
|
|
|
#
|
|
|
|
# The original query is this:
|
|
|
|
# gofmt -l $(go list -f $'{{range .GoFiles}}{{$.Dir}}/{{.}}\n{{end}}' ./... | grep -v bindata.go)
|
|
|
|
#
|
|
|
|
# The original query is then escaped for Makefile (by repeating dollar signs $ -> $$).
|
2018-12-30 06:21:56 +01:00
|
|
|
check-formatting: SHELL:=/bin/bash # HERE: this is setting the shell for check-formatting only
|
|
|
|
check-formatting:
|
2020-11-27 20:49:26 +01:00
|
|
|
! gofmt -l $$(go list -f $$'{{range .GoFiles}}{{$$.Dir}}/{{.}}\n{{end}}' ./... | grep -v bindata.go) 2>&1 | tee /dev/fd/2 | read
|
|
|
|
! gofmt -l $$(go list -f $$'{{range .GoFiles}}{{$$.Dir}}/{{.}}\n{{end}}' ./... | grep -v bindata.go) 2>&1 | tee /dev/fd/2 | read
|