forked from bluenviron/gortsplib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
86 lines (69 loc) · 1.85 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
78
79
80
81
82
83
84
85
86
BASE_IMAGE = golang:1.17-alpine3.14
LINT_IMAGE = golangci/golangci-lint:v1.44.2
.PHONY: $(shell ls)
help:
@echo "usage: make [action]"
@echo ""
@echo "available actions:"
@echo ""
@echo " mod-tidy run go mod tidy"
@echo " format format source files"
@echo " test run tests"
@echo " lint run linter"
@echo " bench run benchmarks"
@echo ""
blank :=
define NL
$(blank)
endef
mod-tidy:
docker run --rm -it -v $(PWD):/s -w /s $(BASE_IMAGE) \
sh -c "apk add git && GOPROXY=direct go get && go mod tidy"
define DOCKERFILE_FORMAT
FROM $(BASE_IMAGE)
RUN go install mvdan.cc/gofumpt@v0.2.0
endef
export DOCKERFILE_FORMAT
format:
echo "$$DOCKERFILE_FORMAT" | docker build -q . -f - -t temp
docker run --rm -it -v $(PWD):/s -w /s temp \
sh -c "gofumpt -l -w ."
define DOCKERFILE_TEST
FROM $(BASE_IMAGE)
RUN apk add --no-cache make docker-cli git gcc musl-dev pkgconfig ffmpeg-dev
WORKDIR /s
COPY go.mod go.sum ./
RUN go mod download
COPY . ./
endef
export DOCKERFILE_TEST
test:
echo "$$DOCKERFILE_TEST" | docker build -q . -f - -t temp
docker run --rm -it \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
--network=host \
--name temp \
temp \
make test-nodocker
test-examples:
go build -o /dev/null ./examples/...
test-pkg:
go test -v -race -coverprofile=coverage-pkg.txt ./pkg/...
test-root:
$(foreach IMG,$(shell echo testimages/*/ | xargs -n1 basename), \
docker build -q testimages/$(IMG) -t gortsplib-test-$(IMG)$(NL))
go test -v -race -coverprofile=coverage-root.txt .
test-nodocker: test-examples test-pkg test-root
lint:
docker run --rm -v $(PWD):/app -w /app \
$(LINT_IMAGE) \
golangci-lint run -v
bench:
echo "$$DOCKERFILE_TEST" | docker build -q . -f - -t temp
docker run --rm -it \
--network=host \
--name temp \
temp \
make bench-nodocker
bench-nodocker:
go test -bench=. -v ./pkg/ringbuffer