-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathMakefile
More file actions
151 lines (124 loc) · 4.99 KB
/
Copy pathMakefile
File metadata and controls
151 lines (124 loc) · 4.99 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
# Copyright 2026 The MatrixHub Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
GO_CMD ?= go
GIT_TAG ?= $(shell git describe --tags --dirty --always)
GIT_COMMIT ?= $(shell git rev-parse HEAD)
GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
PLATFORMS ?=
IMAGE_BUILD_CMD ?= docker buildx build
IMAGE_REPO := ghcr.io/matrixhub-ai/matrixhub
VERSION ?= $(GIT_TAG)
BASE_IMAGE_PREFIX ?= docker.io
NPM_CONFIG_REGISTRY ?= https://registry.npmjs.org
GOPROXY ?= https://proxy.golang.org,direct
HTTP_PROXY ?=
HTTPS_PROXY ?=
version_pkg = github.com/matrixhub-ai/matrixhub/pkg/version
LD_FLAGS += -X '$(version_pkg).GitVersion=$(GIT_TAG)'
LD_FLAGS += -X '$(version_pkg).GitCommit=$(GIT_COMMIT)'
LD_FLAGS += -X '$(version_pkg).BuildDate=$(shell date -u +%Y-%m-%dT%H:%M:%SZ)'
PUSH ?= --load
.PHONY: all
all: help
##@ General
# The help target prints out all targets with their descriptions organized
# beneath their categories. The categories are represented by '##@' and the
# target descriptions by '##'. The awk commands is responsible for reading the
# entire set of makefiles included in this invocation, looking for lines of the
# file as xyz: ## something, and then pretty-format the target and help. Then,
# if there's a line with ##@ something, that gets pretty-printed as a category.
# More info on the usage of ANSI control characters for terminal formatting:
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
# More info on the awk command:
# http://linuxcommand.org/lc3_adv_awk.php
.PHONY: help
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-24s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
.PHONY: lint-fix
lint-fix: ## Run golangci-lint with --fix option
$(GO_CMD) run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.8.0 run --fix
.PHONY: image-build
image-build: ## Build the MatrixHub image
$(IMAGE_BUILD_CMD) \
-t $(IMAGE_REPO):$(VERSION) \
-f deploy/docker/matrixhub/Dockerfile \
$(if $(PLATFORMS),--platform=$(PLATFORMS)) \
--build-arg GOPROXY="$(GOPROXY)" \
--build-arg HTTP_PROXY="$(HTTP_PROXY)" \
--build-arg HTTPS_PROXY="$(HTTPS_PROXY)" \
--build-arg BASE_IMAGE_PREFIX="$(BASE_IMAGE_PREFIX)" \
$(PUSH) \
$(IMAGE_BUILD_EXTRA_OPTS) \
.
.PHONY: image-push
image-push: ## Build and push the MatrixHub image
$(MAKE) image-build PUSH=--push
website/build: website
make -C website build
.PHONY: serve-website
serve-website: ## Run documentation website locally
make -C website serve
.PHONY: clean
clean: ## Clean all build artifacts
rm -rf bin
make -C website clean
.PHONY: local-run-web
local-run-web: ## Run web frontend locally
cd ui && pnpm i && pnpm dev
.PHONY: local-run-api
local-run-api: ## Serve the API only
go run ./cmd/matrixhub apiserver
##@ E2E Testing
.PHONY: deploy.kind-cluster
deploy.kind-cluster: ## Setup KIND cluster
./scripts/setup-kind-cluster.sh
.PHONY: deploy.matrixhub
deploy.matrixhub: ## Deploy MatrixHub to KIND cluster
./scripts/deploy-matrixhub.sh
.PHONY: kind.setup
kind.setup: deploy.kind-cluster deploy.matrixhub ## Setup KIND cluster and deploy MatrixHub
.PHONY: test.e2e
test.e2e: ## Run E2E tests locally (requires running MatrixHub)
$(eval level ?= "smoke")
@bash ./scripts/run-test.sh $(level) smoke $(MATRIXHUB_BASE_URL)
.PHONY: test.e2e.kind
test.e2e.kind: ## Run E2E tests in KIND cluster (setup, deploy, test)
@echo "================================================"
@echo "MatrixHub Kind E2E Test Workflow"
@echo "================================================"
@echo ""
@echo "Environment variables:"
@echo " E2E_CLUSTER_NAME = $${E2E_CLUSTER_NAME:-matrixhub-e2e}"
@echo " E2E_KIND_IMAGE_TAG = $${E2E_KIND_IMAGE_TAG:-v1.32.3}"
@echo " E2E_MATRIXHUB_IMAGE = $${E2E_MATRIXHUB_IMAGE:-ghcr.io/matrixhub-ai/matrixhub:latest}"
@echo ""
@echo "Step 1: Setting up KIND cluster and deploying MatrixHub..."
$(MAKE) kind.setup
@echo ""
@echo "Step 2: Running E2E tests..."
MATRIXHUB_BASE_URL="http://localhost:30001" $(MAKE) test.e2e
@echo ""
@echo "To cleanup, run:"
@echo " kind delete cluster --name=$${E2E_CLUSTER_NAME:-matrixhub-e2e}"
@echo ""
.PHONY: chart.build
chart.build: ## Build Helm chart package
helm package ./deploy/charts/matrixhub -d ./deploy/charts
.PHONY: genproto
genproto:
@./scripts/update-proto-gen.sh
# Generate HTTP client SDK for testing. Output: test/client. Run when swagger changes.
.PHONY: gen_openapi_sdk
gen_openapi_sdk:
@./scripts/gen_openapi_sdk.sh