Skip to content

Commit 13294d3

Browse files
authored
feat(agent): bootstrap agent go rewrite (#230)
Signed-off-by: Riley Rice <riceriley59@gmail.com>
1 parent d5c5474 commit 13294d3

11 files changed

Lines changed: 276 additions & 0 deletions

File tree

.github/workflows/agent-ci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ on:
2121
- main
2222
paths:
2323
- agent/**
24+
- '!agent/go/**'
2425
- containers/agent.Dockerfile
2526
- .github/workflows/agent-ci.yaml
2627
push:
@@ -30,6 +31,7 @@ on:
3031
- agent/*
3132
paths:
3233
- agent/**
34+
- '!agent/go/**'
3335
- containers/agent.Dockerfile
3436
- .github/workflows/agent-ci.yaml
3537
env:

.github/workflows/agent-go-ci.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
name: Agent Go CI
18+
on:
19+
pull_request:
20+
branches:
21+
- main
22+
paths:
23+
- agent/go/**
24+
- .github/workflows/agent-go-ci.yaml
25+
push:
26+
branches:
27+
- main
28+
paths:
29+
- agent/go/**
30+
- .github/workflows/agent-go-ci.yaml
31+
32+
env:
33+
GO_VERSION: 1.26.3
34+
35+
jobs:
36+
test:
37+
name: Agent Go Unit Tests
38+
runs-on: ubuntu-latest
39+
steps:
40+
- uses: actions/checkout@v6
41+
- name: Set up Go ${{ env.GO_VERSION }}
42+
uses: actions/setup-go@v6
43+
with:
44+
go-version: ${{ env.GO_VERSION }}
45+
cache-dependency-path: agent/go/go.sum
46+
- name: Run tests
47+
run: |
48+
cd agent/go
49+
go test ./...
50+
51+
lint:
52+
name: Agent Go Lint
53+
runs-on: ubuntu-latest
54+
steps:
55+
- uses: actions/checkout@v6
56+
- name: Set up Go ${{ env.GO_VERSION }}
57+
uses: actions/setup-go@v6
58+
with:
59+
go-version: ${{ env.GO_VERSION }}
60+
cache-dependency-path: agent/go/go.sum
61+
- name: Run golangci-lint
62+
uses: golangci/golangci-lint-action@v8
63+
with:
64+
version: v2.12.2
65+
working-directory: agent/go

agent/.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
go/
12
venv
23
root_mount
34
root

agent/go/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bin/

agent/go/.golangci.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
version: "2"
18+
run:
19+
modules-download-mode: readonly
20+
allow-parallel-runners: true
21+
linters:
22+
default: none
23+
enable:
24+
- copyloopvar
25+
- dupl
26+
- errcheck
27+
- goconst
28+
- gocyclo
29+
- govet
30+
- ineffassign
31+
- lll
32+
- misspell
33+
- nakedret
34+
- prealloc
35+
- staticcheck
36+
- unconvert
37+
- unparam
38+
- unused
39+
settings:
40+
lll:
41+
line-length: 200
42+
staticcheck:
43+
checks:
44+
- all
45+
- -ST1000
46+
- -ST1003
47+
- -ST1016
48+
- -ST1021
49+
- -QF1008
50+
exclusions:
51+
generated: lax
52+
rules:
53+
- linters:
54+
- dupl
55+
- goconst
56+
- prealloc
57+
path: _test\.go
58+
paths:
59+
- third_party$
60+
- builtin$
61+
- examples$
62+
formatters:
63+
enable:
64+
- gofmt
65+
- goimports
66+
exclusions:
67+
generated: lax
68+
paths:
69+
- third_party$
70+
- builtin$
71+
- examples$

agent/go/Makefile

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
include deps.mk
18+
19+
SHELL = /usr/bin/env bash -o pipefail
20+
.SHELLFLAGS = -ec
21+
22+
GO ?= go
23+
BINARY_DIR ?= ./bin
24+
AGENT_BINARY ?= $(BINARY_DIR)/agent
25+
26+
.PHONY: all
27+
all: build
28+
29+
##@ General
30+
.PHONY: help
31+
help: ## Display this help.
32+
@awk 'BEGIN {FS = ":.*##"; printf "\n\033[1;31mUsage:\033[0m\n make \033[3;1;36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1;31m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
33+
34+
##@ Development
35+
.PHONY: license-fmt
36+
license-fmt: ## Run license header formatting for changed files.
37+
python3 ../../scripts/format_license.py --root-dir . --license-file ../../LICENSE
38+
39+
.PHONY: fmt
40+
fmt: license-fmt ## Format go files and update license headers.
41+
$(GO) fmt ./...
42+
43+
.PHONY: vet
44+
vet: ## Run go vet against code.
45+
$(GO) vet ./...
46+
47+
.PHONY: test
48+
test: ## Run unit tests.
49+
$(GO) test ./...
50+
51+
.PHONY: lint
52+
lint: golangci-lint ## Run golangci-lint.
53+
$(GOLANGCI_LINT) run ./...
54+
55+
.PHONY: lint-fix
56+
lint-fix: golangci-lint ## Run golangci-lint and apply fixes.
57+
$(GOLANGCI_LINT) run --fix ./...
58+
59+
##@ Build
60+
.PHONY: build
61+
build: ## Build agent binary.
62+
mkdir -p $(BINARY_DIR)
63+
$(GO) build -o $(AGENT_BINARY) ./cmd/agent
64+
65+
##@ Clean
66+
.PHONY: clean
67+
clean: ## Remove local build artifacts.
68+
rm -rf $(BINARY_DIR)
69+
rm -rf $(LOCALBIN)

agent/go/cmd/agent/main.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package main
19+
20+
import (
21+
"fmt"
22+
)
23+
24+
func main() {
25+
fmt.Println("Hello, World!")
26+
}

agent/go/deps.mk

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
## this makefile is for installing deps and controlling the versioning
18+
## its included in the main makefile, but its a lot to look at these
19+
## plus ci can watch this file to know to build a new build image
20+
21+
GOLANGCI_LINT_VERSION ?= v2.12.2
22+
23+
## Location to install dependencies to
24+
LOCALBIN ?= $(shell pwd)/bin
25+
$(LOCALBIN):
26+
mkdir -p $(LOCALBIN)
27+
28+
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
29+
30+
.PHONY: install-deps
31+
install-deps: golangci-lint ## Install all dependencies.
32+
33+
.PHONY: golangci-lint
34+
golangci-lint: $(LOCALBIN) ## Download golangci-lint locally if necessary.
35+
@[ -f $(GOLANGCI_LINT) ] || { \
36+
set -e ;\
37+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/$(GOLANGCI_LINT_VERSION)/install.sh | sh -s -- -b $(shell dirname $(GOLANGCI_LINT)) $(GOLANGCI_LINT_VERSION) ;\
38+
}

agent/go/go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/NVIDIA/nodewright/agent
2+
3+
go 1.26.3

agent/go/go.sum

Whitespace-only changes.

0 commit comments

Comments
 (0)