aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnders Betts <anders.betts@gmail.com>2026-09-20 22:08:08 +0200
committerAnders Betts <anders.betts@gmail.com>2026-09-20 22:08:08 +0200
commit6ff31279d38bd3b814f19b1fb63933544139f6cf (patch)
treee0a64a48df9d484b52829371d648698471895ffe
parent29969ad294d1654f6eca23a16c83b84bbf7f9bfe (diff)
build: make gate with WERROR and a pre-push hook
-rwxr-xr-x.githooks/pre-push4
-rw-r--r--AGENTS.md3
-rw-r--r--Makefile8
-rwxr-xr-xscripts/install-hooks.sh5
4 files changed, 19 insertions, 1 deletions
diff --git a/.githooks/pre-push b/.githooks/pre-push
new file mode 100755
index 0000000..4196081
--- /dev/null
+++ b/.githooks/pre-push
@@ -0,0 +1,4 @@
+#!/bin/sh
+set -eu
+cd "$(git rev-parse --show-toplevel)"
+exec make gate
diff --git a/AGENTS.md b/AGENTS.md
index 9798b4a..0008428 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -94,6 +94,9 @@ helpers and `struct app` are in `clients/ui.[ch]`; the scene registry
- Sanitizers: `make test-asan` (ASan) and `make test-ubsan` (UBSan) build
`test_core` in `build-asan`/`build-ubsan`. Run them after touching
allocation or arithmetic paths.
+- Before you stop: `make gate` — a clean rebuild with `WERROR=1`, the full
+ suite and `test-asan`. `sh scripts/install-hooks.sh` points
+ `core.hooksPath` at `.githooks/` so the pre-push hook runs it automatically.
- Never run `bokftui` for tests without `scripts/tui-sandbox.sh`: it
isolates `XDG_CONFIG_HOME`/`XDG_CACHE_HOME` so a run cannot overwrite the
human's `~/.config/bokf/tui.conf`, `~/.cache/bokf/tui.log` or bw session.
diff --git a/Makefile b/Makefile
index f0b2255..dfdac40 100644
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,7 @@ VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null \
WARN = -Wall -Wextra -Wshadow -Wstrict-prototypes -Wmissing-prototypes \
-Wpointer-arith -Wvla -Wformat=2
+WARN += $(if $(WERROR),-Werror)
DEPFLAGS = -MMD -MP
CPPFLAGS = -Isrc -Iclients -Ivendor -Ivendor/argon2
DEFS = -D_GNU_SOURCE -DARGON2_NO_THREADS -DBOKF_VERSION=\"$(VERSION)\"
@@ -109,6 +110,11 @@ test-asan:
test-ubsan:
$(MAKE) BUILD=build-ubsan CFLAGS="$(SAN_CFLAGS) -fsanitize=undefined" test-core
+gate:
+ $(MAKE) clean
+ $(MAKE) WERROR=1 test
+ $(MAKE) WERROR=1 test-asan
+
$(BUILD)/vendor/%.o: vendor/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(DEPFLAGS) $(CPPFLAGS) $(DEFS) -w -c $< -o $@
@@ -140,5 +146,5 @@ install: all
clean:
rm -rf $(BUILD) build-asan build-ubsan
-.PHONY: all backend test test-core test-pty check test-asan test-ubsan \
+.PHONY: all backend test test-core test-pty check test-asan test-ubsan gate \
install clean
diff --git a/scripts/install-hooks.sh b/scripts/install-hooks.sh
new file mode 100755
index 0000000..02e0cfc
--- /dev/null
+++ b/scripts/install-hooks.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+set -eu
+cd "$(dirname "$0")/.."
+git config core.hooksPath .githooks
+echo "git hooks: core.hooksPath=.githooks (pre-push runs 'make gate')"