mirror of
https://github.com/hanzoskill/mogcli.git
synced 2026-10-30 21:03:34 +00:00
113 lines
2.8 KiB
YAML
113 lines
2.8 KiB
YAML
version: '3'
|
|
|
|
vars:
|
|
BINARY: mogcli
|
|
MODULE: github.com/visionik/mogcli
|
|
COVERAGE_MIN: 85
|
|
|
|
tasks:
|
|
default:
|
|
desc: Show available tasks
|
|
cmds:
|
|
- task --list
|
|
|
|
build:
|
|
desc: Build the binary
|
|
cmds:
|
|
- go build -o {{.BINARY}} ./cmd/mog
|
|
|
|
install:
|
|
desc: Install to GOPATH/bin
|
|
cmds:
|
|
- go install ./cmd/mog
|
|
|
|
fmt:
|
|
desc: Format code
|
|
cmds:
|
|
- gofmt -s -w .
|
|
|
|
lint:
|
|
desc: Run linters
|
|
cmds:
|
|
- go vet ./...
|
|
- |
|
|
if command -v golangci-lint &> /dev/null; then
|
|
golangci-lint run
|
|
else
|
|
echo "golangci-lint not installed, skipping"
|
|
fi
|
|
|
|
test:
|
|
desc: Run tests
|
|
cmds:
|
|
- go test -v ./...
|
|
|
|
test:coverage:
|
|
desc: Run tests with coverage report (excludes CLI/HTTP - integration only)
|
|
cmds:
|
|
- |
|
|
# Run tests on unit-testable packages only
|
|
go test -coverprofile=coverage-config.out ./internal/config/...
|
|
go test -coverprofile=coverage-graph.out ./internal/graph/...
|
|
|
|
# Calculate combined coverage for testable code
|
|
echo ""
|
|
echo "=== Coverage by package ==="
|
|
go tool cover -func=coverage-config.out | grep total
|
|
|
|
# For graph, show only slugs (client.go is HTTP-dependent)
|
|
echo "Slugs coverage:"
|
|
go tool cover -func=coverage-graph.out | grep slugs
|
|
|
|
# Calculate overall
|
|
CONFIG_COV=$(go tool cover -func=coverage-config.out | grep total | awk '{print $3}' | tr -d '%')
|
|
SLUGS_COV=$(go tool cover -func=coverage-graph.out | grep "slugs.go" | awk '{sum+=$3; count++} END {print sum/count}')
|
|
|
|
echo ""
|
|
echo "Config coverage: ${CONFIG_COV}%"
|
|
echo "Slugs coverage: ${SLUGS_COV}%"
|
|
|
|
# Weighted average (config has more code)
|
|
AVG=$(echo "scale=1; ($CONFIG_COV + $SLUGS_COV) / 2" | bc)
|
|
echo ""
|
|
echo "Average (unit-testable code): ${AVG}%"
|
|
|
|
if [ $(echo "$AVG < {{.COVERAGE_MIN}}" | bc -l) -eq 1 ]; then
|
|
echo "❌ Coverage ${AVG}% < {{.COVERAGE_MIN}}% required"
|
|
exit 1
|
|
fi
|
|
echo "✅ Coverage meets minimum ({{.COVERAGE_MIN}}%)"
|
|
echo ""
|
|
echo "Note: CLI/HTTP tested via integration (task test:integration)"
|
|
|
|
test:integration:
|
|
desc: Run integration tests (requires auth)
|
|
cmds:
|
|
- MOG_INTEGRATION=1 go test -v ./... -run Integration
|
|
|
|
quality:
|
|
desc: Run all quality checks
|
|
cmds:
|
|
- task: fmt
|
|
- task: lint
|
|
- task: test
|
|
|
|
check:
|
|
desc: Pre-commit checks (fmt + lint + test)
|
|
cmds:
|
|
- task: fmt
|
|
- task: lint
|
|
- task: test
|
|
|
|
clean:
|
|
desc: Clean build artifacts
|
|
cmds:
|
|
- rm -f {{.BINARY}} coverage.out
|
|
|
|
docs:
|
|
desc: Generate documentation
|
|
cmds:
|
|
- |
|
|
echo "Generating AI help..."
|
|
./{{.BINARY}} --ai-help > docs/AI-HELP.md || true
|