Skip to content

Commit 642a282

Browse files
committed
build(wait0): expand Makefile automation and docs integration
Add strict Makefile preamble, self-documenting help, and standard dev/quality targets. Add Docker lifecycle targets and a release target that runs scripts/publish.sh. Update README and AGENTS command references to use canonical make workflows.
1 parent 817f7f8 commit 642a282

File tree

4 files changed

+128
-12
lines changed

4 files changed

+128
-12
lines changed

AGENTS.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,16 @@ wait0 is an ultra-fast cache-first HTTP reverse proxy written in Go that serves
4848
|----------|------|-------------|
4949
| README | README.md | Project landing page and operational guide |
5050
| Docker Hub notes | DOCKERHUB.md | Alias to README for Docker Hub presentation |
51+
52+
## Build & Development Commands
53+
This project uses a `Makefile` for build automation.
54+
55+
Common commands:
56+
- `make help` — list all available targets
57+
- `make test` — run unit tests
58+
- `make test-race` — run race-enabled tests
59+
- `make coverage` — run coverage gate for `internal/wait0`
60+
- `make lint` — run static checks (`go vet`)
61+
- `make build` — build the `wait0` binary
62+
- `make ci-check` — run full local quality gate
63+
- `make docker-build` / `make docker-run` — build and run the container locally

Makefile

Lines changed: 95 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,99 @@
1-
.PHONY: test test-race coverage ci-check
1+
SHELL := bash
2+
.ONESHELL:
3+
.SHELLFLAGS := -eu -o pipefail -c
4+
.DELETE_ON_ERROR:
5+
MAKEFLAGS += --warn-undefined-variables
6+
MAKEFLAGS += --no-builtin-rules
27

3-
test:
4-
go test ./...
8+
GO ?= go
9+
PROJECT ?= $(notdir $(CURDIR))
10+
BIN_DIR ?= bin
11+
BINARY ?= wait0
12+
CMD_PACKAGE ?= ./cmd/wait0
13+
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
14+
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
15+
BUILD_TIME := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
516

6-
test-race:
7-
go test -race ./...
17+
DOCKER ?= docker
18+
DOCKER_IMAGE ?= $(PROJECT)
19+
DOCKER_TAG ?= $(VERSION)
20+
CONTAINER_NAME ?= wait0-local
821

9-
coverage:
10-
./scripts/coverage.sh 80
22+
COVERAGE_THRESHOLD ?= 80
1123

12-
ci-check: test test-race coverage
24+
.DEFAULT_GOAL := help
25+
26+
.PHONY: help build test test-race coverage lint fmt dev clean ci ci-check print-version \
27+
docker-build docker-run docker-stop docker-logs docker-push docker-clean release
28+
29+
help: ## Show available targets
30+
@awk 'BEGIN {FS = ":.*##"; printf "Usage:\n make \033[36m<target>\033[0m\n"} \
31+
/^[a-zA-Z0-9_.-]+:.*## / {printf " \033[36m%-22s\033[0m %s\n", $$1, $$2} \
32+
/^##@/ {printf "\n\033[1m%s\033[0m\n", substr($$0, 5)}' $(MAKEFILE_LIST)
33+
34+
##@ Build
35+
build: ## Build wait0 binary
36+
mkdir -p $(BIN_DIR)
37+
$(GO) build -trimpath -o $(BIN_DIR)/$(BINARY) $(CMD_PACKAGE)
38+
39+
print-version: ## Print build metadata
40+
@echo "project=$(PROJECT)"
41+
@echo "version=$(VERSION)"
42+
@echo "commit=$(COMMIT)"
43+
@echo "build_time=$(BUILD_TIME)"
44+
45+
##@ Quality
46+
test: ## Run unit tests
47+
$(GO) test ./...
48+
49+
test-race: ## Run tests with race detector
50+
$(GO) test -race ./...
51+
52+
coverage: ## Run coverage gate for internal/wait0
53+
./scripts/coverage.sh $(COVERAGE_THRESHOLD)
54+
55+
lint: ## Run static checks
56+
$(GO) vet ./...
57+
58+
fmt: ## Format Go sources
59+
$(GO) fmt ./...
60+
61+
ci: lint test build ## Run fast CI checks (lint + test + build)
62+
63+
ci-check: lint test test-race coverage build ## Run full local quality gate
64+
65+
##@ Development
66+
dev: ## Run wait0 with debug config
67+
$(GO) run $(CMD_PACKAGE) -config ./debug/wait0.yaml
68+
69+
clean: ## Remove build and coverage artifacts
70+
rm -rf $(BIN_DIR) coverage.out coverage.internal.filtered.out coverage-summary.txt
71+
72+
##@ Docker
73+
docker-build: ## Build Docker image
74+
$(DOCKER) build -t $(DOCKER_IMAGE):$(DOCKER_TAG) .
75+
76+
docker-run: ## Run container with debug config and local data volume
77+
mkdir -p .wait0-data
78+
$(DOCKER) run -d --rm \
79+
--name $(CONTAINER_NAME) \
80+
-p 8082:8082 \
81+
-v "$(CURDIR)/debug/wait0.yaml:/wait0.yaml:ro" \
82+
-v "$(CURDIR)/.wait0-data:/data" \
83+
$(DOCKER_IMAGE):$(DOCKER_TAG)
84+
85+
docker-stop: ## Stop local container
86+
-$(DOCKER) stop $(CONTAINER_NAME)
87+
88+
docker-logs: ## Tail local container logs
89+
$(DOCKER) logs -f $(CONTAINER_NAME)
90+
91+
docker-push: ## Push Docker image to registry
92+
$(DOCKER) push $(DOCKER_IMAGE):$(DOCKER_TAG)
93+
94+
docker-clean: ## Remove local Docker image
95+
-$(DOCKER) image rm $(DOCKER_IMAGE):$(DOCKER_TAG)
96+
97+
##@ Publish
98+
release: ## Build and publish Docker image to Devforth DockerHub
99+
./scripts/publish.sh

README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,20 +139,27 @@ If you need to pre-warm cache after redeploy, it is recommended to use a sitemap
139139
How to run:
140140

141141
```bash
142-
go test ./...
142+
make test
143143
go run ./cmd/wait0 -config ./debug/wait0.yaml
144144
```
145145

146146
Testing and coverage gates:
147147

148148
```bash
149-
# full local quality gate (tests + race + coverage threshold)
149+
# show all available targets
150+
make help
151+
152+
# full local quality gate (lint + tests + race + coverage threshold + build)
150153
make ci-check
151154
152-
# or run separately
155+
# common commands
156+
make build
153157
make test
154158
make test-race
159+
make lint
160+
make fmt
155161
make coverage
162+
make dev
156163
```
157164

158165
Coverage policy:
@@ -161,6 +168,15 @@ Coverage policy:
161168
- `internal/wait0/proc_linux.go`
162169
- `internal/wait0/proc_other.go`
163170

171+
Docker quick commands:
172+
173+
```bash
174+
make docker-build
175+
make docker-run
176+
make docker-logs
177+
make docker-stop
178+
```
179+
164180
Debug stack (origin + wait0):
165181

166182
```bash
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
docker buildx create --use
2-
docker buildx build --platform=linux/amd64,linux/arm64 --tag "devforth/wait0:latest" --tag "devforth/wait0:1.0.1" --push .
2+
docker buildx build --platform=linux/amd64,linux/arm64 --tag "devforth/wait0:latest" --tag "devforth/wait0:1.0.1" --push ../Dockerfile

0 commit comments

Comments
 (0)