Files
nmon/Makefile
jleung f7b394585b Maintainability is a hard rule: standard, golangci-lint config, lint in every gate
- docs/MAINTAINABILITY.md: limits and architecture rules
- .golangci.yml (pinned v2.14.0) + file-size check; make lint runs first in every gate
- web/go.mod stops the Go tool from walking web/node_modules
- layering: Target -> internal/snmptarget, TableKey -> profile.Metric.TableKey; poller no longer imports discovery

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lx9FNLG2CqeBbVGGd9bFsP
2026-10-22 18:54:32 +00:00

63 lines
1.8 KiB
Makefile

GO ?= go
TAGS ?= vmembed
LDFLAGS := -s -w
BIN := nmon
PG_DSN ?= postgres://nmon:nmon@localhost:55432/nmon?sslmode=disable
.PHONY: all lint lint-go lint-web build importer build-arm64 build-noembed fetch-vm web test test-integration test-pg test-v6only vet gate-m1 gate-m2 gate-m3 gate-m4 gate-m5 gate-m6 clean
all: build
fetch-vm:
./scripts/fetch-vm.sh
# The UI is built first when web/ exists so embed.FS picks it up.
web:
@if [ -f web/package.json ]; then cd web && npm ci --no-audit --no-fund && npm run build; fi
build: fetch-vm
CGO_ENABLED=0 $(GO) build -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $(BIN) ./cmd/nmon
build-arm64: fetch-vm
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 $(GO) build -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $(BIN)-arm64 ./cmd/nmon
importer:
CGO_ENABLED=0 $(GO) build -ldflags '$(LDFLAGS)' -o nmon-librenms-import ./cmd/nmon-librenms-import
build-noembed:
CGO_ENABLED=0 $(GO) build -ldflags '$(LDFLAGS)' -o $(BIN) ./cmd/nmon
GOLANGCI := go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.14.0
# Hard rule (docs/MAINTAINABILITY.md): every gate runs this first and it must be clean.
lint: lint-go lint-web
lint-go:
$(GOLANGCI) run ./...
./scripts/lint-filesize.sh
lint-web:
@if [ -f web/package.json ]; then cd web && npm run lint; fi
vet:
$(GO) vet ./...
test:
$(GO) test -race ./...
# Integration tests use fixtures and a real VictoriaMetrics binary extracted by fetch-vm.
test-integration: fetch-vm
$(GO) test -race -tags 'integration $(TAGS)' ./...
test-pg:
./scripts/test-pg.sh
test-v6only:
NMON_TEST_V6ONLY=1 $(GO) test -race -tags 'integration $(TAGS)' ./...
gate-m1 gate-m2 gate-m3 gate-m4 gate-m5 gate-m6: gate-m%:
./scripts/gate-m$*.sh
clean:
rm -f $(BIN) $(BIN)-arm64 nmon-librenms-import