-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
121 lines (102 loc) · 3.11 KB
/
Copy pathMakefile
File metadata and controls
121 lines (102 loc) · 3.11 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
.PHONY: build run test clean docker-build docker-run help
# Variables
APP_NAME=goarchive
DOCKER_IMAGE=goarchive:latest
GO_FILES=$(shell find . -name '*.go' -type f)
# Default target
.DEFAULT_GOAL := help
## help: Display this help message
help:
@echo "Available targets:"
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'
## build: Build the application binary
build:
@echo "Building $(APP_NAME)..."
cd cmd/goarchive && go build -o ../../$(APP_NAME) .
## run: Run the application locally
run:
@echo "Running $(APP_NAME)..."
cd cmd/goarchive && go run main.go
## test: Run tests
test:
@echo "Running tests..."
go test -v ./...
## test-coverage: Run tests with coverage
test-coverage:
@echo "Running tests with coverage..."
go test -v -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
## lint: Run linter
lint:
@echo "Running linter..."
golangci-lint run
## fmt: Format code
fmt:
@echo "Formatting code..."
go fmt ./...
gofumpt -l -w .
## tidy: Tidy and verify module dependencies
tidy:
@echo "Tidying dependencies..."
@echo "- Core module..."
go mod tidy
go mod verify
@echo "- Provider modules..."
cd database/postgres && go mod tidy
cd storage/disk && go mod tidy
cd storage/s3 && go mod tidy
@echo "- CLI module..."
cd cmd/goarchive && go mod tidy
@echo "- Example modules..."
cd examples/basic-backup && go mod tidy
cd examples/using-env-config && go mod tidy
@echo "✓ All modules tidied (verify skipped for modules with local replaces)"
## clean: Clean build artifacts
clean:
@echo "Cleaning..."
rm -f $(APP_NAME)
rm -f coverage.out coverage.html
go clean
## docker-build: Build Docker image
docker-build:
@echo "Building Docker image..."
docker build -t $(DOCKER_IMAGE) .
## docker-build-scheduler: Build Docker image with scheduler
docker-build-scheduler:
@echo "Building Docker scheduler image..."
docker build -f Dockerfile.scheduler -t goarchive:scheduler .
## docker-run: Run the application in Docker
docker-run: docker-build
@echo "Running $(APP_NAME) in Docker..."
docker run --rm \
--env-file .env \
$(DOCKER_IMAGE)
## docker-compose-up: Start services with docker-compose
docker-compose-up:
@echo "Starting services..."
docker-compose up -d
## docker-compose-down: Stop services with docker-compose
docker-compose-down:
@echo "Stopping services..."
docker-compose down
## docker-compose-test: Run full test with docker-compose
docker-compose-test:
@echo "Running full test with docker-compose..."
docker-compose up -d postgres localstack
@echo "Waiting for services to be ready..."
sleep 10
@echo "Creating S3 bucket..."
docker-compose run --rm goarchive sh -c '\
aws --endpoint-url=http://localstack:4566 s3 mb s3://backups --region us-east-1 || true'
@echo "Running backup..."
docker-compose run --rm goarchive
docker-compose down
## install-tools: Install development tools
install-tools:
@echo "Installing development tools..."
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
go install mvdan.cc/gofumpt@latest
## deps: Download dependencies
deps:
@echo "Downloading dependencies..."
go mod download