134 lines
3.1 KiB
Makefile
134 lines
3.1 KiB
Makefile
# ©AngelaMos | 2026
|
|
# Justfile
|
|
|
|
set export
|
|
set shell := ["bash", "-uc"]
|
|
|
|
project := file_name(justfile_directory())
|
|
version := `git describe --tags --always 2>/dev/null || echo "dev"`
|
|
|
|
# =============================================================================
|
|
# Default
|
|
# =============================================================================
|
|
|
|
default:
|
|
@just --list --unsorted
|
|
|
|
# =============================================================================
|
|
# Linting and Formatting
|
|
# =============================================================================
|
|
|
|
[group('lint')]
|
|
lint *ARGS:
|
|
golangci-lint run --timeout=5m {{ARGS}}
|
|
|
|
[group('lint')]
|
|
lint-fix:
|
|
golangci-lint run --timeout=5m --fix
|
|
|
|
[group('lint')]
|
|
format:
|
|
golangci-lint fmt
|
|
|
|
[group('lint')]
|
|
tidy:
|
|
go mod tidy
|
|
|
|
[group('lint')]
|
|
vet:
|
|
go vet ./...
|
|
|
|
# =============================================================================
|
|
# Testing
|
|
# =============================================================================
|
|
|
|
[group('test')]
|
|
test *ARGS:
|
|
go test -race ./... {{ARGS}}
|
|
|
|
[group('test')]
|
|
test-v *ARGS:
|
|
go test -race -v ./... {{ARGS}}
|
|
|
|
[group('test')]
|
|
cover:
|
|
go test -race -cover ./...
|
|
|
|
# =============================================================================
|
|
# CI / Quality
|
|
# =============================================================================
|
|
|
|
[group('ci')]
|
|
ci: lint test
|
|
@echo "All checks passed."
|
|
|
|
[group('ci')]
|
|
check: lint vet
|
|
|
|
# =============================================================================
|
|
# Development
|
|
# =============================================================================
|
|
|
|
[group('dev')]
|
|
run *ARGS:
|
|
go run ./cmd/sentinel {{ARGS}}
|
|
|
|
[group('dev')]
|
|
dev-scan:
|
|
go run ./cmd/sentinel scan
|
|
|
|
[group('dev')]
|
|
dev-scan-json:
|
|
go run ./cmd/sentinel scan --json
|
|
|
|
[group('dev')]
|
|
dev-testdata:
|
|
go run ./cmd/sentinel scan --root testdata
|
|
|
|
[group('dev')]
|
|
dev-baseline-save:
|
|
go run ./cmd/sentinel baseline save
|
|
|
|
[group('dev')]
|
|
dev-baseline-diff:
|
|
go run ./cmd/sentinel baseline diff
|
|
|
|
# =============================================================================
|
|
# Build (Production)
|
|
# =============================================================================
|
|
|
|
[group('prod')]
|
|
build:
|
|
go build -ldflags="-s -w" -o bin/sentinel ./cmd/sentinel
|
|
@echo "Built: bin/sentinel ($(du -h bin/sentinel | cut -f1))"
|
|
|
|
[group('prod')]
|
|
build-static:
|
|
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o bin/sentinel ./cmd/sentinel
|
|
@echo "Built static: bin/sentinel ($(du -h bin/sentinel | cut -f1))"
|
|
|
|
[group('prod')]
|
|
build-debug:
|
|
go build -o bin/sentinel ./cmd/sentinel
|
|
|
|
[group('prod')]
|
|
install:
|
|
go install ./cmd/sentinel
|
|
|
|
# =============================================================================
|
|
# Utilities
|
|
# =============================================================================
|
|
|
|
[group('util')]
|
|
info:
|
|
@echo "Project: {{project}}"
|
|
@echo "Version: {{version}}"
|
|
@echo "Go: $(go version | cut -d' ' -f3)"
|
|
@echo "OS: {{os()}} ({{arch()}})"
|
|
@echo "Module: $(head -1 go.mod | cut -d' ' -f2)"
|
|
|
|
[group('util')]
|
|
clean:
|
|
-rm -rf bin/
|
|
@echo "Cleaned build artifacts."
|