-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
56 lines (45 loc) · 1.22 KB
/
Makefile
File metadata and controls
56 lines (45 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
.PHONY: test test-unit test-integration test-coverage lint build clean docker-up docker-down
# Default target
all: lint test build
# Build the binary
build:
go build -o vault-audit-filter .
# Run unit tests
test-unit:
go test -v -race ./...
# Run integration tests (requires Vault to be running)
test-integration:
go test -tags=integration -v -race ./...
# Run all tests
test: test-unit
# Run tests with coverage
test-coverage:
go test -coverpkg=./... ./... -race -coverprofile=coverage.out -covermode=atomic
go tool cover -func=coverage.out
# Run linter
lint:
go vet ./...
go fmt ./...
# Clean build artifacts
clean:
rm -f vault-audit-filter
rm -f coverage.out
# Start Vault for integration tests
docker-up:
docker compose up -d
@echo "Waiting for Vault to be ready..."
@for i in $$(seq 1 30); do \
if curl -s http://127.0.0.1:8200/v1/sys/health | grep -q "initialized"; then \
echo "Vault is ready"; \
break; \
fi; \
echo "Waiting..."; \
sleep 1; \
done
# Stop Vault
docker-down:
docker compose down
# Run integration tests with docker
integration: docker-up
VAULT_ADDR=http://127.0.0.1:8200 VAULT_TOKEN=root-token AUDIT_HOST=host.docker.internal go test -tags=integration -v -race ./...
$(MAKE) docker-down