-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
124 lines (110 loc) · 4.15 KB
/
Makefile
File metadata and controls
124 lines (110 loc) · 4.15 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
.PHONY: build test clean install lint fmt help runner-update vendor-charts
# Binary name
BINARY_NAME=deskrun
INSTALL_PATH=/usr/local/bin
# Runner configuration
RUNNER_NAME?=test-runner
GITHUB_REPO?=rkoster/deskrun
GITHUB_TOKEN?=
# Help target
help:
@echo "Available targets:"
@echo " build - Build the binary"
@echo " build-all - Build for multiple platforms"
@echo " test - Run tests"
@echo " clean - Clean build artifacts"
@echo " install - Install the binary"
@echo " fmt - Format code"
@echo " lint - Run linter"
@echo " check - Run linter and tests"
@echo " dev - Build and run the binary"
@echo " runner-update - Update test runner with Nix and Docker caching (requires gh CLI)"
@echo " vendor-charts - Render and vendor ARC Helm charts to YAML"
@echo " help - Show this help message"
# Build the binary
build:
go build -o $(BINARY_NAME) ./cmd/deskrun
# Build for multiple platforms
build-all:
GOOS=linux GOARCH=amd64 go build -o $(BINARY_NAME)-linux-amd64 ./cmd/deskrun
GOOS=darwin GOARCH=amd64 go build -o $(BINARY_NAME)-darwin-amd64 ./cmd/deskrun
GOOS=darwin GOARCH=arm64 go build -o $(BINARY_NAME)-darwin-arm64 ./cmd/deskrun
# Run tests (excludes upstream/ which contains vendored helm chart tests with external dependencies)
test:
go test -v ./cmd/... ./internal/... ./pkg/...
# Clean build artifacts
clean:
go clean
rm -f $(BINARY_NAME)
rm -f $(BINARY_NAME)-*
# Install the binary
install: build
install -m 755 $(BINARY_NAME) $(INSTALL_PATH)/$(BINARY_NAME)
# Format code
fmt:
go fmt ./...
# Run linter
lint:
go vet ./...
test -z "$$(gofmt -l .)"
# Run all checks
check: lint test
# Development build and run
dev: build
./$(BINARY_NAME)
# Update runner with Docker and user-level Nix caching for this repository
runner-update:
@echo "Updating runner '$(RUNNER_NAME)' for repository '$(GITHUB_REPO)'..."
@echo "Configuration:"
@echo " Runner name: $(RUNNER_NAME)"
@echo " Repository: https://github.com/$(GITHUB_REPO)"
@echo " Mode: cached-privileged-kubernetes"
@echo " Cache paths: /var/lib/docker, /root/.cache/nix"
@echo ""
@GITHUB_TOKEN=$$(gh auth token) && \
echo "Step 1: Bringing down existing runner..." && \
go run ./cmd/deskrun down $(RUNNER_NAME) || true && \
echo "" && \
echo "Step 2: Removing old configuration..." && \
go run ./cmd/deskrun remove $(RUNNER_NAME) || true && \
echo "" && \
echo "Step 3: Adding updated runner configuration..." && \
go run ./cmd/deskrun add $(RUNNER_NAME) \
--repository https://github.com/$(GITHUB_REPO) \
--mode cached-privileged-kubernetes \
--cache /var/lib/docker \
--cache /root/.cache/nix \
--auth-type pat \
--auth-value $$GITHUB_TOKEN && \
echo "" && \
echo "Step 4: Deploying updated runner..." && \
go run ./cmd/deskrun up && \
echo "" && \
echo "Runner updated successfully!"
# Vendor ARC charts using vendir and render them with Helm
vendor-charts:
@echo "Syncing upstream helm charts using vendir..."
vendir sync
@echo ""
@echo "Rendering ARC controller chart..."
@mkdir -p pkg/templates/templates/controller
@helm template arc-controller ./upstream/gha-runner-scale-set-controller \
--namespace arc-systems \
> pkg/templates/templates/controller/rendered.yaml
@echo "ARC controller chart rendered to pkg/templates/templates/controller/rendered.yaml"
@echo ""
@echo "Adding CRDs to controller chart..."
@echo "---" >> pkg/templates/templates/controller/rendered.yaml
@cat ./upstream/gha-runner-scale-set-controller/crds/*.yaml >> pkg/templates/templates/controller/rendered.yaml
@echo "CRDs added to pkg/templates/templates/controller/rendered.yaml"
@echo ""
@echo "Generating base templates for scale-set..."
@./scripts/generate-base-templates.sh
@echo ""
@echo "Updating test expected files..."
@ACCEPT_DIFF=true go test ./internal/runner/template_spec/... ./pkg/templates/...
@echo ""
@echo "Charts synced and base templates generated successfully!"
@echo " - Raw helm charts: upstream/"
@echo " - Controller template: pkg/templates/templates/controller/rendered.yaml"
@echo " - Scale-set base templates: pkg/templates/templates/scale-set/bases/"