From 84e911687780a070b39fd676393ea8a8c901c609 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Sat, 21 Nov 2026 13:55:00 +1100 Subject: [PATCH] build: add task wt:check for checking a worktree's changed packages --- Taskfile.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Taskfile.yml b/Taskfile.yml index 186bc99c8..0f83fe275 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -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: