Skip to content

Commit 8bbb258

Browse files
authored
Merge pull request #82 from cbullinger/docsp-54375-copier-eng
DOCSP-54375: Copier App Enhancements
2 parents 23df6ea + 7230262 commit 8bbb258

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+13375
-220
lines changed

examples-copier/Makefile

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
.PHONY: help build test test-unit test-webhook clean run run-dry install
2+
3+
# Default target
4+
help:
5+
@echo "Examples Copier - Makefile"
6+
@echo ""
7+
@echo "Available targets:"
8+
@echo " make build - Build all binaries"
9+
@echo " make test - Run all tests"
10+
@echo " make test-unit - Run unit tests only"
11+
@echo " make test-webhook - Build webhook test tool"
12+
@echo " make run - Run application"
13+
@echo " make run-dry - Run in dry-run mode"
14+
@echo " make run-local - Run in local dev mode (recommended)"
15+
@echo " make run-local-quick - Quick local run (no cloud logging)"
16+
@echo " make install - Install all tools to \$$GOPATH/bin"
17+
@echo " make clean - Remove built binaries"
18+
@echo ""
19+
@echo "Testing with webhooks:"
20+
@echo " make test-webhook-example - Test with example payload"
21+
@echo " make test-webhook-pr PR=123 OWNER=org REPO=repo - Test with real PR"
22+
@echo ""
23+
@echo "Quick start for local testing:"
24+
@echo " make run-local-quick # Start app (Terminal 1)"
25+
@echo " make test-webhook-example # Send test webhook (Terminal 2)"
26+
@echo ""
27+
28+
# Build all binaries
29+
build:
30+
@echo "Building examples-copier..."
31+
@go build -o examples-copier .
32+
@echo "Building config-validator..."
33+
@go build -o config-validator ./cmd/config-validator
34+
@echo "Building test-webhook..."
35+
@go build -o test-webhook ./cmd/test-webhook
36+
@echo "✓ All binaries built successfully"
37+
38+
# Run all tests
39+
test: test-unit
40+
@echo "✓ All tests passed"
41+
42+
# Run unit tests
43+
test-unit:
44+
@echo "Running unit tests..."
45+
@go test ./services -v
46+
47+
# Run unit tests with coverage
48+
test-coverage:
49+
@echo "Running tests with coverage..."
50+
@go test ./services -coverprofile=coverage.out
51+
@go tool cover -html=coverage.out -o coverage.html
52+
@echo "✓ Coverage report generated: coverage.html"
53+
54+
# Build test-webhook tool
55+
test-webhook:
56+
@echo "Building test-webhook..."
57+
@go build -o test-webhook ./cmd/test-webhook
58+
@echo "✓ test-webhook built"
59+
60+
# Test with example payload
61+
test-webhook-example: test-webhook
62+
@echo "Testing with example payload..."
63+
@./test-webhook -payload test-payloads/example-pr-merged.json
64+
65+
# Test with real PR (requires PR, OWNER, REPO variables)
66+
test-webhook-pr: test-webhook
67+
@if [ -z "$(PR)" ] || [ -z "$(OWNER)" ] || [ -z "$(REPO)" ]; then \
68+
echo "Error: PR, OWNER, and REPO must be set"; \
69+
echo "Usage: make test-webhook-pr PR=123 OWNER=myorg REPO=myrepo"; \
70+
exit 1; \
71+
fi
72+
@./test-webhook -pr $(PR) -owner $(OWNER) -repo $(REPO)
73+
74+
# Test with real PR using helper script
75+
test-pr:
76+
@if [ -z "$(PR)" ]; then \
77+
echo "Error: PR must be set"; \
78+
echo "Usage: make test-pr PR=123"; \
79+
exit 1; \
80+
fi
81+
@./scripts/test-with-pr.sh $(PR)
82+
83+
# Run application
84+
run: build
85+
@echo "Starting examples-copier..."
86+
@./examples-copier
87+
88+
# Run in dry-run mode
89+
run-dry: build
90+
@echo "Starting examples-copier in dry-run mode..."
91+
@DRY_RUN=true ./examples-copier
92+
93+
# Run in local development mode (recommended)
94+
run-local: build
95+
@echo "Starting examples-copier in local development mode..."
96+
@./scripts/run-local.sh
97+
98+
# Run with cloud logging disabled (quick local testing)
99+
run-local-quick: build
100+
@echo "Starting examples-copier (local, no cloud logging)..."
101+
@COPIER_DISABLE_CLOUD_LOGGING=true DRY_RUN=true ./examples-copier
102+
103+
# Validate configuration
104+
validate: build
105+
@echo "Validating configuration..."
106+
@./examples-copier -validate
107+
108+
# Install binaries to $GOPATH/bin
109+
install:
110+
@echo "Installing binaries..."
111+
@go install .
112+
@go install ./cmd/config-validator
113+
@go install ./cmd/test-webhook
114+
@echo "✓ Binaries installed to \$$GOPATH/bin"
115+
116+
# Clean built binaries
117+
clean:
118+
@echo "Cleaning built binaries..."
119+
@rm -f examples-copier config-validator test-webhook
120+
@rm -f coverage.out coverage.html
121+
@echo "✓ Clean complete"
122+
123+
# Format code
124+
fmt:
125+
@echo "Formatting code..."
126+
@go fmt ./...
127+
@echo "✓ Code formatted"
128+
129+
# Run linter
130+
lint:
131+
@echo "Running linter..."
132+
@golangci-lint run ./...
133+
@echo "✓ Linting complete"
134+
135+
# Download dependencies
136+
deps:
137+
@echo "Downloading dependencies..."
138+
@go mod download
139+
@go mod tidy
140+
@echo "✓ Dependencies updated"
141+
142+
# Show version info
143+
version:
144+
@echo "Go version:"
145+
@go version
146+
@echo ""
147+
@echo "Module info:"
148+
@go list -m
149+
150+
# Development setup
151+
dev-setup: deps build
152+
@echo "Setting up development environment..."
153+
@chmod +x scripts/test-with-pr.sh
154+
@echo "✓ Development environment ready"
155+
156+
# Quick test cycle
157+
quick-test: build test-unit
158+
@echo "✓ Quick test cycle complete"
159+
160+
# Full test cycle with webhook testing
161+
full-test: build test-unit test-webhook-example
162+
@echo "✓ Full test cycle complete"
163+

0 commit comments

Comments
 (0)