|
| 1 | +# Makefile for valkey-ai-tasks project |
| 2 | + |
| 3 | +# Go parameters |
| 4 | +GOCMD=go |
| 5 | +GOBUILD=$(GOCMD) build |
| 6 | +GOTEST=$(GOCMD) test |
| 7 | +GOGET=$(GOCMD) get |
| 8 | +GOMOD=$(GOCMD) mod |
| 9 | +GOFMT=$(GOCMD) fmt |
| 10 | + |
| 11 | +# Project directories |
| 12 | +TEST_DIR=./tests |
| 13 | +INTEG_TEST_DIR=$(TEST_DIR)/integration |
| 14 | + |
| 15 | +# Test parameters |
| 16 | +COVERAGE_DIR=./coverage |
| 17 | +COVERAGE_FILE=$(COVERAGE_DIR)/coverage.out |
| 18 | +COVERAGE_HTML=$(COVERAGE_DIR)/coverage.html |
| 19 | + |
| 20 | +# Default filter is empty (run all tests) |
| 21 | +filter?=. |
| 22 | + |
| 23 | +# Default verbosity is off |
| 24 | +verbose?= |
| 25 | + |
| 26 | +# Set verbosity flag if verbose is set |
| 27 | +ifdef verbose |
| 28 | + VERBOSE_FLAG=-v |
| 29 | +else |
| 30 | + VERBOSE_FLAG= |
| 31 | +endif |
| 32 | + |
| 33 | +.PHONY: all build test integ-test clean fmt tidy coverage |
| 34 | + |
| 35 | +# Default target |
| 36 | +all: build test |
| 37 | + |
| 38 | +# Build the application |
| 39 | +build: |
| 40 | + @echo "Building application..." |
| 41 | + @$(GOBUILD) ./... |
| 42 | + |
| 43 | +# Run all tests |
| 44 | +test: |
| 45 | + @echo "Running all tests..." |
| 46 | + @$(GOTEST) $(VERBOSE_FLAG) ./... -run $(filter) |
| 47 | + |
| 48 | +# Run only integration tests |
| 49 | +integ-test: |
| 50 | + @echo "Running integration tests..." |
| 51 | + @$(GOTEST) $(VERBOSE_FLAG) ./tests/integration/... -run $(filter) |
| 52 | + |
| 53 | +# Run tests with coverage |
| 54 | +coverage: |
| 55 | + @echo "Running tests with coverage..." |
| 56 | + @mkdir -p $(COVERAGE_DIR) |
| 57 | + @$(GOTEST) -coverprofile=$(COVERAGE_FILE) ./... |
| 58 | + @$(GOCMD) tool cover -html=$(COVERAGE_FILE) -o $(COVERAGE_HTML) |
| 59 | + @echo "Coverage report generated at $(COVERAGE_HTML)" |
| 60 | + |
| 61 | +# Format code |
| 62 | +fmt: |
| 63 | + @echo "Formatting code..." |
| 64 | + @$(GOFMT) ./... |
| 65 | + |
| 66 | +# Update dependencies |
| 67 | +tidy: |
| 68 | + @echo "Updating dependencies..." |
| 69 | + @$(GOMOD) tidy |
| 70 | + |
| 71 | +# Clean build artifacts |
| 72 | +clean: |
| 73 | + @echo "Cleaning build artifacts..." |
| 74 | + @rm -rf $(COVERAGE_DIR) |
| 75 | + @find . -type f -name "*.test" -delete |
| 76 | + |
| 77 | +# Help target |
| 78 | +help: |
| 79 | + @echo "Available targets:" |
| 80 | + @echo " all : Build and run tests" |
| 81 | + @echo " build : Build the application" |
| 82 | + @echo " test : Run all tests" |
| 83 | + @echo " Usage: make test [filter=TestName] [verbose=1]" |
| 84 | + @echo " integ-test : Run integration tests only" |
| 85 | + @echo " Usage: make integ-test [filter=TestName] [verbose=1]" |
| 86 | + @echo " coverage : Generate test coverage report" |
| 87 | + @echo " fmt : Format code" |
| 88 | + @echo " tidy : Update dependencies" |
| 89 | + @echo " clean : Clean build artifacts" |
| 90 | + @echo " help : Show this help message" |
0 commit comments