2026-05-27 12:35:01 +02:00
|
|
|
.PHONY: all build test lint coverage clean fmt vet check install-hooks changelog release release-patch release-minor release-major release-dry ship ship-dry ship-push
|
2026-03-28 11:29:42 +01:00
|
|
|
|
|
|
|
|
BINARY = unarr
|
2026-03-29 01:00:26 +01:00
|
|
|
SENTRY_DSN ?=
|
2026-03-30 13:06:07 +02:00
|
|
|
LDFLAGS = -s -w -X github.com/torrentclaw/unarr/internal/sentry.dsn=$(SENTRY_DSN)
|
2026-03-28 11:29:42 +01:00
|
|
|
|
|
|
|
|
all: fmt vet lint test build
|
|
|
|
|
|
2026-03-29 23:44:14 +02:00
|
|
|
## Build the binary (stripped, ~28MB)
|
2026-03-28 11:29:42 +01:00
|
|
|
build:
|
2026-03-29 23:44:14 +02:00
|
|
|
go build -ldflags '$(LDFLAGS)' -trimpath -o $(BINARY) ./cmd/unarr/
|
|
|
|
|
|
2026-03-28 11:29:42 +01:00
|
|
|
|
|
|
|
|
## Run all tests
|
|
|
|
|
test:
|
|
|
|
|
go test -v -race -count=1 ./...
|
|
|
|
|
|
|
|
|
|
## Run linter (requires golangci-lint)
|
|
|
|
|
lint:
|
|
|
|
|
golangci-lint run ./...
|
|
|
|
|
|
feat(cli): upgrade command, rich status, and version cache
- 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
2026-03-31 22:05:43 +02:00
|
|
|
## Run tests with coverage report (excludes CLI layer — cmd/ is glue code)
|
|
|
|
|
COVER_PKGS = $(shell go list ./... | grep -v '/cmd')
|
2026-03-28 11:29:42 +01:00
|
|
|
coverage:
|
feat(cli): upgrade command, rich status, and version cache
- 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
2026-03-31 22:05:43 +02:00
|
|
|
go test -race -coverprofile=coverage.out -covermode=atomic $(COVER_PKGS)
|
|
|
|
|
@echo "──────────────────────────────────────"
|
|
|
|
|
@go tool cover -func=coverage.out | tail -1
|
|
|
|
|
@echo "──────────────────────────────────────"
|
2026-03-28 11:29:42 +01:00
|
|
|
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/
|
|
|
|
|
|
2026-04-06 10:16:01 +02:00
|
|
|
## Preview changelog for next release
|
|
|
|
|
changelog:
|
|
|
|
|
@git-cliff --unreleased --strip header
|
|
|
|
|
|
|
|
|
|
## Create a release: make release-patch, release-minor, release-major, or release V=0.5.0
|
|
|
|
|
release:
|
|
|
|
|
@test -n "$(V)" || { echo "Usage: make release V=0.5.0"; exit 1; }
|
|
|
|
|
@./scripts/release.sh $(V)
|
|
|
|
|
|
|
|
|
|
release-patch:
|
|
|
|
|
@./scripts/release.sh patch
|
|
|
|
|
|
|
|
|
|
release-minor:
|
|
|
|
|
@./scripts/release.sh minor
|
|
|
|
|
|
|
|
|
|
release-major:
|
|
|
|
|
@./scripts/release.sh major
|
|
|
|
|
|
|
|
|
|
## Preview release without making changes
|
|
|
|
|
release-dry:
|
|
|
|
|
@test -n "$(V)" || { echo "Usage: make release-dry V=patch|minor|major|0.5.0"; exit 1; }
|
|
|
|
|
@./scripts/release.sh --dry-run $(V)
|
|
|
|
|
|
2026-05-27 12:35:01 +02:00
|
|
|
## Ship a release end-to-end (goreleaser + Hetzner + Docker Hub). Standalone backup for GH Actions.
|
|
|
|
|
## Reads version from internal/cmd/version.go unless V= is provided.
|
|
|
|
|
ship:
|
|
|
|
|
@./scripts/ship.sh $(V)
|
|
|
|
|
|
|
|
|
|
## Ship + git push tag to GH afterwards
|
|
|
|
|
ship-push:
|
|
|
|
|
@./scripts/ship.sh --push $(V)
|
|
|
|
|
|
|
|
|
|
## Preview ship steps without executing
|
|
|
|
|
ship-dry:
|
|
|
|
|
@./scripts/ship.sh --dry-run $(V)
|
|
|
|
|
|
2026-03-28 11:29:42 +01:00
|
|
|
## Remove generated files
|
|
|
|
|
clean:
|
|
|
|
|
rm -f $(BINARY) coverage.out coverage.html
|