refactor: clarify service boundaries and unify project tooling
This commit is contained in:
31 files changed
+832
-539
No files matched your search
@@ -1,22 +1,52 @@
|
||||
GO ?= go
|
||||
PYTHON ?= python3
|
||||
BINARY := dist/routershelf-linux-mipsle
|
||||
SERVICES := routershelf routershelf-smb
|
||||
HOST_BINARIES := $(addprefix dist/,$(SERVICES))
|
||||
MIPS_BINARIES := $(addsuffix -linux-mipsle,$(HOST_BINARIES))
|
||||
|
||||
.PHONY: test build-mipsle check-shell check-config nat-plan test-stress-tool build-smb-mipsle
|
||||
.PHONY: test check check-shell check-config check-format check-docs vet test-race test-repository \
|
||||
build build-mipsle build-smb-mipsle build-router nat-plan test-stress-tool
|
||||
|
||||
test: check-shell check-config test-stress-tool
|
||||
test: check-shell check-config test-stress-tool test-repository
|
||||
$(GO) test ./...
|
||||
|
||||
check-shell:
|
||||
sh -n deploy/padavan/supervisor.example.sh
|
||||
sh -n deploy/padavan/smb-supervisor.example.sh
|
||||
sh -n scripts/nat-plan.sh
|
||||
sh -n examples/status-dashboard/scripts/status-service.sh
|
||||
sh -n examples/status-dashboard/scripts/status-response.sh
|
||||
# CI and the local full check use the same commands. No deployment is performed.
|
||||
check: test check-format check-docs vet test-race
|
||||
|
||||
build-mipsle:
|
||||
mkdir -p dist
|
||||
GOOS=linux GOARCH=mipsle GOMIPS=softfloat CGO_ENABLED=0 $(GO) build -trimpath -ldflags='-s -w' -o $(BINARY) ./cmd/routershelf
|
||||
check-shell:
|
||||
@for script in deploy/padavan/*.sh scripts/*.sh examples/status-dashboard/scripts/*.sh examples/status-dashboard/config.example.sh; do \
|
||||
sh -n "$$script" || exit; \
|
||||
done
|
||||
|
||||
check-format:
|
||||
@unformatted=$$(gofmt -l cmd internal) && { test -z "$$unformatted" || { echo "Run go fmt ./...: $$unformatted"; exit 1; }; }
|
||||
|
||||
check-docs:
|
||||
$(PYTHON) -B scripts/check_repository.py
|
||||
|
||||
vet:
|
||||
$(GO) vet ./...
|
||||
|
||||
test-race:
|
||||
$(GO) test -race ./...
|
||||
|
||||
# Native executables are useful for local development and macOS client checks.
|
||||
build: $(HOST_BINARIES)
|
||||
|
||||
# Preserve the existing per-service targets and artifact names.
|
||||
build-mipsle: dist/routershelf-linux-mipsle
|
||||
build-smb-mipsle: dist/routershelf-smb-linux-mipsle
|
||||
build-router: $(MIPS_BINARIES)
|
||||
|
||||
# Always rebuild: a package depends on embedded assets and transitive sources.
|
||||
.PHONY: $(HOST_BINARIES) $(MIPS_BINARIES)
|
||||
$(HOST_BINARIES):
|
||||
@mkdir -p dist
|
||||
CGO_ENABLED=0 $(GO) build -trimpath -ldflags='-s -w' -o $@ ./cmd/$(notdir $@)
|
||||
|
||||
$(MIPS_BINARIES): dist/%-linux-mipsle:
|
||||
@mkdir -p dist
|
||||
GOOS=linux GOARCH=mipsle GOMIPS=softfloat CGO_ENABLED=0 $(GO) build -trimpath -ldflags='-s -w' -o $@ ./cmd/$*
|
||||
|
||||
check-config:
|
||||
ROUTERSHELF_ENV_FILE="$(CURDIR)/.env.example" sh deploy/padavan/supervisor.example.sh --check-config
|
||||
@@ -25,8 +55,7 @@ nat-plan:
|
||||
sh scripts/nat-plan.sh
|
||||
|
||||
test-stress-tool:
|
||||
$(PYTHON) -B -m unittest discover -s scripts/tests -p 'test_*.py' -v
|
||||
$(PYTHON) -B -m unittest discover -s scripts/tests -p 'test_stress_test.py' -v
|
||||
|
||||
build-smb-mipsle:
|
||||
mkdir -p dist
|
||||
GOOS=linux GOARCH=mipsle GOMIPS=softfloat CGO_ENABLED=0 $(GO) build -trimpath -ldflags='-s -w' -o dist/routershelf-smb-linux-mipsle ./cmd/routershelf-smb
|
||||
test-repository:
|
||||
$(PYTHON) -B -m unittest discover -s scripts/tests -p 'test_repository.py' -v
|
||||
Reference in new issue
Block a user