chore: add root Makefile with namespaced targets
Namespaced go-* targets (build, run, test, test-verbose, check, cover, fmt, vet, tidy, install, lint, clean) plus umbrella targets that delegate to them. help is the default. py-* targets will slot in during the Python port. Updates .gitignore with coverage artifacts. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
92
docs/usage/makefile.md
Normal file
92
docs/usage/makefile.md
Normal file
@@ -0,0 +1,92 @@
|
||||
# Makefile
|
||||
|
||||
The root `Makefile` provides a single entry point for all common development
|
||||
tasks. Targets are namespaced by language (`go-*`, `py-*` when the Python port
|
||||
lands) with short umbrella targets (`build`, `test`, …) that delegate to the
|
||||
language-specific ones.
|
||||
|
||||
## Quick reference
|
||||
|
||||
```sh
|
||||
make # same as: make help
|
||||
make help # list all targets with descriptions
|
||||
```
|
||||
|
||||
## Umbrella targets
|
||||
|
||||
| Target | Description |
|
||||
|--------|-------------|
|
||||
| `all` | Run `check` then `build` |
|
||||
| `build` | Build the binary (→ `go-build`) |
|
||||
| `test` | Run all tests (→ `go-test`) |
|
||||
| `check` | Pre-commit gate: fmt + vet + test (→ `go-check`) |
|
||||
| `fmt` | Format source (→ `go-fmt`) |
|
||||
| `vet` | Static analysis (→ `go-vet`) |
|
||||
| `clean` | Remove binary and coverage artifacts |
|
||||
|
||||
## Go targets
|
||||
|
||||
| Target | Description |
|
||||
|--------|-------------|
|
||||
| `go-build` | Compile `go/latprobe` |
|
||||
| `go-run` | Build and run (pass flags via `ARGS=`) |
|
||||
| `go-test` | `go test ./...` |
|
||||
| `go-test-verbose` | `go test -v ./...` — per-case PASS/FAIL output |
|
||||
| `go-check` | `go-fmt` + `go-vet` + `go-test` |
|
||||
| `go-cover` | Coverage report → `go/coverage.html` |
|
||||
| `go-fmt` | `gofmt -w go/` |
|
||||
| `go-vet` | `go vet ./...` |
|
||||
| `go-tidy` | `go mod tidy` |
|
||||
| `go-install` | Install binary to `$GOBIN` |
|
||||
| `go-lint` | `golangci-lint run` (must be installed) |
|
||||
| `go-clean` | Remove `go/latprobe`, `go/coverage.out`, `go/coverage.html` |
|
||||
|
||||
## Examples
|
||||
|
||||
```sh
|
||||
# Build and run a quick probe
|
||||
make go-run ARGS="https://example.com"
|
||||
make go-run ARGS="-n 5 --json https://example.com https://www.google.com"
|
||||
|
||||
# Run the full test suite
|
||||
make test
|
||||
|
||||
# Verbose output showing each test case
|
||||
make go-test-verbose
|
||||
|
||||
# Pre-commit gate (format, vet, test all in one)
|
||||
make check
|
||||
|
||||
# Generate and open coverage report
|
||||
make go-cover
|
||||
open go/coverage.html # macOS
|
||||
|
||||
# Lint
|
||||
make go-lint
|
||||
|
||||
# Clean up artifacts
|
||||
make clean
|
||||
```
|
||||
|
||||
## Passing arguments to `go-run`
|
||||
|
||||
```sh
|
||||
make go-run ARGS="<url> [url ...] [flags]"
|
||||
|
||||
# Examples
|
||||
make go-run ARGS="https://example.com"
|
||||
make go-run ARGS="--timeout 2s --fail https://example.com"
|
||||
make go-run ARGS="--json -n 3 https://example.com https://www.google.com"
|
||||
```
|
||||
|
||||
## Adding Python targets (when the port lands)
|
||||
|
||||
The umbrella targets are designed to accept Python targets alongside the Go ones.
|
||||
The pattern will be:
|
||||
|
||||
```make
|
||||
test: go-test py-test # py-test added here during the port
|
||||
```
|
||||
|
||||
`go-lint` requires `golangci-lint` to be installed. If it's missing the target
|
||||
prints an install link and exits 1.
|
||||
Reference in New Issue
Block a user