|
| 1 | +.PHONY: help test test-coverage lint fmt vet clean build example docker-arango |
| 2 | + |
| 3 | +# Default target |
| 4 | +help: |
| 5 | + @echo "Available targets:" |
| 6 | + @echo " make test - Run all tests" |
| 7 | + @echo " make test-coverage - Run tests with coverage report" |
| 8 | + @echo " make lint - Run golangci-lint" |
| 9 | + @echo " make fmt - Format code with gofmt" |
| 10 | + @echo " make vet - Run go vet" |
| 11 | + @echo " make clean - Clean build artifacts" |
| 12 | + @echo " make example - Run the basic example" |
| 13 | + @echo " make docker-arango - Start ArangoDB in Docker" |
| 14 | + |
| 15 | +# Run tests |
| 16 | +test: |
| 17 | + @echo "Running tests..." |
| 18 | + go test -v -race ./... |
| 19 | + |
| 20 | +# Run tests with coverage |
| 21 | +test-coverage: |
| 22 | + @echo "Running tests with coverage..." |
| 23 | + go test -v -race -coverprofile=coverage.txt -covermode=atomic ./... |
| 24 | + go tool cover -html=coverage.txt -o coverage.html |
| 25 | + @echo "Coverage report generated: coverage.html" |
| 26 | + |
| 27 | +# Run linter (requires golangci-lint) |
| 28 | +lint: |
| 29 | + @echo "Running linter..." |
| 30 | + @if command -v golangci-lint > /dev/null; then \ |
| 31 | + golangci-lint run ./...; \ |
| 32 | + else \ |
| 33 | + echo "golangci-lint not found. Install it from https://golangci-lint.run/usage/install/"; \ |
| 34 | + fi |
| 35 | + |
| 36 | +# Format code |
| 37 | +fmt: |
| 38 | + @echo "Formatting code..." |
| 39 | + gofmt -w -s . |
| 40 | + |
| 41 | +# Run go vet |
| 42 | +vet: |
| 43 | + @echo "Running go vet..." |
| 44 | + go vet ./... |
| 45 | + |
| 46 | +# Clean build artifacts |
| 47 | +clean: |
| 48 | + @echo "Cleaning..." |
| 49 | + rm -f coverage.txt coverage.html |
| 50 | + go clean -cache -testcache |
| 51 | + |
| 52 | +# Run the basic example |
| 53 | +example: |
| 54 | + @echo "Running basic example..." |
| 55 | + cd examples/basic && go run main.go |
| 56 | + |
| 57 | +# Start ArangoDB in Docker for testing |
| 58 | +docker-arango: |
| 59 | + @echo "Starting ArangoDB in Docker..." |
| 60 | + @docker run -d --name arangodb-test \ |
| 61 | + -e ARANGO_ROOT_PASSWORD=password \ |
| 62 | + -p 8529:8529 \ |
| 63 | + arangodb/arangodb:latest |
| 64 | + @echo "ArangoDB started at http://localhost:8529" |
| 65 | + @echo "Username: root" |
| 66 | + @echo "Password: password" |
| 67 | + @echo "" |
| 68 | + @echo "To stop: docker stop arangodb-test" |
| 69 | + @echo "To remove: docker rm arangodb-test" |
| 70 | + |
| 71 | +# Stop and remove Docker container |
| 72 | +docker-stop: |
| 73 | + @echo "Stopping ArangoDB..." |
| 74 | + @docker stop arangodb-test || true |
| 75 | + @docker rm arangodb-test || true |
0 commit comments