-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
97 lines (80 loc) · 3.61 KB
/
Makefile
File metadata and controls
97 lines (80 loc) · 3.61 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# Makefile for the another-me project
# Go parameters
GOBASE := $(shell pwd)
PKG_LIST := $(shell go list ./... | grep -v /vendor/)
# Docker parameters
DOCKER_COMPOSE_FILE := docker-compose.yaml
.PHONY: all actions test test-unit test-integration lint tidy docker-up docker-down docker-clean-restart docker-logs help
all: test lint tidy
# ===================================================================================
# GitHub Actions (local)
# ===================================================================================
actions:
@echo "Installing/Updating act..."
@go install github.com/nektos/act@latest
@echo "Running act..."
@act
# ===================================================================================
# Testing
# ===================================================================================
test: test-unit
test-unit:
@echo "Running unit tests..."
@go test -v -race -coverprofile=coverage-unit.out $(PKG_LIST)
test-integration:
@echo "Running integration tests..."
@echo "Ensure Docker services (PostgreSQL, etc.) are running before executing integration tests."
@go test -v -race -count=1 -tags=integration $(PKG_LIST)
test-all: test-unit test-integration
@echo "All tests completed."
# ===================================================================================
# Go tools
# ===================================================================================
lint:
@echo "Running linters..."
@golangci-lint-v2 run ./... || golangci-lint run ./...
tidy:
@echo "Tidying go modules..."
@go mod tidy
# ===================================================================================
# Docker
# ===================================================================================
docker-up:
@echo "Starting Docker services in detached mode..."
@docker compose -f $(DOCKER_COMPOSE_FILE) up -d
docker-down:
@echo "Stopping Docker services..."
@docker compose -f $(DOCKER_COMPOSE_FILE) down
docker-clean-restart:
@echo "Stopping Docker services..."
@docker compose -f $(DOCKER_COMPOSE_FILE) down
@rm -rf $(GOBASE)/.docker-data
@echo "Starting Docker services in detached mode..."
@docker compose -f $(DOCKER_COMPOSE_FILE) up -d
docker-logs:
@echo "Showing Docker service logs..."
@docker compose -f $(DOCKER_COMPOSE_FILE) logs -f
# ===================================================================================
# Help
# ===================================================================================
help:
@echo "-------------------------------------------------------------------------"
@echo "Usage: make <target>"
@echo ""
@echo "Available targets are:"
@echo " all Runs test, lint, and tidy."
@echo " actions Runs GitHub Actions locally."
@echo " test Alias for test-unit."
@echo " test-unit Runs all unit tests."
@echo " test-integration Runs all integration tests (requires Docker services to be up)."
@echo " test-all Runs all unit and integration tests."
@echo " lint Runs golangci-lint."
@echo " tidy Runs go mod tidy."
@echo " docker-up Starts Docker services (PostgreSQL, Neo4j, Qdrant) in detached mode."
@echo " docker-down Stops Docker services."
@echo " docker-clean-restart Stops Docker services and removes the .docker-data directory, then starts Docker services in detached mode."
@echo " docker-logs Shows logs for running Docker services."
@echo " help Shows this help message."
@echo "-------------------------------------------------------------------------"
# Default target
.DEFAULT_GOAL := help