build: add Makefile as the single entry point for dev/CI/release
One make interface that runs the same commands locally and in CI.
- `make validate` = fmt-check -> check -> test -> release build (the pre-PR gate).
- `make ci` (alias) is now what .github/workflows/ci.yml runs; release.yml's
validate stage runs `make validate` and its per-target build/package runs
`make package TARGET=<triple>` (byte-identical artifact: krust-<triple>.tar.gz
containing krust-<triple>/{krust,README.md,LICENSE}).
- Convenience targets: fmt, check, clippy, test, build(-release), run, clean,
package; lab-{up,load,contexts,crds,churn,down} wrap scripts/scale; and
bench/bench-contexts/soak/discover/metrics wrap the headless harnesses.
- cargo is resolved robustly (PATH, then a Homebrew keg-only rustup, else
plain cargo) and its dir is put on PATH so external subcommands (cargo-fmt,
cargo-clippy) and rustc resolve even when rustup is keg-only.
- dist/ (package output) gitignored. Docs (contributor guide, AGENTS, README)
point at `make validate`.
Verified locally: make validate green (85 tests), make package produces the
release tarball, cargo resolves with no keg on PATH. CI running `make ci` on
this PR is the cross-environment proof.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
7dde2b34fe
commit
897fd38066
7 files changed
+130
-40
No files matched your search
@@ -26,14 +26,5 @@ jobs:
|
||||
- name: Cache Rust artifacts
|
||||
uses: Swatinem/rust-cache@v2
|
||||
|
||||
- name: cargo fmt --all -- --check
|
||||
run: cargo fmt --all -- --check
|
||||
|
||||
- name: cargo check --locked
|
||||
run: cargo check --locked
|
||||
|
||||
- name: cargo test --locked
|
||||
run: cargo test --locked
|
||||
|
||||
- name: cargo build --release --locked
|
||||
run: cargo build --release --locked
|
||||
- name: Validate (make ci)
|
||||
run: make ci
|
||||
@@ -83,13 +83,8 @@ jobs:
|
||||
- name: Cache Rust artifacts
|
||||
uses: Swatinem/rust-cache@v2
|
||||
|
||||
- name: Validate (fmt/check/test/build)
|
||||
run: |
|
||||
set -euo pipefail
|
||||
cargo fmt --all -- --check
|
||||
cargo check --locked
|
||||
cargo test --locked
|
||||
cargo build --release --locked
|
||||
- name: Validate (make validate)
|
||||
run: make validate
|
||||
|
||||
- name: Resolve next semver
|
||||
id: version
|
||||
@@ -253,19 +248,8 @@ jobs:
|
||||
- name: Cache Rust artifacts
|
||||
uses: Swatinem/rust-cache@v2
|
||||
|
||||
- name: Build release binary
|
||||
run: cargo build --release --locked --target ${{ matrix.target }}
|
||||
|
||||
- name: Package artifact
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
TARGET='${{ matrix.target }}'
|
||||
PKG="krust-${TARGET}"
|
||||
mkdir -p "dist/${PKG}"
|
||||
cp "target/${TARGET}/release/krust" "dist/${PKG}/krust"
|
||||
cp README.md LICENSE "dist/${PKG}/"
|
||||
tar -C dist -czf "dist/${PKG}.tar.gz" "${PKG}"
|
||||
- name: Build + package artifact (make package)
|
||||
run: make package TARGET=${{ matrix.target }}
|
||||
|
||||
- name: Upload build artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
|
||||
@@ -31,3 +31,6 @@ target
|
||||
|
||||
# Scale-lab generated kubeconfig (embeds kwok cluster certs — never commit)
|
||||
scripts/scale/kubeconfig-scale.yaml
|
||||
|
||||
# Release packaging output (`make package`)
|
||||
/dist
|
||||
@@ -9,11 +9,13 @@
|
||||
Agent behavior must prioritize snappiness and controlled API pressure over feature breadth.
|
||||
|
||||
## Mandatory Change Pipeline
|
||||
After every code change, run validation in this order:
|
||||
1. `cargo fmt --all`
|
||||
2. `cargo check`
|
||||
3. `cargo test`
|
||||
4. `cargo build --release`
|
||||
After every code change, run `make validate` — it runs, in order:
|
||||
1. `cargo fmt --all -- --check`
|
||||
2. `cargo check --locked`
|
||||
3. `cargo test --locked`
|
||||
4. `cargo build --release --locked`
|
||||
|
||||
This is the same target CI runs (`make ci`). Use `make fmt` to auto-format.
|
||||
|
||||
Rules:
|
||||
- If tests fail, do not proceed to release build until fixed.
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
# krust Makefile — one entry point for local dev, CI, and release packaging.
|
||||
# Targets mirror the commands in .github/workflows/{ci,release}.yml so `make` runs the
|
||||
# exact same pipeline on your machine and on CI.
|
||||
#
|
||||
# make # list targets
|
||||
# make validate # the full pre-PR / CI gate (fmt-check + check + test + release build)
|
||||
# make package # build + tar a release artifact for the host (or TARGET=<triple>)
|
||||
# make lab-up lab-load lab-contexts # stand up the kwok scale lab
|
||||
# make bench | soak | discover | metrics # verification harnesses against the lab
|
||||
|
||||
# Resolve cargo: PATH first, then a Homebrew keg-only rustup install (macOS), else plain `cargo`.
|
||||
CARGO ?= $(shell command -v cargo 2>/dev/null || command -v /opt/homebrew/opt/rustup/bin/cargo 2>/dev/null || echo cargo)
|
||||
RUSTC ?= $(shell command -v rustc 2>/dev/null || command -v /opt/homebrew/opt/rustup/bin/rustc 2>/dev/null || echo rustc)
|
||||
# Put cargo's directory on PATH so external subcommands (cargo-fmt, cargo-clippy) and rustc resolve
|
||||
# even with a Homebrew keg-only rustup that isn't otherwise on PATH.
|
||||
export PATH := $(dir $(CARGO)):$(PATH)
|
||||
|
||||
# Host target triple, used by `package` when TARGET is not supplied.
|
||||
TARGET ?= $(shell $(RUSTC) -vV 2>/dev/null | sed -n 's/^host: //p')
|
||||
|
||||
# Defaults for the lab harness targets.
|
||||
SCALE_KUBECONFIG ?= scripts/scale/kubeconfig-scale.yaml
|
||||
KRUST_BIN := target/release/krust
|
||||
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
.PHONY: help fmt fmt-check check clippy test build build-release validate ci run clean \
|
||||
package lab-up lab-load lab-contexts lab-crds lab-churn lab-down \
|
||||
bench bench-contexts soak discover metrics
|
||||
|
||||
help: ## List available targets
|
||||
@awk 'BEGIN{FS=":.*?## "}/^[a-zA-Z0-9_-]+:.*?## /{printf " \033[36m%-16s\033[0m %s\n",$$1,$$2}' $(MAKEFILE_LIST)
|
||||
|
||||
# ---- core dev pipeline (identical commands to CI) -------------------------------------
|
||||
fmt: ## Format all code
|
||||
$(CARGO) fmt --all
|
||||
|
||||
fmt-check: ## Check formatting without writing
|
||||
$(CARGO) fmt --all -- --check
|
||||
|
||||
check: ## Type-check (locked)
|
||||
$(CARGO) check --locked
|
||||
|
||||
clippy: ## Lint with clippy (locked, warnings as errors) — not part of the CI gate
|
||||
$(CARGO) clippy --locked --all-targets -- -D warnings
|
||||
|
||||
test: ## Run the test suite (locked)
|
||||
$(CARGO) test --locked
|
||||
|
||||
build: ## Debug build
|
||||
$(CARGO) build --locked
|
||||
|
||||
build-release: ## Optimized release build
|
||||
$(CARGO) build --release --locked
|
||||
|
||||
validate: ## Full gate run sequentially: fmt-check -> check -> test -> release build
|
||||
$(MAKE) fmt-check
|
||||
$(MAKE) check
|
||||
$(MAKE) test
|
||||
$(MAKE) build-release
|
||||
|
||||
ci: validate ## Alias invoked by GitHub Actions
|
||||
|
||||
run: ## Run krust locally (pass args via ARGS="--context foo")
|
||||
$(CARGO) run -- $(ARGS)
|
||||
|
||||
clean: ## Remove build artifacts and generated dist/
|
||||
$(CARGO) clean
|
||||
rm -rf dist
|
||||
|
||||
# ---- release packaging (mirrors .github/workflows/release.yml) ------------------------
|
||||
package: ## Build + tar a release artifact for TARGET (default: host triple)
|
||||
@test -n "$(TARGET)" || { echo "could not determine TARGET (rustc not found); pass TARGET=<triple>"; exit 1; }
|
||||
$(CARGO) build --release --locked --target $(TARGET)
|
||||
@PKG="krust-$(TARGET)"; \
|
||||
rm -rf "dist/$$PKG"; mkdir -p "dist/$$PKG"; \
|
||||
cp "target/$(TARGET)/release/krust" "dist/$$PKG/krust"; \
|
||||
cp README.md LICENSE "dist/$$PKG/"; \
|
||||
tar -C dist -czf "dist/$$PKG.tar.gz" "$$PKG"; \
|
||||
echo "packaged dist/$$PKG.tar.gz"
|
||||
|
||||
# ---- kwok scale lab (scripts/scale) ---------------------------------------------------
|
||||
lab-up: ## Create the kwok scale cluster
|
||||
scripts/scale/up.sh
|
||||
lab-load: ## Load fake nodes/namespaces/pods (tune with KRUST_* env)
|
||||
scripts/scale/load.sh
|
||||
lab-contexts: ## Generate the multi-context kubeconfig
|
||||
scripts/scale/contexts.sh
|
||||
lab-crds: ## Install the sample CRD + custom resources
|
||||
scripts/scale/crds.sh
|
||||
lab-churn: ## Run the churn generator (Ctrl-C to stop)
|
||||
scripts/scale/churn.sh
|
||||
lab-down: ## Tear down the kwok cluster + generated kubeconfig
|
||||
scripts/scale/down.sh
|
||||
|
||||
# ---- verification harnesses (need the lab + a release build) --------------------------
|
||||
bench: build-release ## Bench the hot paths against the lab
|
||||
$(KRUST_BIN) --kubeconfig $(SCALE_KUBECONFIG) --bench
|
||||
bench-contexts: build-release ## Multi-context memory test (N=20 by default)
|
||||
$(KRUST_BIN) --kubeconfig $(SCALE_KUBECONFIG) --bench --bench-contexts $(or $(N),20)
|
||||
soak: build-release ## Soak under churn (SECS=210 by default)
|
||||
$(KRUST_BIN) --kubeconfig $(SCALE_KUBECONFIG) --soak-secs $(or $(SECS),210)
|
||||
discover: build-release ## Dynamic discovery catalog (RES=<plural> to also list one)
|
||||
$(KRUST_BIN) --kubeconfig $(SCALE_KUBECONFIG) --discover $(if $(RES),--discover-resource $(RES),)
|
||||
metrics: build-release ## Live metrics probe (CTX=<context>, else the lab)
|
||||
$(KRUST_BIN) $(if $(CTX),--context $(CTX),--kubeconfig $(SCALE_KUBECONFIG)) --readonly --metrics
|
||||
@@ -46,6 +46,9 @@ sudo install krust-x86_64-unknown-linux-gnu/krust /usr/local/bin/krust
|
||||
cargo install --git https://github.com/ErfanY/krust.git --locked krust
|
||||
```
|
||||
|
||||
For local development, `make` (no args) lists targets; `make validate` runs the full CI gate
|
||||
(fmt/check/test/release build) and `make package` builds a release tarball.
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
|
||||
@@ -36,12 +36,13 @@ cargo run -- --context <context-name>
|
||||
## Required Validation Before PR
|
||||
|
||||
```bash
|
||||
cargo fmt --all
|
||||
cargo check --locked
|
||||
cargo test --locked
|
||||
cargo build --release --locked
|
||||
make validate # fmt-check -> check -> test -> release build (identical to CI)
|
||||
```
|
||||
|
||||
`make validate` is exactly what GitHub Actions runs (`make ci`), so a green local run matches CI.
|
||||
`make` (no args) lists all targets. Individual steps are also available: `make fmt`, `make check`,
|
||||
`make test`, `make build-release`, `make clippy`.
|
||||
|
||||
## Code Review Focus
|
||||
|
||||
Review for:
|
||||
|
||||
Reference in new issue
Block a user