Skip to content

Commit 8970bf5

Browse files
EItanyaclaude
andauthored
refactor: replace Go workspace with single module (#1485)
Remove the go.work multi-module workspace and consolidate go/api, go/core, and go/adk into a single module at go/go.mod. This fixes external import resolution which was broken because Go requires module-prefixed tags (go/api/vX.Y.Z) for multi-module repos, and replace directives are ignored when consumed as a dependency. - Merge three go.mod files into one (github.com/kagent-dev/kagent/go) - Remove go.work, per-module go.mod/go.sum, and replace directives - Simplify Dockerfile to copy single go.mod/go.sum - Simplify Makefile (no more per-module loops) - Update CI cache paths and working directories - Remove go module tagging step from release workflow - Fix pre-existing runtime_test.go probe config expectations --------- Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 791b03a commit 8970bf5

File tree

21 files changed

+272
-2286
lines changed

21 files changed

+272
-2286
lines changed

.github/workflows/ci.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ jobs:
111111
112112
- name: Run e2e tests
113113
if: success()
114-
working-directory: go/core
114+
working-directory: go
115115
run: |
116116
# Get the Kind network gateway IP that pods can reach
117117
HOST_IP=$(docker network inspect kind -f '{{range .IPAM.Config}}{{if .Gateway}}{{.Gateway}}{{"\n"}}{{end}}{{end}}' | grep -E '^[0-9]+\.' | head -1)
@@ -148,12 +148,12 @@ jobs:
148148
with:
149149
go-version: "1.26"
150150
cache: true
151-
cache-dependency-path: go/*/go.sum
151+
cache-dependency-path: go/go.sum
152152

153153
- name: Run Go unit tests
154154
working-directory: go
155155
run: |
156-
go test -race -skip 'TestE2E.*' -v ./api/... ./adk/... ./core/...
156+
go test -race -skip 'TestE2E.*' -v ./...
157157
158158
helm-unit-tests:
159159
env:
@@ -267,12 +267,12 @@ jobs:
267267
with:
268268
go-version: "1.26"
269269
cache: true
270-
cache-dependency-path: go/*/go.sum
270+
cache-dependency-path: go/go.sum
271271
- name: golangci-lint
272272
uses: golangci/golangci-lint-action@v9
273273
with:
274274
version: v2.11.3
275-
working-directory: go/core
275+
working-directory: go
276276

277277
python-test:
278278
env:
@@ -342,7 +342,7 @@ jobs:
342342
with:
343343
go-version: "1.26"
344344
cache: true
345-
cache-dependency-path: go/*/go.sum
345+
cache-dependency-path: go/go.sum
346346

347347
- name: Generate controller manifests
348348
run: make controller-manifests

.github/workflows/tag.yaml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -147,21 +147,6 @@ jobs:
147147
fi
148148
make build-cli
149149
make helm-version
150-
- name: Create Go module tags
151-
if: startsWith(github.ref, 'refs/tags/')
152-
run: |
153-
VERSION=$(echo "$GITHUB_REF" | cut -c12-)
154-
155-
# Create module-prefixed tags for each Go sub-module
156-
for module in api core adk; do
157-
TAG="go/${module}/${VERSION}"
158-
echo "Creating tag: ${TAG}"
159-
git tag "${TAG}"
160-
done
161-
162-
# Push all module tags
163-
git push origin "go/api/${VERSION}" "go/core/${VERSION}" "go/adk/${VERSION}"
164-
165150
- name: Release
166151
uses: softprops/action-gh-release@v2
167152
if: startsWith(github.ref, 'refs/tags/')

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ test_results
2323
# Dependency directories (remove the comment below to include it)
2424
# vendor/
2525

26-
# Go workspace file
27-
go.work
28-
2926
# Go CLI binary
3027
go/cli/bin/*
3128

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ KAGENT_ADK_IMG ?= $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(KAGENT_ADK_IMAGE_NAME):$(K
5252
GOLANG_ADK_IMG ?= $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(GOLANG_ADK_IMAGE_NAME):$(GOLANG_ADK_IMAGE_TAG)
5353
SKILLS_INIT_IMG ?= $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(SKILLS_INIT_IMAGE_NAME):$(SKILLS_INIT_IMAGE_TAG)
5454

55-
#take from go/core/go.mod
55+
#take from go/go.mod
5656
AWK ?= $(shell command -v gawk || command -v awk)
57-
TOOLS_GO_VERSION ?= $(shell $(AWK) '/^go / { print $$2 }' go/core/go.mod)
57+
TOOLS_GO_VERSION ?= $(shell $(AWK) '/^go / { print $$2 }' go/go.mod)
5858
export GOTOOLCHAIN=go$(TOOLS_GO_VERSION)
5959

6060
# Version information for the build
@@ -105,7 +105,7 @@ init-git-hooks: ## Use the tracked version of Git hooks from this repo
105105

106106
# KMCP
107107
KMCP_ENABLED ?= true
108-
KMCP_VERSION ?= $(shell $(AWK) '/github\.com\/kagent-dev\/kmcp/ { print substr($$2, 2) }' go/core/go.mod) # KMCP version defaults to what's referenced in go.mod
108+
KMCP_VERSION ?= $(shell $(AWK) '/github\.com\/kagent-dev\/kmcp/ { print substr($$2, 2) }' go/go.mod) # KMCP version defaults to what's referenced in go.mod
109109

110110
HELM_ACTION=upgrade --install
111111

go/Dockerfile

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,13 @@ ARG BUILDPLATFORM
1010
ARG BUILD_PACKAGE=core/cmd/controller/main.go
1111

1212
WORKDIR /workspace
13-
# Copy the Go workspace and all module manifests
14-
COPY go.work .
15-
COPY api/go.mod api/go.sum api/
16-
COPY core/go.mod core/go.sum core/
17-
COPY adk/go.mod adk/go.sum adk/
13+
# Copy the Go module manifests
14+
COPY go.mod go.sum .
1815
# cache deps before building and copying source so that we don't need to re-download as much
1916
# and so that source changes don't invalidate our downloaded layer
2017
RUN --mount=type=cache,target=/root/go/pkg/mod,rw \
2118
--mount=type=cache,target=/root/.cache/go-build,rw \
22-
go work sync && go mod download
19+
go mod download
2320
# Copy all source
2421
COPY api/ api/
2522
COPY core/ core/

go/Makefile

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,68 +29,65 @@ manifests: controller-gen generate ## Generate ClusterRole and CustomResourceDef
2929
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
3030
$(CONTROLLER_GEN) object:headerFile="api/hack/boilerplate.go.txt" paths="./api/..."
3131

32-
## Workspace modules
33-
MODULES := api core adk
34-
3532
##@ Development
3633

3734
.PHONY: fmt
38-
fmt: ## Run go fmt against all modules.
39-
@for m in $(MODULES); do echo "fmt $$m"; (cd $$m && go fmt ./...); done
35+
fmt: ## Run go fmt.
36+
go fmt ./...
4037

4138
.PHONY: vet
42-
vet: ## Run go vet against all modules.
43-
@for m in $(MODULES); do echo "vet $$m"; (cd $$m && go vet ./...); done
39+
vet: ## Run go vet.
40+
go vet ./...
4441

4542
.PHONY: lint
46-
lint: golangci-lint ## Run golangci-lint against all modules.
47-
@for m in $(MODULES); do echo "lint $$m"; (cd $$m && $(GOLANGCI_LINT) run) || exit 1; done
43+
lint: golangci-lint ## Run golangci-lint.
44+
$(GOLANGCI_LINT) run
4845

4946
.PHONY: lint-fix
50-
lint-fix: golangci-lint ## Run golangci-lint with auto-fix against all modules.
51-
@for m in $(MODULES); do echo "lint-fix $$m"; (cd $$m && $(GOLANGCI_LINT) run --fix) || exit 1; done
47+
lint-fix: golangci-lint ## Run golangci-lint with auto-fix.
48+
$(GOLANGCI_LINT) run --fix
5249

5350
.PHONY: lint-config
5451
lint-config: golangci-lint ## Verify golangci-lint linter configuration.
55-
@for m in $(MODULES); do echo "lint-config $$m"; (cd $$m && $(GOLANGCI_LINT) config verify) || exit 1; done
52+
$(GOLANGCI_LINT) config verify
5653

5754
.PHONY: govulncheck
58-
govulncheck: ## Run govulncheck against all modules.
55+
govulncheck: ## Run govulncheck.
5956
$(call go-install-tool,bin/govulncheck,golang.org/x/vuln/cmd/govulncheck,latest)
60-
@for m in $(MODULES); do echo "govulncheck $$m"; (cd $$m && go mod tidy -v && ../bin/govulncheck-latest ./...) || exit 1; done
57+
go mod tidy -v && bin/govulncheck-latest ./...
6158

6259
##@ Build (core module — CLI binaries)
6360

6461
core/bin/kagent-local:
65-
cd core && CGO_ENABLED=0 go test -race ./cli/...
66-
cd core && CGO_ENABLED=0 go build -ldflags "$(LDFLAGS)" -o bin/kagent-local ./cli/cmd/kagent
62+
go test -race ./core/cli/...
63+
CGO_ENABLED=0 go build -ldflags "$(LDFLAGS)" -o core/bin/kagent-local ./core/cli/cmd/kagent
6764

6865
core/bin/kagent-linux-amd64:
69-
cd core && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o bin/kagent-linux-amd64 ./cli/cmd/kagent
66+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o core/bin/kagent-linux-amd64 ./core/cli/cmd/kagent
7067

7168
core/bin/kagent-linux-amd64.sha256: core/bin/kagent-linux-amd64
7269
sha256sum core/bin/kagent-linux-amd64 > core/bin/kagent-linux-amd64.sha256
7370

7471
core/bin/kagent-linux-arm64:
75-
cd core && CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -o bin/kagent-linux-arm64 ./cli/cmd/kagent
72+
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -o core/bin/kagent-linux-arm64 ./core/cli/cmd/kagent
7673

7774
core/bin/kagent-linux-arm64.sha256: core/bin/kagent-linux-arm64
7875
sha256sum core/bin/kagent-linux-arm64 > core/bin/kagent-linux-arm64.sha256
7976

8077
core/bin/kagent-darwin-amd64:
81-
cd core && CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o bin/kagent-darwin-amd64 ./cli/cmd/kagent
78+
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o core/bin/kagent-darwin-amd64 ./core/cli/cmd/kagent
8279

8380
core/bin/kagent-darwin-amd64.sha256: core/bin/kagent-darwin-amd64
8481
sha256sum core/bin/kagent-darwin-amd64 > core/bin/kagent-darwin-amd64.sha256
8582

8683
core/bin/kagent-darwin-arm64:
87-
cd core && CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -o bin/kagent-darwin-arm64 ./cli/cmd/kagent
84+
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -o core/bin/kagent-darwin-arm64 ./core/cli/cmd/kagent
8885

8986
core/bin/kagent-darwin-arm64.sha256: core/bin/kagent-darwin-arm64
9087
sha256sum core/bin/kagent-darwin-arm64 > core/bin/kagent-darwin-arm64.sha256
9188

9289
core/bin/kagent-windows-amd64.exe:
93-
cd core && CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o bin/kagent-windows-amd64.exe ./cli/cmd/kagent
90+
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o core/bin/kagent-windows-amd64.exe ./core/cli/cmd/kagent
9491

9592
core/bin/kagent-windows-amd64.exe.sha256: core/bin/kagent-windows-amd64.exe
9693
sha256sum core/bin/kagent-windows-amd64.exe > core/bin/kagent-windows-amd64.exe.sha256
@@ -104,15 +101,15 @@ build: core/bin/kagent-linux-amd64.sha256 core/bin/kagent-linux-arm64.sha256 cor
104101

105102
.PHONY: run
106103
run: fmt vet ## Run a controller from your host.
107-
cd core && go run ./cmd/controller/main.go
104+
go run ./core/cmd/controller/main.go
108105

109106
.PHONY: test
110-
test: ## Run all unit tests across the workspace.
111-
UPDATE_GOLDEN=$(UPDATE_GOLDEN) go test -race -skip 'TestE2E.*' -v ./api/... ./core/... ./adk/...
107+
test: ## Run all unit tests.
108+
UPDATE_GOLDEN=$(UPDATE_GOLDEN) go test -race -skip 'TestE2E.*' -v ./...
112109

113110
.PHONY: e2e
114111
e2e: ## Run end-to-end tests.
115-
cd core && go test -v github.com/kagent-dev/kagent/go/core/test/e2e -failfast
112+
go test -v github.com/kagent-dev/kagent/go/core/test/e2e -failfast
116113

117114
##@ Dependencies
118115

@@ -130,9 +127,9 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
130127
## Tool Versions
131128
CONTROLLER_TOOLS_VERSION ?= v0.19.0
132129
#ENVTEST_VERSION is the version of controller-runtime release branch to fetch the envtest setup script (i.e. release-0.20)
133-
ENVTEST_VERSION ?= $(shell cd core && go list -m -f "{{ .Version }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-%d.%d", $$2, $$3}')
130+
ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-%d.%d", $$2, $$3}')
134131
#ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries (i.e. 1.31)
135-
ENVTEST_K8S_VERSION ?= $(shell cd core && go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.%d", $$3}')
132+
ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.%d", $$3}')
136133
GOLANGCI_LINT_VERSION ?= v2.10.1
137134

138135
.PHONY: controller-gen

go/adk/go.mod

Lines changed: 0 additions & 89 deletions
This file was deleted.

0 commit comments

Comments
 (0)