Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/legacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ jobs:
go-version: '1.24.0'
cache: true
- name: Release test
run: make build
run: make build-cross
11 changes: 9 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ on:
tags:
- "v*"

env:
# Go module path for Docker mount (must match go.mod module).
BREV_MODULE: github.com/brevdev/brev-cli
# goreleaser-cross image with cross-compilers for CGO (see https://goreleaser.com/limitations/cgo/#using-docker).
GOLANG_CROSS_VERSION: v1.25.7

jobs:
goreleaser:
runs-on: ubuntu-22.04
Expand All @@ -17,8 +23,9 @@ jobs:
with:
go-version: '1.24.0'
cache: true
- name: Release
run: make ci smoke-test release

- name: CI, smoke-test, and release
run: make ci smoke-test release-cross
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
# disable until this until figure out tags
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ dist/
# .env
.env
.envrc
.release-env

# binary
brev-cli
Expand Down
3 changes: 2 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
version: 2
before:
hooks:
- go mod download
builds:
- env:
- CGO_ENABLED=0
- CGO_ENABLED=1
goos:
- darwin
- linux
Expand Down
60 changes: 54 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,39 @@
.DEFAULT_GOAL := fast-build
VERSION := dev-$(shell git rev-parse HEAD | cut -c 1-8)

# Cross-compilation via Docker (golang:1.24 native Linux container).
# When arch=<GOOS>/<GOARCH> is provided, spin up a container that matches
# the target platform so CGO uses the native Linux gcc/GNU ld toolchain
_GOMODCACHE := $(shell go env GOMODCACHE)
ifdef arch
_CROSS_GOOS := $(word 1,$(subst /, ,$(arch)))
_CROSS_GOARCH := $(word 2,$(subst /, ,$(arch)))
_BUILD_PREFIX := docker run --rm \
--platform $(_CROSS_GOOS)/$(_CROSS_GOARCH) \
-v $(CURDIR):/app \
-v $(_GOMODCACHE):/go/pkg/mod \
-e CGO_ENABLED=1 \
-e GOPRIVATE=github.com/brevdev/* \
-e GONOSUMDB=github.com/brevdev/* \
-w /app \
golang:1.24
else
_BUILD_PREFIX := CGO_ENABLED=1
endif

.PHONY: fast-build
fast-build: ## go build -o brev
$(call print-target)
echo ${VERSION}
CGO_ENABLED=0 go build -o brev -ldflags "-X github.com/brevdev/brev-cli/pkg/cmd/version.Version=${VERSION}"
CGO_ENABLED=1 go build -o brev -ldflags "-X github.com/brevdev/brev-cli/pkg/cmd/version.Version=${VERSION}"

.PHONY: local
local: ## build with env wrapper (use: make local env=dev0|dev1|dev2|stg arch=linux/amd64, or make local for defaults)
$(call print-target)
ifdef env
@echo "Building with env=$(env) wrapper..."
@echo ${VERSION}
$(if $(arch),GOOS=$(word 1,$(subst /, ,$(arch))) GOARCH=$(word 2,$(subst /, ,$(arch))),) CGO_ENABLED=0 go build -o brev-local -ldflags "-X github.com/brevdev/brev-cli/pkg/cmd/version.Version=${VERSION}"
$(_BUILD_PREFIX) go build -o brev-local -ldflags "-X github.com/brevdev/brev-cli/pkg/cmd/version.Version=${VERSION}"
@echo '#!/bin/sh' > brev
@echo '# Auto-generated wrapper with environment overrides' >> brev
@echo 'export BREV_CONSOLE_URL="https://localhost.nvidia.com:3000"' >> brev
Expand All @@ -26,7 +46,7 @@ ifdef env
@chmod +x brev
else
@echo "Building without environment overrides (using config.go defaults)..."
$(if $(arch),GOOS=$(word 1,$(subst /, ,$(arch))) GOARCH=$(word 2,$(subst /, ,$(arch))),) CGO_ENABLED=0 go build -o brev -ldflags "-X github.com/brevdev/brev-cli/pkg/cmd/version.Version=${VERSION}"
$(_BUILD_PREFIX) go build -o brev -ldflags "-X github.com/brevdev/brev-cli/pkg/cmd/version.Version=${VERSION}"
endif

.PHONY: install-dev
Expand Down Expand Up @@ -108,14 +128,42 @@ diff: ## git diff
build: ## goreleaser --snapshot --skip-publish --rm-dist
build: install-tools
$(call print-target)
goreleaser --snapshot --skip-publish --rm-dist
goreleaser --snapshot --skip=publish --clean

.PHONY: release
release: ## goreleaser --rm-dist
release: install-tools
$(call print-target)
goreleaser --rm-dist

# Docker-based build/release using goreleaser-cross (CGO cross-compile; see https://goreleaser.com/limitations/cgo/#using-docker).
GOLANG_CROSS_VERSION ?= v1.25.7
BREV_MODULE ?= github.com/brevdev/brev-cli

.PHONY: build-cross
build-cross: ## run goreleaser snapshot inside goreleaser-cross Docker (CGO builds for all targets)
$(call print-target)
docker run --rm \
-e CGO_ENABLED=1 \
-v "$$(pwd):/go/src/$(BREV_MODULE)" \
-w "/go/src/$(BREV_MODULE)" \
ghcr.io/goreleaser/goreleaser-cross:$(GOLANG_CROSS_VERSION) \
--clean --skip=validate --skip=publish

.PHONY: release-cross
release-cross: ## run goreleaser release inside goreleaser-cross Docker. Set GITHUB_TOKEN or create .release-env.
$(call print-target)
docker run --rm \
-e CGO_ENABLED=1 \
-e GOPRIVATE=github.com/brevdev/* \
-e GONOSUMDB=github.com/brevdev/* \
-e "GITHUB_TOKEN=$$GITHUB_TOKEN" \
-v "$$HOME/.gitconfig:/root/.gitconfig:ro" \
-v "$$(pwd):/go/src/$(BREV_MODULE)" \
-w "/go/src/$(BREV_MODULE)" \
ghcr.io/goreleaser/goreleaser-cross:$(GOLANG_CROSS_VERSION) \
release --clean; \

.PHONY: run
run: ## go run
@go run -race .
Expand Down Expand Up @@ -305,8 +353,8 @@ develop-with-nix:
update-devplane-deps: ## update devplane dependencies (use: make update-devplane-deps commit=<hash-or-tag>, defaults to latest)
@COMMIT=$${commit:-latest}; \
echo "Updating devplane dependencies to: $$COMMIT"; \
go get -u github.com/brevdev/dev-plane@$$COMMIT; \
GOPRIVATE=github.com/brevdev/* go get -u github.com/brevdev/dev-plane@$$COMMIT; \
go get buf.build/gen/go/brevdev/devplane/grpc/go@$$COMMIT; \
go get buf.build/gen/go/brevdev/devplane/protocolbuffers/go@$$COMMIT; \
go mod tidy; \
GOPRIVATE=github.com/brevdev/* go mod tidy; \
echo "Successfully updated to $$COMMIT"
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ go 1.24.0

require (
buf.build/gen/go/brevdev/devplane/connectrpc/go v1.19.1-20260228021043-887d38e1b474.2
buf.build/gen/go/brevdev/devplane/protocolbuffers/go v1.36.11-20260305005117-3cacb6388cd4.1
buf.build/gen/go/brevdev/devplane/protocolbuffers/go v1.36.11-20260305201249-af5106090c8a.1
connectrpc.com/connect v1.19.1
github.com/NVIDIA/go-nvml v0.13.0-1
github.com/alessio/shellescape v1.4.1
github.com/brevdev/parse v0.0.11
github.com/briandowns/spinner v1.16.0
Expand Down Expand Up @@ -150,7 +151,7 @@ require (
go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect
golang.org/x/net v0.48.0 // indirect
golang.org/x/oauth2 v0.34.0 // indirect
golang.org/x/sys v0.40.0 // indirect
golang.org/x/sys v0.40.0
golang.org/x/term v0.39.0 // indirect
golang.org/x/time v0.12.0 // indirect
google.golang.org/protobuf v1.36.11
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
buf.build/gen/go/brevdev/devplane/connectrpc/go v1.19.1-20260228021043-887d38e1b474.2 h1:Sq0kIa/xKzScbJcqB5EbPVhOL0QYHPr3araQaupL2lk=
buf.build/gen/go/brevdev/devplane/connectrpc/go v1.19.1-20260228021043-887d38e1b474.2/go.mod h1:Yh34p9aADmWsKv2umYlMpnCZuBmNBE9N+HImgRriJXM=
buf.build/gen/go/brevdev/devplane/protocolbuffers/go v1.36.11-20260305005117-3cacb6388cd4.1 h1:3Y3FI5kbM4uacawy5dySjVTPSbu2BJMO42eQHf2wz+g=
buf.build/gen/go/brevdev/devplane/protocolbuffers/go v1.36.11-20260305005117-3cacb6388cd4.1/go.mod h1:V/y7Wxg0QvU4XPVwqErF5NHLobUT1QEyfgrGuQIxdPo=
buf.build/gen/go/brevdev/devplane/protocolbuffers/go v1.36.11-20260305201249-af5106090c8a.1 h1:d+kY4OSI/WV2eBuO5G7ezCQ8RiLtDOIrUbtmZOKi5Kw=
buf.build/gen/go/brevdev/devplane/protocolbuffers/go v1.36.11-20260305201249-af5106090c8a.1/go.mod h1:V/y7Wxg0QvU4XPVwqErF5NHLobUT1QEyfgrGuQIxdPo=
buf.build/gen/go/brevdev/protoc-gen-gotag/protocolbuffers/go v1.36.11-20220906235457-8b4922735da5.1 h1:6amhprQmCKJ4wgJ6ngkh32d9V+dQcOLUZ/SfHdOnYgo=
buf.build/gen/go/brevdev/protoc-gen-gotag/protocolbuffers/go v1.36.11-20220906235457-8b4922735da5.1/go.mod h1:O+pnSHMru/naTMrm4tmpBoH3wz6PHa+R75HR7Mv8X2g=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
Expand Down Expand Up @@ -53,6 +53,8 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/NVIDIA/go-nvml v0.13.0-1 h1:OLX8Jq3dONuPOQPC7rndB6+iDmDakw0XTYgzMxObkEw=
github.com/NVIDIA/go-nvml v0.13.0-1/go.mod h1:+KNA7c7gIBH7SKSJ1ntlwkfN80zdx8ovl4hrK3LmPt4=
github.com/ProtonMail/go-crypto v1.1.5 h1:eoAQfK2dwL+tFSFpr7TbOaPNUbPiJj4fLYwwGE1FQO4=
github.com/ProtonMail/go-crypto v1.1.5/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE=
github.com/alessio/shellescape v1.4.1 h1:V7yhSDDn8LP4lc4jS8pFkt0zCnzVJlG5JXy9BVKJUX0=
Expand Down
12 changes: 6 additions & 6 deletions pkg/cmd/register/device_registration_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ const (
// DeviceRegistration is the persistent identity file for a registered device.
// Fields align with the AddNodeResponse from dev-plane.
type DeviceRegistration struct {
ExternalNodeID string `json:"external_node_id"`
DisplayName string `json:"display_name"`
OrgID string `json:"org_id"`
DeviceID string `json:"device_id"`
RegisteredAt string `json:"registered_at"`
NodeSpec NodeSpec `json:"node_spec"`
ExternalNodeID string `json:"external_node_id"`
DisplayName string `json:"display_name"`
OrgID string `json:"org_id"`
DeviceID string `json:"device_id"`
RegisteredAt string `json:"registered_at"`
HardwareProfile HardwareProfile `json:"hardware_profile"`
}

// RegistrationStore defines the contract for persisting device registration data.
Expand Down
10 changes: 5 additions & 5 deletions pkg/cmd/register/device_registration_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func Test_SaveAndLoadRegistration_RoundTrip(t *testing.T) {
OrgID: "org_xyz",
DeviceID: "device-uuid-123",
RegisteredAt: "2026-02-25T00:00:00Z",
NodeSpec: NodeSpec{
HardwareProfile: HardwareProfile{
CPUCount: &cpuCount,
RAMBytes: &ramBytes,
Architecture: "arm64",
Expand Down Expand Up @@ -59,11 +59,11 @@ func Test_SaveAndLoadRegistration_RoundTrip(t *testing.T) {
if loaded.DeviceID != reg.DeviceID {
t.Errorf("DeviceID mismatch: got %s, want %s", loaded.DeviceID, reg.DeviceID)
}
if loaded.NodeSpec.Architecture != "arm64" {
t.Errorf("Architecture mismatch: got %s", loaded.NodeSpec.Architecture)
if loaded.HardwareProfile.Architecture != "arm64" {
t.Errorf("Architecture mismatch: got %s", loaded.HardwareProfile.Architecture)
}
if loaded.NodeSpec.CPUCount == nil || *loaded.NodeSpec.CPUCount != 12 {
t.Errorf("CPUCount mismatch: got %v", loaded.NodeSpec.CPUCount)
if loaded.HardwareProfile.CPUCount == nil || *loaded.HardwareProfile.CPUCount != 12 {
t.Errorf("CPUCount mismatch: got %v", loaded.HardwareProfile.CPUCount)
}
}

Expand Down
Loading
Loading