-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJustfile
More file actions
78 lines (59 loc) · 3.53 KB
/
Justfile
File metadata and controls
78 lines (59 loc) · 3.53 KB
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
set dotenv-load := false
set ignore-comments := true
adapter_gowork := env_var_or_default("CLIENTIP_ADAPTER_GOWORK", "off")
default:
@just --list
ci: test race coverage lint tidy-check actionlint
fmt:
gofumpt -extra -w .
goimports -w .
lint:
golangci-lint run
cd prometheus && GOWORK={{adapter_gowork}} golangci-lint run --config ../.golangci.yml
test pattern="" *args:
@echo {{ if pattern == "" { "Running full test suite with shuffle..." } else { if pattern == "--" { "Running full test suite with shuffle..." } else { "Running tests matching pattern: " + pattern } } }}
@go test -v -p 1 -count=1 ./... {{ if pattern == "" { "-shuffle=on" } else { if pattern == "--" { "-shuffle=on" } else { "-run \"" + pattern + "\"" } } }} {{args}}
@GOWORK={{adapter_gowork}} go -C prometheus test -v -p 1 -count=1 ./... {{ if pattern == "" { "-shuffle=on" } else { if pattern == "--" { "-shuffle=on" } else { "-run \"" + pattern + "\"" } } }} {{args}}
fuzz fuzztime="30s" *args:
@echo "Running parser fuzz targets for {{fuzztime}} each"
@go test -run '^$' -fuzz '^FuzzParseIP_RoundTripNormalization$' -fuzztime "{{fuzztime}}" . {{args}}
@go test -run '^$' -fuzz '^FuzzParseRemoteAddr_RoundTripNormalization$' -fuzztime "{{fuzztime}}" . {{args}}
@go test -run '^$' -fuzz '^FuzzParseXFFValues_ErrorShapeAndOutput$' -fuzztime "{{fuzztime}}" . {{args}}
@go test -run '^$' -fuzz '^FuzzParseForwardedValues_ErrorShapeAndOutput$' -fuzztime "{{fuzztime}}" . {{args}}
fuzz-one target fuzztime="30s" *args:
@echo "Running fuzz target name {{target}} for {{fuzztime}}"
@go test -run '^$' -fuzz '^{{target}}$' -fuzztime "{{fuzztime}}" . {{args}}
bench pattern="." *args:
@echo "Running benchmarks matching pattern: {{pattern}}"
@go test -run '^$' -bench "{{pattern}}" -benchmem -count=1 ./... {{args}}
@GOWORK={{adapter_gowork}} go -C prometheus test -run '^$' -bench "{{pattern}}" -benchmem -count=1 ./... {{args}}
bench-all *args:
@just bench "." {{args}}
bench-save name pattern="." count="6" *args:
@mkdir -p .bench
@echo "Saving benchmark sample to .bench/{{name}}.txt"
@go test -run "^$" -bench "{{pattern}}" -benchmem -count={{count}} ./... {{args}} > ".bench/{{name}}.txt"
@GOWORK={{adapter_gowork}} go -C prometheus test -run "^$" -bench "{{pattern}}" -benchmem -count={{count}} ./... {{args}} >> ".bench/{{name}}.txt"
bench-compare-saved before after:
@just bench-compare ".bench/{{before}}.txt" ".bench/{{after}}.txt"
bench-compare before after:
@if command -v benchstat >/dev/null 2>&1; then benchstat "{{before}}" "{{after}}"; else go run golang.org/x/perf/cmd/benchstat@latest "{{before}}" "{{after}}"; fi
race:
go test -race ./...
GOWORK={{adapter_gowork}} go -C prometheus test -race ./...
coverage:
go test -coverprofile=coverage.out ./...
GOWORK={{adapter_gowork}} go -C prometheus test -coverprofile=../coverage-prometheus.out ./...
go tool cover -func=coverage.out
GOWORK={{adapter_gowork}} go -C prometheus tool cover -func=../coverage-prometheus.out
vet:
go vet ./...
GOWORK={{adapter_gowork}} go -C prometheus vet ./...
tidy-check:
before="$(git status --porcelain -- go.mod go.sum)"; go mod tidy; after="$(git status --porcelain -- go.mod go.sum)"; test "$before" = "$after"
before="$(git status --porcelain -- prometheus/go.mod prometheus/go.sum)"; GOWORK={{adapter_gowork}} go -C prometheus mod tidy; after="$(git status --porcelain -- prometheus/go.mod prometheus/go.sum)"; test "$before" = "$after"
security:
govulncheck ./...
cd prometheus && GOWORK={{adapter_gowork}} govulncheck ./...
actionlint:
actionlint