-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpre-commit
More file actions
executable file
·43 lines (31 loc) · 1.08 KB
/
pre-commit
File metadata and controls
executable file
·43 lines (31 loc) · 1.08 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
#!/bin/bash
set -e
SELF_DIR="$(cd "$(dirname "$0")"; pwd)"
# Delete the current .venv and reinstall it. This is so that the version number
# is reflected correctly if it has been changed in pyproject.toml
VENV_PYTHON="$SELF_DIR/.venv"
if [ -d "$VENV_PYTHON" ]; then
rm -rf "$VENV_PYTHON"
fi
cd "$SELF_DIR"
# Setup the .venv
"$SELF_DIR/util/pyziggy-setup" --use-cwd setup
# Run tests
"$SELF_DIR/.venv/bin/python" -m unittest discover -s "$SELF_DIR/tests"
# Reformat everything with black
"$SELF_DIR/.venv/bin/python" -m black "$SELF_DIR/src" "$SELF_DIR/tests"
# Generate docs
source "$SELF_DIR/.venv/bin/activate"
pushd "$SELF_DIR/docs"
make clean
make html
popd
# Look for an outdated version in pyziggy-setup
VERSION="$("$SELF_DIR/.venv/bin/python" -c 'import importlib.metadata; print(importlib.metadata.version("pyziggy"))')"
VERSION_MISMATCH=$(grep 'pyziggy==' util/pyziggy-setup | grep -v "pyziggy==$VERSION" | cat)
if [ -n "$VERSION_MISMATCH" ]; then
echo "Mismatching version string found in util/pyziggy-setup"
echo "$VERSION_MISMATCH"
exit 1
fi
echo "GOOD TO GO!"