-#!/bin/sh -exu
+#!/bin/bash
#
-# Copyright (C) 2015 - Michael Jeanson <mjeanson@efficios.com>
+# Copyright (C) 2019 Michael Jeanson <mjeanson@efficios.com>
+# Copyright (C) 2019 Francis Deslauriers <francis.deslauriers@efficios.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-BABELTRACE_DIR="deps/babeltrace/build"
+set -exu
-PYTHON3=python3
-P3_VERSION=$($PYTHON3 -c "import sys;print(sys.version[:3])")
+set -o pipefail
-BINDINGS_DIR="$BABELTRACE_DIR/lib/python${P3_VERSION}/dist-packages/babeltrace"
+PYTHON3=python3
+SRCDIR="$WORKSPACE/src/babeltrace"
PYENV_HOME="$WORKSPACE/.pyenv/"
# Delete previously built virtualenv
# Create virtualenv and install necessary packages
virtualenv --system-site-packages -p ${PYTHON3} "$PYENV_HOME"
-set +u
+set +ux
+# shellcheck disable=SC1090
. "$PYENV_HOME/bin/activate"
-set -u
+set -ux
+
+if [ -f "$SRCDIR/dev-requirements.txt" ]; then
+ pip install -r "$SRCDIR/dev-requirements.txt"
+else
+ pip install --quiet black
+ pip install --quiet flake8
+fi
+
+exit_code=0
-pip install --quiet pylint
-pip install --quiet pep8
+cd "$SRCDIR"
-pep8 --exclude="nativebt.py" "$BINDINGS_DIR" | tee pep8.out
+black --diff --check . | tee ../../black.out || exit_code=1
+flake8 --output-file=../../flake8.out --tee || exit_code=1
-pylint -f parseable --ignore="nativebt.py" "$BINDINGS_DIR" | tee pylint.out
+exit $exit_code