- Replace `upgrade` stub with real command (alias for `self-update`) - Also register `update` as alias: `unarr update` works too - Rewrite `status` to show full config, disk usage, daemon state, and update availability with colored sections - Add version check cache (1h TTL) so `status` is instant on repeat runs - Guard against division by zero on empty filesystems - Guard against negative durations from clock skew - Guard against stale PID via heartbeat recency check (2 min) - Add comprehensive test coverage across agent, engine, upgrade, usenet, arr, library, mediaserver, and UI packages - Improve Makefile coverage target to exclude cmd/ glue code - Fix stream handler resource cleanup and ffprobe error handling
53 lines
1.4 KiB
Makefile
53 lines
1.4 KiB
Makefile
.PHONY: all build test lint coverage clean fmt vet check install-hooks
|
|
|
|
BINARY = unarr
|
|
SENTRY_DSN ?=
|
|
LDFLAGS = -s -w -X github.com/torrentclaw/unarr/internal/sentry.dsn=$(SENTRY_DSN)
|
|
|
|
all: fmt vet lint test build
|
|
|
|
## Build the binary (stripped, ~28MB)
|
|
build:
|
|
go build -ldflags '$(LDFLAGS)' -trimpath -o $(BINARY) ./cmd/unarr/
|
|
|
|
|
|
## Run all tests
|
|
test:
|
|
go test -v -race -count=1 ./...
|
|
|
|
## Run linter (requires golangci-lint)
|
|
lint:
|
|
golangci-lint run ./...
|
|
|
|
## Run tests with coverage report (excludes CLI layer — cmd/ is glue code)
|
|
COVER_PKGS = $(shell go list ./... | grep -v '/cmd')
|
|
coverage:
|
|
go test -race -coverprofile=coverage.out -covermode=atomic $(COVER_PKGS)
|
|
@echo "──────────────────────────────────────"
|
|
@go tool cover -func=coverage.out | tail -1
|
|
@echo "──────────────────────────────────────"
|
|
go tool cover -html=coverage.out -o coverage.html
|
|
|
|
## Format code
|
|
fmt:
|
|
gofmt -s -w .
|
|
|
|
## Check formatting (no write, exits non-zero if unformatted)
|
|
check:
|
|
@test -z "$$(gofmt -l .)" || { echo "Files not formatted:"; gofmt -l .; exit 1; }
|
|
|
|
## Run go vet
|
|
vet:
|
|
go vet ./...
|
|
|
|
## Install lefthook git hooks
|
|
install-hooks:
|
|
lefthook install
|
|
|
|
## Install binary to GOPATH/bin
|
|
install:
|
|
go install ./cmd/unarr/
|
|
|
|
## Remove generated files
|
|
clean:
|
|
rm -f $(BINARY) coverage.out coverage.html
|