build: add task wt:check for checking a worktree's changed packages

This commit is contained in:
sam committed 2026-11-21 13:55:00 +11:00
1 parent f47e60db00
commit 84e9116877
1 file changed
+26
+26
View File
@@ -363,6 +363,32 @@ tasks:
- task: openapi:check
- task: check:readonly
wt:check:
desc: "Check a worktree's Go packages and the dashboard if ui/ changed (-- ./pkg/... to name packages; default: those changed since main)"
# A worktree has no ui/dist, so the Go steps build with no_ui. The full
# gate still runs once, on the merged tree.
cmds:
- |
set -eu
base="$(git merge-base HEAD main)"
changed="$( { git diff --name-only "$base"; git ls-files --others --exclude-standard; } | sort -u)"
pkgs="{{.CLI_ARGS}}"
if [ -z "$pkgs" ]; then
pkgs="$(printf '%s\n' "$changed" | grep '\.go$' | grep -v '^ui/' | xargs -r -n1 dirname | sort -u | while read -r d; do [ -d "$d" ] && echo "./$d"; done | tr '\n' ' ')"
fi
if [ -n "$pkgs" ]; then
echo "packages: $pkgs"
go vet -tags no_ui $pkgs
go test -short -tags no_ui $pkgs
golangci-lint run --build-tags no_ui $pkgs
fi
if printf '%s\n' "$changed" | grep -q '^ui/'; then
"{{.TASK_EXE}}" test:ui
fi
if [ -z "$pkgs" ] && ! printf '%s\n' "$changed" | grep -q '^ui/'; then
echo "nothing changed since main"
fi
check:readonly:
internal: true
deps: