Watch
1
0
Fork
You've already forked RedFlag
0
RedFlag/Makefile
Fimeg 4896fb6856 ci: Gitea Actions pipeline — release gate, embedded UI build, guided release script
ci.yml: vet, race tests, clippy, full web build, AI-attribution and
action-pin enforcement. release.yml: gate job verifies tag against
versions.go/docker-compose/Cargo/CHANGELOG, forward-only and on public,
before anything builds; web UI staged into the embed path (gitignored
dist made a bare go build ship an empty dashboard); binaries and docker
image must self-report the tag; release created via Gitea's own API.
scripts/release.sh is the operator path: checks runner, secret, branch,
versions, changelog — asks before every mutation, watches the run after.
bump-version.sh gains current-version display, dirty-tree warning,
duplicate check, changelog check, confirmation. build-secure-agent.sh
retired (bare go build, no version injection, single Makefile caller).
2026-06-11 02:01:42 -04:00

72 lines
2.9 KiB
Makefile

.PHONY: help db-up db-down server agent clean kernel-enforcer test lint version
VERSION ?= $(shell git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//' || echo "dev")
BUILD_TIME := $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
AGENT_LDFLAGS := -X github.com/Fimeg/RedFlag/agent/internal/version.Version=$(VERSION) \
-X github.com/Fimeg/RedFlag/agent/internal/version.ConfigVersion=$(VERSION) \
-X github.com/Fimeg/RedFlag/agent/internal/version.BuildTime=$(BUILD_TIME)
SERVER_LDFLAGS := -X github.com/Fimeg/RedFlag/server/internal/version/versions.AgentVersion=$(VERSION) \
-X github.com/Fimeg/RedFlag/server/internal/version/versions.ConfigVersion=$(VERSION)
help: ## Show this help message
@echo 'Usage: make [target]'
@echo ''
@echo 'Available targets:'
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-15s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
version: ## Print current version
@echo "VERSION=$(VERSION)"
db-up: ## Start PostgreSQL database
docker-compose up -d postgres
@echo "Waiting for database to be ready..."
@sleep 3
db-down: ## Stop PostgreSQL database
docker-compose down
server: ## Build and run the server
cd server && go mod tidy && go run cmd/server/main.go
agent: ## Build and run the agent
cd agent && go mod tidy && go run cmd/agent/main.go
build-server: ## Build server binary
cd server && go mod tidy && go build -ldflags "$(SERVER_LDFLAGS)" -o bin/server cmd/server/main.go
build-agent: ## Build agent binary with version injection
cd agent && go mod tidy && go build -ldflags "$(AGENT_LDFLAGS)" -o bin/agent ./cmd/agent/
clean: ## Clean build artifacts
rm -rf server/bin agent/bin
build-all: ## Build all components with version from git tag
@echo "Building all components at version $(VERSION)..."
cd server && go mod tidy && go build -ldflags "$(SERVER_LDFLAGS)" -o redflag-server cmd/server/main.go
cd agent && go mod tidy && go build -ldflags "$(AGENT_LDFLAGS)" -o redflag-agent ./cmd/agent/
@echo "Build complete!"
test: ## Run all tests
cd server && go test -race -count=1 ./...
cd agent && go test -race -count=1 ./...
cd helper && cargo test
lint: ## Run linters and vet
cd server && go vet ./...
cd agent && go vet ./...
cd helper && cargo clippy -- -D warnings
kernel-enforcer: ## Build eBPF kernel enforcer
@echo "Building eBPF kernel enforcer..."
@cd agent && clang -O2 -g -target bpf -mllvm -bpf-stack-size=4096 -c pkg-gate/pkg-gate.c -o pkg-gate/pkg-gate.o \
-I/usr/src/kernels/$(shell uname -r)/vmlinux.h \
-I/usr/src/kernels/$(shell uname -r)/tools/lib/bpf \
-I/usr/src/kernels/$(shell uname -r)/tools/bpf/resolve_btfids/libbpf/include \
-I/usr/src/kernels/$(shell uname -r)/tools/bpf/resolve_btfids/libbpf \
-I/usr/src/kernels/$(shell uname -r)
@echo "eBPF enforcer built successfully"
kernel-enforcer-clean: ## Clean eBPF kernel enforcer artifacts
@echo "Cleaning eBPF kernel enforcer..."
@cd agent && rm -f pkg-gate/pkg-gate.o
@echo "Clean complete"