1BIN=img
2OUT=./bin/$(BIN)
3SERVER=./cmd/server/main.go
4
5GO_TEST=go test -v -timeout 100ms -shuffle on -parallel `nproc`
6GO_BUILD=go build -v -ldflags '-w -s'
7GO_RUN=go run -v
8
9all: build
10
11build: sass tmpl
12 $(GO_BUILD) -o $(OUT) $(SERVER)
13
14compress: build
15 upx -1 $(OUT)
16
17compress_into_oblivion: build
18 upx --best --ultra-brute $(OUT)
19
20run: sass
21 $(GO_RUN) $(SERVER) \
22 --log-level error \
23 --aes-key=6368616e676520746869732070617373 \
24 --cache-path=${HOME}/.thumb
25
26sass:
27 @mkdir -p static
28 sassc \
29 -I scss scss/main.scss static/main.css \
30 --style compressed
31
32tmpl:
33 qtc -dir=./templates
34
35test: test.unit test.integration
36
37test.all: gci test.unit test.integration lint
38
39test.integration:
40 $(GO_TEST) -tags=integration ./...
41
42test.unit:
43 $(GO_TEST) -tags=unit ./...
44
45gen:
46 go run -v \
47 ./cmd/ggen/...
48
49cover.%:
50 $(GO_TEST) \
51 -tags=$* \
52 -coverprofile=bin/cover \
53 ./...
54 go tool cover \
55 -html=bin/cover \
56 -o bin/cover.html
57 echo "open bin/cover.html"
58
59lint:
60 golangci-lint run \
61 --fix \
62 --config golangci.yml \
63 --verbose \
64 ./...
65
66fix: gci alignment
67
68gci:
69 find . \
70 -type f \
71 -name "*.go" \
72 -not -path "./vendor/*" \
73 -exec gci write -s standard -s default -s "prefix(git.sr.ht/~gabrielgio/img)" {} +
74
75alignment:
76 betteralign -apply ./...