-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
130 lines (108 loc) · 4.46 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
GO_BUILD_FLAGS ?= -trimpath
GO_BUILD_LDFLAGS ?= -s -w
all: test fq
# used to force make to always redo
.PHONY: always
fq: always
CGO_ENABLED=0 go build -o fq -ldflags "${GO_BUILD_LDFLAGS}" ${GO_BUILD_FLAGS} .
test: always testgo testjq testcli
test-race: always testgo-race testjq testcli
# figure out all go packages with test files
testgo: PKGS=$(shell find . -name "*_test.go" | xargs -n 1 dirname | sort | uniq)
testgo: always
go test -timeout 20m ${RACE} ${VERBOSE} ${COVER} ${PKGS}
testgo-race: RACE=-race
testgo-race: testgo
testjq: $(shell find . -name "*.jq.test")
%.jq.test: fq
@echo $@
@./fq -rRs -L pkg/interp 'include "jqtest"; run_tests' $@
testcli: fq
@pkg/cli/test_exp.sh ./fq pkg/cli/test_repl.exp
@pkg/cli/test_exp.sh ./fq pkg/cli/test_cli_ctrlc.exp
@pkg/cli/test_exp.sh ./fq pkg/cli/test_cli_ctrld.exp
cover: COVER=-cover -coverpkg=./... -coverprofile=cover.out
cover: test
go tool cover -html=cover.out -o cover.out.html
cat cover.out.html | grep '<option value="file' | sed -E 's/.*>(.*) \((.*)%\)<.*/\2 \1/' | sort -rn
doc: always
doc: $(wildcard doc/*.svg)
doc: $(wildcard *.md doc/*.md)
%.md: fq
@doc/mdsh.sh ./fq $@
doc/%.svg: fq
(cd doc ; ../$@.sh ../fq) | go run github.com/wader/ansisvg@master > $@
doc/formats.svg: fq
@# ignore graphviz version as it causes diff when nothing has changed
./fq -rnf doc/formats_diagram.jq | dot -Tsvg | sed 's/Generated by graphviz.*//' >doc/formats.svg
doc/file.mp3: Makefile
ffmpeg -y -f lavfi -i sine -f lavfi -i testsrc -map 0:0 -map 1:0 -t 20ms "$@"
doc/file.mp4: Makefile
ffmpeg -y -f lavfi -i sine -f lavfi -i testsrc -c:a aac -c:v h264 -f mp4 -t 20ms "$@"
gogenerate: always
go generate -x ./...
lint: always
# bump: make-golangci-lint /golangci-lint@v([\d.]+)/ git:https://github.com/golangci/golangci-lint.git|^1
# bump: make-golangci-lint link "Release notes" https://github.com/golangci/golangci-lint/releases/tag/v$LATEST
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.1 run
depgraph.svg: always
go run github.com/kisielk/godepgraph@latest github.com/wader/fq | dot -Tsvg -o godepgraph.svg
# make memprof ARGS=". test.mp3"
# make cpuprof ARGS=". test.mp3"
prof: always
go build -tags profile -o fq.prof .
CPUPROFILE=fq.cpu.prof MEMPROFILE=fq.mem.prof ./fq.prof ${ARGS}
memprof: prof
go tool pprof -http :5555 fq.prof fq.mem.prof
cpuprof: prof
go tool pprof -http :5555 fq.prof fq.cpu.prof
update-gomod: always
GOPROXY=direct go get -d github.com/wader/readline@fq
GOPROXY=direct go get -d github.com/wader/gojq@fq
go mod tidy
# Usage: make fuzz # fuzz all foramts
# Usage: make fuzz GROUP=mp4 # fuzz a group (each format is a group also)
# TODO: as decode recovers panic and "repanics" unrecoverable errors this is a bit hacky at the moment
# Retrigger:
# try to decode crash with all formats in order to see which one panicked:
# cat format/testdata/fuzz/FuzzFormats/... | go run dev/fuzzbytes.go | go run . -d bytes '. as $b | formats | keys[] as $f | $b | decode($f)'
# convert crash into raw bytes:
# cat format/testdata/fuzz/FuzzFormats/... | go run dev/fuzzbytes.go | fq -d bytes to_base64
# fq -n '"..." | from_base64 | ...'
fuzz: always
# in other terminal: tail -f /tmp/repanic
FUZZTEST=1 go test -v -run Fuzz -fuzz=Fuzz ./format/
# usage: make release VERSION=0.0.1
# tag forked dependeces for history and to make then stay around
release: always
release: WADER_GOJQ_COMMIT=$(shell go list -m -f '{{.Version}}' github.com/wader/gojq | sed 's/.*-\(.*\)/\1/')
release: WADER_READLINE_COMMIT=$(shell go list -m -f '{{.Version}}' github.com/wader/readline | sed 's/.*-\(.*\)/\1/')
release:
@echo "# wader/fq":
@echo "# make sure head is at wader/master"
@echo git fetch wader
@echo git show
@echo make lint test doc
@echo go mod tidy
@echo git diff
@echo
@echo "sed 's/version = "\\\(.*\\\)"/version = \"${VERSION}\"/' fq.go > fq.go.new && mv fq.go.new fq.go"
@echo git add fq.go
@echo git commit -m \"fq: Update version to ${VERSION}\"
@echo git push wader master
@echo
@echo "# make sure head master commit CI was successful"
@echo open https://github.com/wader/fq/commit/master
@echo git tag v${VERSION}
@echo
@echo "# wader/gojq:"
@echo git tag fq-v${VERSION} ${WADER_GOJQ_COMMIT}
@echo git push wader fq-v${VERSION}:fq-v${VERSION}
@echo
@echo "# wader/readline:"
@echo git tag fq-v${VERSION} ${WADER_READLINE_COMMIT}
@echo git push wader fq-v${VERSION}:fq-v${VERSION}
@echo
@echo "# wader/fq":
@echo git push wader v${VERSION}:v${VERSION}
@echo "# edit draft release notes and publish"