Something went wrong. Try again.
A lightweight test helper package
Something went wrong. Try again.
test Taskfile.yml
2.5 kB · 110 lines
YAML
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111# https://taskfile.dev
version: "3"
vars: COV_DATA: coverage.out
tasks: default: desc: List all available tasks silent: true cmds: - task --list
tidy: desc: Tidy dependencies in go.mod and go.sum sources: - "**/*.go" - go.mod - go.sum cmds: - go mod tidy
fmt: desc: Run go fmt on all source files sources: - "**/*.go" preconditions: - sh: command -v golines msg: golines not installed, run `go install github.com/segmentio/golines@latest` cmds: - go fmt ./... - golines . --ignore-generated --write-output --max-len 120
test: desc: Run the test suite sources: - "**/*.go" - testdata/**/*.snap.txt cmds: - go test -race ./... {{ .CLI_ARGS }} env: NO_COLOR: true
bench: desc: Run all project benchmarks sources: - "**/*.go" cmds: - go test ./... -run None -benchmem -bench . {{ .CLI_ARGS }}
lint: desc: Run the linters and auto-fix if possible sources: - "**/*.go" - .golangci.yml deps: - fmt preconditions: - sh: command -v golangci-lint msg: golangci-lint not installed, see https://golangci-lint.run/usage/install/#local-installation
- sh: command -v betteralign msg: requires betteralign, run `go install github.com/dkorunic/betteralign/cmd/betteralign@latest`
- sh: command -v typos msg: requires typos-cli, run `brew install typos-cli` cmds: - betteralign -test_files -apply ./... - golangci-lint run --fix - typos
doc: desc: Render the pkg docs locally preconditions: - sh: command -v pkgsite msg: pkgsite not installed, run `go install golang.org/x/pkgsite/cmd/pkgsite@latest` cmds: - pkgsite -open
cov: desc: Calculate test coverage and render the html generates: - "{{ .COV_DATA }}" cmds: - go test -race -cover -covermode atomic -coverprofile {{ .COV_DATA }} ./... - go tool cover -html {{ .COV_DATA }}
check: desc: Run tests and linting in one cmds: - task: test - task: lint
sloc: desc: Print lines of code cmds: - fd . -e go | xargs wc -l | sort -nr | head
clean: desc: Remove build artifacts and other clutter cmds: - go clean ./... - rm -rf {{ .COV_DATA }}
update: desc: Updates dependencies in go.mod and go.sum cmds: - go get -u ./... - go mod tidy