Skip to content

Commit 3279fd8

Browse files
committed
feat(mise): add git:pre-push task for branch validation and conditional tests
1 parent 151cdfd commit 3279fd8

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

mise.toml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,33 @@ if echo "$changed" | grep -qE "Dockerfile$"; then
5959
echo "$changed" | grep -E "Dockerfile$" | xargs hadolint || exit 1
6060
fi
6161
'''
62+
63+
[tasks."git:pre-push"]
64+
description = "Validate branch name and run tests before push"
65+
run = '''
66+
#!/usr/bin/env bash
67+
pnpm dlx @gracefullight/validate-branch || exit 1
68+
69+
# Get changed files compared to origin
70+
changed=$(git diff --name-only origin/main...HEAD 2>/dev/null || git diff --name-only HEAD~1)
71+
72+
if echo "$changed" | grep -q "^apps/api/"; then
73+
echo "[pre-push] apps/api detected, running test..."
74+
mise //apps/api:test || exit 1
75+
fi
76+
77+
if echo "$changed" | grep -q "^apps/web/"; then
78+
echo "[pre-push] apps/web detected, running test..."
79+
mise //apps/web:test || exit 1
80+
fi
81+
82+
if echo "$changed" | grep -q "^apps/worker/"; then
83+
echo "[pre-push] apps/worker detected, running test..."
84+
mise //apps/worker:test || exit 1
85+
fi
86+
87+
if echo "$changed" | grep -q "^apps/mobile/"; then
88+
echo "[pre-push] apps/mobile detected, running test..."
89+
mise //apps/mobile:test || exit 1
90+
fi
91+
'''

0 commit comments

Comments
 (0)