Repository navigation
Expand file tree
/
Copy pathinit-dev
More file actions
executable file
·59 lines (55 loc) · 1.7 KB
/
Copy pathinit-dev
File metadata and controls
executable file
·59 lines (55 loc) · 1.7 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
#!/usr/bin/env bash
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$DIR"
function print_help () {
echo "Usage: $0 [OPTION]"
echo -e "Setup development environment for Memgraph.\n"
echo "Optional arguments:"
echo -e " -h\tdisplay this help and exit"
echo -e " --ci\tscript is being run inside ci"
}
ci=false
if [[ $# -eq 1 && "$1" == "-h" ]]; then
print_help
exit 0
else
while (($#)); do
case "$1" in
--ci)
shift
ci=true
;;
*)
echo "Invalid argument provided: $1"
print_help
exit 1
;;
esac
done
fi
echo "Linking git hooks OR skip if .git folder is not there"
if [ -d "$DIR/.git" ]; then
for hookpath in $(find "$DIR/.githooks" -type f); do
hook="$(basename "$hookpath")"
ln -s -f "$DIR/.githooks/$hook" "$DIR/.git/hooks/$hook"
echo "Added $hook hook"
done
else
echo "WARNING: .git folder not present, skip adding hooks"
fi
# Install pre-commit hooks only outside CI.
if [[ "$ci" == "false" ]]; then
echo "Installing pre-commit hooks"
# Python >= 3.10 required; resolve_python honors $MG_PYTHON (exported by
# build.sh) and falls back to versioned binaries on distros whose default
# python3 is older (e.g. centos-9).
source "$DIR/environment/util.sh"
PYTHON="$(resolve_python)"
export PIP_BREAK_SYSTEM_PACKAGES=1
# Upgrading pip is best-effort: a Homebrew/distro-managed pip can't uninstall
# itself (no RECORD file), so don't let a failed upgrade abort the script.
"$PYTHON" -m pip install --upgrade pip || true
"$PYTHON" -m pip install pre-commit black==26.5.0 isort==5.12.*
"$PYTHON" -m pre_commit install
fi