Skip to content

Commit 6ecfa71

Browse files
authored
Add pre-push (#977)
* Add pre-push git hook * Don't run docker-compose in pre-push git-hook Not all contributors use docker-compose. * Setting FD limit to 4096 if possible, shellcheck reports lint issue SC2039 due to "ulimit -n" being undefined under POSIX * Capped FD limit at 4096 In production, the limit is 8096. This is a canary that notices if docs.rs is using too many file descriptors locally and lets the team fix the outage before it affects production.
1 parent 3ed00ad commit 6ecfa71

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

.git_hooks/pre-push

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env sh
2+
fd_hard_limit="$(ulimit -n -H)"
3+
if [ "$fd_hard_limit" = "unlimited" ] || [ "$fd_hard_limit" -ge 4096 ] ; then
4+
ulimit -n 4096
5+
else
6+
ulimit -n "$fd_hard_limit"
7+
fi
8+
9+
if ! cargo test ; then
10+
printf "\n"
11+
printf "\033[0;31mpre-push hook failed during:\033[0m\n"
12+
printf "\033[0;31m\tcargo test\033[0m\n"
13+
exit 1
14+
fi
15+
16+
printf "\n"
17+
printf "\033[0;32mpre-push hook succeeded\033[0m\n"

0 commit comments

Comments
 (0)