Makefile 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # Local mirror of the .github/workflows/pr.yml checks.
  2. # Keep this in sync with the workflow. Run `make check` before pushing.
  3. SHELL := /bin/bash
  4. AGENT_VERSION ?= 0.0.0-dev
  5. GO ?= go
  6. NPM ?= npm
  7. AGENT_BIN := server-go/internal/agentbin/agents
  8. .PHONY: check frontend agents server agent collector clean
  9. check: frontend agents server agent
  10. @echo "check: all steps passed"
  11. frontend:
  12. cd app && $(NPM) ci --no-audit --no-fund
  13. cd app && $(NPM) run lint
  14. cd app && $(NPM) run build
  15. rm -rf server-go/internal/staticspa/dist
  16. cp -r app/dist server-go/internal/staticspa/dist
  17. # The agent binaries are go:embed inputs of the server, so they must exist
  18. # before the server compiles. scripts/build-agents.sh builds the five
  19. # architectures (normalizeArch names: armv7 is "arm" with GOARM=7, MIPS is
  20. # softfloat), packs them with UPX and verifies the result (#1890: an unpacked
  21. # agent needs twice its size free to upgrade on a router). It needs upx in
  22. # PATH; UPX_BIN=/path/to/upx points it elsewhere.
  23. agents:
  24. GO=$(GO) scripts/build-agents.sh $(AGENT_VERSION) $(AGENT_BIN)
  25. server:
  26. cd server-go && $(GO) test ./...
  27. agent:
  28. cd agent && $(GO) test ./...
  29. # The collector is its own module and is not part of the PR workflow.
  30. collector:
  31. cd collector && $(GO) test ./...
  32. clean:
  33. rm -rf app/dist server-go/internal/staticspa/dist
  34. # --- Docker (optional install path, docs/docker.md) -------------------------
  35. # Not part of `make check`: helpers to build and run the server image. The
  36. # image builds the frontend and the agent binaries itself, so a plain
  37. # `docker build` is self-contained and needs no toolchain on the host.
  38. DOCKER_IMAGE ?= netpulse:local
  39. VERSION ?= 0.0.0-docker
  40. BUILD_COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
  41. .PHONY: docker-build docker-up docker-down
  42. docker-build:
  43. docker build \
  44. --build-arg VERSION=$(VERSION) \
  45. --build-arg BUILD_COMMIT=$(BUILD_COMMIT) \
  46. --build-arg AGENT_VERSION=$(shell tr -d '[:space:]' < agent/VERSION 2>/dev/null || echo 0.0.0-dev) \
  47. -t $(DOCKER_IMAGE) .
  48. docker-up:
  49. docker compose up -d --build
  50. docker-down:
  51. docker compose down