X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=scripts%2Fbabeltrace%2Fpylint.sh;h=839d86266da2edfe4c686ac06e0967b9e4d02270;hb=3b6ded166d659bde14b384ce4b3981d4378852ef;hp=5ed53e979c6db4c432f0663ef0e7c7c28881d4e5;hpb=b0afcb4784ae0bbe4c3dc4db2d9c410f36cb9a29;p=lttng-ci.git diff --git a/scripts/babeltrace/pylint.sh b/scripts/babeltrace/pylint.sh old mode 100644 new mode 100755 index 5ed53e9..839d862 --- a/scripts/babeltrace/pylint.sh +++ b/scripts/babeltrace/pylint.sh @@ -1,6 +1,7 @@ -#!/bin/sh -exu +#!/bin/bash # -# Copyright (C) 2015 - Michael Jeanson +# Copyright (C) 2019 Michael Jeanson +# Copyright (C) 2019 Francis Deslauriers # # 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 @@ -15,22 +16,40 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -BABELTRACE_DIR="deps/babeltrace/build" -BINDINGS_DIR="$BABELTRACE_DIR/lib/python3.4/dist-packages/babeltrace" +set -exu +set -o pipefail + +PYTHON3=python3 + +SRCDIR="$WORKSPACE/src/babeltrace" PYENV_HOME="$WORKSPACE/.pyenv/" # Delete previously built virtualenv -if [ -d $PYENV_HOME ]; then - rm -rf $PYENV_HOME +if [ -d "$PYENV_HOME" ]; then + rm -rf "$PYENV_HOME" fi # Create virtualenv and install necessary packages -virtualenv --system-site-packages -p python3 $PYENV_HOME -. $PYENV_HOME/bin/activate -pip install --quiet pylint -pip install --quiet pep8 +virtualenv --system-site-packages -p ${PYTHON3} "$PYENV_HOME" + +set +ux +# shellcheck disable=SC1090 +. "$PYENV_HOME/bin/activate" +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 + +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