# 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" cmds: - go fmt ./... test: desc: Run the test suite sources: - "**/*.go" - go.mod - go.sum - "**/testdata/**/*" env: # -race needs CGO (https://go.dev/doc/articles/race_detector#Requirements) CGO_ENABLED: 1 cmds: - go test -race ./... {{ .CLI_ARGS }} demo: desc: Render the demo gifs sources: - ./docs/src/*.tape - "**/*.go" preconditions: - sh: command -v vhs msg: vhs not installed, see https://github.com/charmbracelet/vhs cmds: - for file in ./docs/src/*.tape; do vhs "$file"; done bench: desc: Run all project benchmarks sources: - "**/*.go" cmds: - go test ./... -run None -benchmem -bench . {{ .CLI_ARGS }} lint: desc: Run linting sources: - "**/*.go" - .golangci.yml preconditions: - sh: command -v golangci-lint msg: golangci-lint not installed, see https://golangci-lint.run/usage/install/#local-installation - sh: command -v typos msg: requires typos-cli, run `brew install typos-cli` cmds: - 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