-
Notifications
You must be signed in to change notification settings - Fork 4
/
check.sh
executable file
·50 lines (45 loc) · 1.5 KB
/
check.sh
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
#!/bin/sh
# Copyright 2021 MIT Probabilistic Computing Project
# Apache License, Version 2.0, refer to LICENSE.txt
set -Ceux
: ${PYTHON:=python}
root=$(cd -- "$(dirname -- "$0")" && pwd)
(
set -Ceu
cd -- "${root}"
rm -rf build
"$PYTHON" setup.py build
if [ $# -eq 0 ]; then
# (Default) Run tests/
./pythenv.sh "$PYTHON" -m pytest --pyargs hirm
cd cxx && make tests
elif [ ${1} = 'coverage' ]; then
# Generate coverage report.
./pythenv.sh coverage run --source=build/ -m pytest --pyargs hirm
coverage html
coverage report
elif [ ${1} = 'examples' ]; then
# Run the .py files under examples/
cd examples
for x in *.py; do
MPLBACKEND=agg python "${x}" || continue
done
elif [ ${1} = 'release' ]; then
# Make a release to pypi
rm -rf dist
"$PYTHON" setup.py sdist bdist_wheel
twine upload --repository pypi dist/*
elif [ ${1} = 'tag' ]; then
# Make a tagged release, e.g., ./check.sh 2.0.0
status="$(git diff --stat && git diff --staged)"
[ -z "${status}" ] || (echo 'fatal: tag dirty' && exit 1)
tag="${2}"
sed -i "s/__version__ = .*/__version__ = '${tag}'/g" -- src/__init__.py
git add -- src/__init__.py
git commit -m "Pin version ${tag}."
git tag -a -m v"${tag}" v"${tag}"
else
# If args are specified delegate control to user.
./pythenv.sh "$PYTHON" -m pytest "$@"
fi
)