-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathci_verify.sh
More file actions
executable file
·63 lines (50 loc) · 1.33 KB
/
ci_verify.sh
File metadata and controls
executable file
·63 lines (50 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/sh
set -e
install_git_hook() {
local _hook=".git/hooks/$1"
if [ -e "$_hook" ]; then
echo "$_hook already exists"
exit 1
fi
ln -s $(realpath ci_verify.sh) $_hook
echo "linked ci_verify.sh to $_hook"
exit 0
}
for arg in "$@"; do
case $arg in
"--on-git-commit")
install_git_hook pre-commit;;
"--on-git-push")
install_git_hook pre-push;;
esac
done
# validate local github workflow changes on commit or ./ci_verify.sh
validate_gh_wf_if_changed() {
_changes=$(git status)
if echo "$_changes" | grep -Eq "\.github/workflows/.*?\.ya?ml"; then
model-t .
fi
}
if [ "$0" = ".git/hooks/pre-commit" ]; then
validate_gh_wf_if_changed
fi
if echo "$0" | grep -q "ci_verify\.sh$"; then
validate_gh_wf_if_changed
fi
# validate committed github workflow changes on push
if [ "$0" = ".git/hooks/pre-push" ]; then
read -a _input
_changes=$(git diff --name-only ${_input[1]} ${_input[3]})
if echo "$_changes" | grep -Eq "^\.github/workflows/.*?\.ya?ml$"; then
model-t .
fi
fi
# verify env has build tool dependencies
if ! command -v "pnpm" &> /dev/null; then
_url="https://pnpm.io/installation"
echo "\033[31merror:\033[0m pnpm is required for contributing\n\n $_url\n"
fi
# run through all the checks done for ci
pnpm build
pnpm test
pnpm fmtcheck