Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions .github/.golangci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
version: "2"
linters:
default: all
default: none
disable:
- funcorder
- embeddedstructfieldcheck
- noinlineerr
- nonamedreturns
- varnamelen
enable:
- arangolint
- asasalint
- asciicheck
- bidichk
Expand Down Expand Up @@ -43,6 +45,7 @@ linters:
- goconst
- gocritic
- gocyclo
- godoclint
- godot
- godox
- goheader
Expand All @@ -59,6 +62,7 @@ linters:
- ineffassign
- interfacebloat
- intrange
- iotamixing
- ireturn
- lll
- loggercheck
Expand Down Expand Up @@ -101,14 +105,15 @@ linters:
- tparallel
- unconvert
- unparam
- unqueryvet
- unused
- usestdlibvars
- usetesting
- varnamelen
- wastedassign
- whitespace
- wrapcheck
- wsl
- wsl_v5
- zerologlint
settings:
cyclop:
Expand All @@ -126,6 +131,7 @@ linters:
enable-all: true
disabled-checks:
- unnamedResult
- sloppyReassign
govet:
enable-all: true
settings:
Expand All @@ -146,12 +152,13 @@ linters:
- '3'
- '4'
- '8'
- '9'
nlreturn:
block-size: 2
prealloc:
simple: false
range-loops: true
for-loops: true

exclusions:
rules:
- path: internal/hash.go
Expand Down
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ By contributing to this project, you agree that your contributions will be licen

All contributions (including pull requests) must agree to the [Developer Certificate of Origin (DCO) version 1.1](https://developercertificate.org). It states that the contributor has the right to submit the patch for inclusion into the project. Simply submitting a contribution implies this agreement, however, please include the "Signed-off-by" git tag in every commit (this tag is a conventional way to confirm that you agree to the DCO).

Thanks! :heart:
Thanks! :heart:
45 changes: 43 additions & 2 deletions .github/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ update-linters:
@go install mvdan.cc/gofumpt@latest
@go install github.com/daixiang0/gci@latest
@go install github.com/segmentio/golines@latest
@go install github.com/google/addlicense@latest
@go install golang.org/x/tools/cmd/goimports@latest
@go install golang.org/x/vuln/cmd/govulncheck@latest
@go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@latest
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin

.PHONY: fmt
fmt:
Expand All @@ -21,7 +22,7 @@ fmt:
@go fmt ../...
@golines -m 120 -t 4 -w ../
@gofumpt -w -extra ../
@gci write -s Standard -s Default -s "Prefix($(shell go list -m))" ../
@gci write -s standard -s default -s "Prefix($(shell go list -m))" -s blank -s dot -s alias --skip-generated ../
@fieldalignment -fix ../...

.PHONY: license
Expand All @@ -32,8 +33,14 @@ license:
.PHONY: lint
lint: fmt license
@echo "Linting ..."
@if golangci-lint config verify -v --config=.golangci.yml; then echo "Config OK"; else return 1; fi;
@if golangci-lint run --config=.golangci.yml ../...; then echo "Linting OK"; else return 1; fi;

.PHONY: vulncheck
vulncheck:
@echo "Running govulncheck ..."
@govulncheck -show verbose ../...

.PHONY: test
test:
@echo "Running all tests ..."
Expand All @@ -48,3 +55,37 @@ vectors:
cover:
@echo "Testing with coverage ..."
@go test -v -race -covermode=atomic -coverpkg=../... -coverprofile=./coverage.out ../tests

.PHONY: fuzz
fuzz:
@echo "Running fuzz tests ..."
@fuzzTime=$${FUZZTIME:-2}; \
failed=0; \
find .. -name '*_test.go' -exec grep -l '^func Fuzz' {} \; | while read -r file; do \
grep '^func Fuzz' "$$file" | sed -E 's/^func ([^(]+).*/\1/' | while read -r func; do \
echo "Fuzzing $$func in $$file"; \
if ! go test "$$(dirname "$$file")" -run="$$func" -fuzz="$$func" -fuzztime="$${fuzzTime}s"; then \
failed=1; \
echo "Crasher found for $$func. Crashing input:"; \
testdata_dir="$$(dirname "$$file")/testdata/fuzz/$$func"; \
if [ -d "$$testdata_dir" ]; then \
latest_crasher=$$(ls -t "$$testdata_dir" | head -n 1); \
if [ -n "$$latest_crasher" ]; then \
cat "$$testdata_dir/$$latest_crasher"; \
else \
echo "Could not find crasher file in $$testdata_dir"; \
fi; \
else \
echo "Could not find testdata directory: $$testdata_dir"; \
fi; \
fi; \
done; \
done; \
exit $$failed

.PHONY: bench
bench:
@echo "Running benchmarks ..."
@bench_regex=$${BENCH:-'.*Suites'}; \
bench_time=$${BENCHTIME:-5s}; \
go test -run '^$$' -bench "$$bench_regex" -benchmem -benchtime "$$bench_time" ../tests
Loading
Loading