self tests
This commit is contained in:
58
rig/Makefile
58
rig/Makefile
@@ -16,10 +16,26 @@
|
||||
# Identity follows the FOLDER NAME, so this directory can be copied elsewhere,
|
||||
# renamed, and run as a separate environment with no edits. ctrl/.env overrides
|
||||
# it when you want a name that differs from the directory.
|
||||
#
|
||||
# Asked once, of ctrl/ports.sh, which resolves it through lib/config.sh:
|
||||
#
|
||||
# CLUSTER KUBECONTEXT HTTP HTTPS TILT REGISTRY MANIFESTS_DIR
|
||||
#
|
||||
# Read positionally, so the order is a contract — ctrl/selftest.sh pins it.
|
||||
#
|
||||
# This used to be sed over ctrl/.env plus a slug computed here, which is a
|
||||
# SECOND derivation of values lib/config.sh already owns — and the two could
|
||||
# disagree about the port after `make ports persist`, or about the name for any
|
||||
# directory whose sanitised form differs from its raw one. One source now; the
|
||||
# Tiltfile reads the same line.
|
||||
FACTS := $(shell bash ctrl/ports.sh active 2>/dev/null)
|
||||
SLUG := $(shell echo '$(notdir $(CURDIR))' | tr '[:upper:]' '[:lower:]' | tr -c 'a-z0-9-' '-' | sed 's/^-*//; s/-*$$//')
|
||||
CLUSTER := $(or $(shell sed -n 's/^CLUSTER=//p' ctrl/.env 2>/dev/null),$(SLUG))
|
||||
KCTX := --context kind-$(CLUSTER)
|
||||
TILT_PORT := $(shell sed -n 's/^TILT_PORT=//p' ctrl/.env 2>/dev/null)
|
||||
# The fallback matters: ports.sh sources config.sh, and if a profile or .env is
|
||||
# broken it exits non-zero. Losing the cluster name would send --context to the
|
||||
# wrong place, so fall back to the folder rather than to empty.
|
||||
CLUSTER := $(or $(word 1,$(FACTS)),$(SLUG))
|
||||
KCTX := --context $(or $(word 2,$(FACTS)),kind-$(SLUG))
|
||||
TILT_PORT := $(word 5,$(FACTS))
|
||||
DEPSIMG := $(SLUG)-deps
|
||||
|
||||
# Words after the target become the script's subcommand. Make would otherwise
|
||||
@@ -35,7 +51,7 @@ $(eval $(ARGS):;@:)
|
||||
.PHONY: $(ARGS)
|
||||
endif
|
||||
|
||||
.PHONY: help setup check mem deps deps-image pins cluster registry addons ports \
|
||||
.PHONY: help setup check selftest mem deps deps-image pins cluster registry addons ports \
|
||||
newbox dockerhost docs tilt \
|
||||
kind-up kind-down kind-reset tilt-up tilt-down
|
||||
|
||||
@@ -50,6 +66,12 @@ setup: ## prepare this machine [core] [--share-docker]
|
||||
check: ## is this machine ready? reports, never fixes
|
||||
bash ctrl/check.sh
|
||||
|
||||
# The counterpart to check: that one asks about the MACHINE and never fails,
|
||||
# this one asks about RIG and exits 1, the way pins does. The checks are written
|
||||
# as the decisions they defend, so a failure names what is being undone.
|
||||
selftest: ## does rig still do what it says? exits 1 if not
|
||||
bash ctrl/selftest.sh
|
||||
|
||||
mem: ## memory, and any cap holding it [status|backup|restore]
|
||||
bash ctrl/mem.sh $(or $(ARGS),status)
|
||||
|
||||
@@ -91,11 +113,16 @@ dockerhost: ## share Docker between distros [status|share|un
|
||||
docs: ## documentation [serve|graphs] (default serve)
|
||||
bash ctrl/docs.sh $(or $(ARGS),serve)
|
||||
|
||||
# --port is only passed when TILT_PORT is actually set. It comes from ctrl/.env,
|
||||
# which does NOT carry it by default — ports are derived at runtime in
|
||||
# lib/config.sh unless `make ports persist` has written them. Without the guard
|
||||
# tilt receives a bare `--port` with no value and fails on the flag rather than
|
||||
# on anything real. `make ports show` prints the derived block.
|
||||
# --port is only passed when TILT_PORT resolved. It normally does, since FACTS
|
||||
# above asks ports.sh — but ports.sh can fail on a broken profile, and without
|
||||
# the guard tilt receives a bare `--port` with no value and fails on the flag
|
||||
# rather than on anything real. Tilt's own default is 10350, which is the number
|
||||
# every project on this machine is trying not to collide on, so falling back to
|
||||
# it silently is worse than not passing the flag.
|
||||
#
|
||||
# The Tiltfile asks ports.sh for the rest itself — cluster, registry and where
|
||||
# the manifests are — so nothing needs passing here beyond what tilt's own flags
|
||||
# require.
|
||||
tilt: ## dev loop [up|down] (default up)
|
||||
cd ctrl && tilt $(or $(ARGS),up) $(KCTX) $(if $(filter down,$(ARGS)),,$(if $(TILT_PORT),--port $(TILT_PORT)))
|
||||
|
||||
@@ -110,6 +137,11 @@ tilt: ## dev loop [up|down] (default
|
||||
#
|
||||
# `cluster list` and `cluster free` have no hyphenated twin on purpose — they
|
||||
# are rig's own, with nothing to be consistent with.
|
||||
#
|
||||
# Nothing outside this file reads these names: the script is `ctrl/cluster.sh`
|
||||
# and it takes the verb. So rename them, delete the ones you never type, or add
|
||||
# the spelling your own projects use — an alias is two lines, and adding one
|
||||
# costs nothing but a line in .PHONY above.
|
||||
|
||||
kind-up: ## alias for `cluster up`
|
||||
bash ctrl/cluster.sh up
|
||||
@@ -120,10 +152,10 @@ kind-down: ## alias for `cluster down`
|
||||
kind-reset: ## alias for `cluster reset`
|
||||
bash ctrl/cluster.sh reset
|
||||
|
||||
# These two match the other projects' spelling, but rig has no Tiltfile — there
|
||||
# is nothing to run yet, and they fail the same way `make tilt` does.
|
||||
tilt-up: ## alias for `tilt up` (rig has no Tiltfile yet)
|
||||
# These two match the other projects' spelling. rig ships ctrl/Tiltfile, so they
|
||||
# run — it deploys the examples in k8s/base until you replace them.
|
||||
tilt-up: ## alias for `tilt up`
|
||||
cd ctrl && tilt up $(KCTX) $(if $(TILT_PORT),--port $(TILT_PORT))
|
||||
|
||||
tilt-down: ## alias for `tilt down` (rig has no Tiltfile yet)
|
||||
tilt-down: ## alias for `tilt down`
|
||||
cd ctrl && tilt down $(KCTX)
|
||||
|
||||
Reference in New Issue
Block a user