-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
153 lines (129 loc) · 5.51 KB
/
Makefile
File metadata and controls
153 lines (129 loc) · 5.51 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
.PHONY: help build build-all build-gitlab build-github build-bitbucket build-devops build-gitea build-circle test test-unit test-e2e lint clean coverage coverage-html serve-docs
# Default target
help:
@echo "Pipeleek Makefile"
@echo ""
@echo "Available targets:"
@echo " make build - Build the main pipeleek binary"
@echo " make build-all - Build all binaries (main + platform-specific)"
@echo " make build-gitlab - Build GitLab-specific binary"
@echo " make build-github - Build GitHub-specific binary"
@echo " make build-bitbucket - Build BitBucket-specific binary"
@echo " make build-devops - Build Azure DevOps-specific binary"
@echo " make build-gitea - Build Gitea-specific binary"
@echo " make build-circle - Build CircleCI-specific binary"
@echo " make test - Run all tests (unit + e2e)"
@echo " make test-unit - Run unit tests only"
@echo " make test-e2e - Run e2e tests (builds binary first)"
@echo " make coverage - Generate test coverage report"
@echo " make coverage-html - Generate and open HTML coverage report"
@echo " make lint - Run golangci-lint"
@echo " make serve-docs - Generate and serve CLI documentation"
@echo " make clean - Remove built artifacts"
# Build flags to reduce binary size (strip symbols, debug info, and file paths)
GO_BUILD_FLAGS = -trimpath -ldflags="-s -w"
# Build the main pipeleek binary
build:
@echo "Building pipeleek..."
CGO_ENABLED=0 go build $(GO_BUILD_FLAGS) -o pipeleek ./cmd/pipeleek
# Build GitLab-specific binary
build-gitlab:
@echo "Building pipeleek-gitlab..."
CGO_ENABLED=0 go build $(GO_BUILD_FLAGS) -o pipeleek-gitlab ./cmd/pipeleek-gitlab
# Build GitHub-specific binary
build-github:
@echo "Building pipeleek-github..."
CGO_ENABLED=0 go build $(GO_BUILD_FLAGS) -o pipeleek-github ./cmd/pipeleek-github
# Build BitBucket-specific binary
build-bitbucket:
@echo "Building pipeleek-bitbucket..."
CGO_ENABLED=0 go build $(GO_BUILD_FLAGS) -o pipeleek-bitbucket ./cmd/pipeleek-bitbucket
# Build Azure DevOps-specific binary
build-devops:
@echo "Building pipeleek-devops..."
CGO_ENABLED=0 go build $(GO_BUILD_FLAGS) -o pipeleek-devops ./cmd/pipeleek-devops
# Build Gitea-specific binary
build-gitea:
@echo "Building pipeleek-gitea..."
CGO_ENABLED=0 go build $(GO_BUILD_FLAGS) -o pipeleek-gitea ./cmd/pipeleek-gitea
# Build CircleCI-specific binary
build-circle:
@echo "Building pipeleek-circle..."
CGO_ENABLED=0 go build $(GO_BUILD_FLAGS) -o pipeleek-circle ./cmd/pipeleek-circle
# Build all binaries
build-all: build build-gitlab build-github build-bitbucket build-devops build-gitea build-circle
@echo "All binaries built successfully"
# Run all tests
test: test-unit test-e2e
# Run unit tests (excluding e2e)
test-unit:
@echo "Running unit tests..."
go test $$(go list ./... | grep -v /tests/e2e) -v -race
# Run e2e tests (builds binary first)
test-e2e: build
@echo "Running e2e tests..."
PIPELEEK_BINARY=$$(pwd)/pipeleek go test ./tests/e2e/... -tags=e2e -v -timeout 10m
# Run e2e tests for specific platform
test-e2e-gitlab: build
@echo "Running GitLab e2e tests..."
PIPELEEK_BINARY=$$(pwd)/pipeleek go test ./tests/e2e/gitlab/... -tags=e2e -v
test-e2e-github: build
@echo "Running GitHub e2e tests..."
PIPELEEK_BINARY=$$(pwd)/pipeleek go test ./tests/e2e/github/... -tags=e2e -v
test-e2e-bitbucket: build
@echo "Running BitBucket e2e tests..."
PIPELEEK_BINARY=$$(pwd)/pipeleek go test ./tests/e2e/bitbucket/... -tags=e2e -v
test-e2e-devops: build
@echo "Running Azure DevOps e2e tests..."
PIPELEEK_BINARY=$$(pwd)/pipeleek go test ./tests/e2e/devops/... -tags=e2e -v
test-e2e-gitea: build
@echo "Running Gitea e2e tests..."
PIPELEEK_BINARY=$$(pwd)/pipeleek go test ./tests/e2e/gitea/... -tags=e2e -v
test-e2e-circle: build
@echo "Running CircleCI e2e tests..."
PIPELEEK_BINARY=$$(pwd)/pipeleek go test ./tests/e2e/circle/... -tags=e2e -v
# Generate test coverage report
coverage:
@echo "Generating coverage report..."
@go test $$(go list ./... | grep -v /tests/e2e) -coverprofile=coverage.out -covermode=atomic
@echo ""
@echo "Coverage Summary:"
@go tool cover -func=coverage.out | grep total | awk '{print "Total Coverage: " $$3}'
@echo ""
@echo "Coverage report saved to coverage.out"
@echo "Run 'make coverage-html' to view detailed HTML report"
# Generate and open HTML coverage report
coverage-html: coverage
@echo "Generating HTML coverage report..."
@go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report saved to coverage.html"
@if command -v xdg-open > /dev/null; then \
xdg-open coverage.html; \
elif command -v open > /dev/null; then \
open coverage.html; \
else \
echo "Open coverage.html in your browser to view the report"; \
fi
# Run golangci-lint
lint:
@echo "Running golangci-lint..."
golangci-lint run --timeout=10m
# Generate and serve CLI documentation
serve-docs: build
@echo "Generating and serving CLI documentation..."
@if ! command -v mkdocs > /dev/null 2>&1; then \
echo "MkDocs not found. Installing MkDocs and dependencies..."; \
pip install mkdocs mkdocs-material mkdocs-minify-plugin; \
fi
./pipeleek docs -s
# Clean up built artifacts
clean:
@echo "Cleaning up..."
rm -f pipeleek pipeleek.exe coverage.out coverage.html
rm -f pipeleek-gitlab pipeleek-gitlab.exe
rm -f pipeleek-github pipeleek-github.exe
rm -f pipeleek-bitbucket pipeleek-bitbucket.exe
rm -f pipeleek-devops pipeleek-devops.exe
rm -f pipeleek-gitea pipeleek-gitea.exe
rm -f pipeleek-circle pipeleek-circle.exe
go clean -cache -testcache