From 8f584fa68ac826e365ea325adf93b2778e251bf3 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Thu, 19 Oct 2023 15:14:40 -0400 Subject: [PATCH] jjb: babeltrace: Add 'isort' to pylint jobs Requested by Simon, the script makes sure it doesn't run on stable-15 and stable-2.0 where it's not supported. Change-Id: Ia4617feff900fe7ca9542c06974f1b45371d011b Signed-off-by: Michael Jeanson --- jobs/babeltrace.yaml | 2 +- scripts/babeltrace/pylint.sh | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/jobs/babeltrace.yaml b/jobs/babeltrace.yaml index 8a4ed6a..51dd99e 100644 --- a/jobs/babeltrace.yaml +++ b/jobs/babeltrace.yaml @@ -554,7 +554,7 @@ publishers: - workspace-cleanup: *babeltrace_publisher_workspace-cleanup_defaults - archive: - artifacts: 'black.out,flake8.out' + artifacts: 'black.out,flake8.out,isort.out' allow-empty: false - ircbot: *babeltrace_publisher_ircbot_defaults - email-ext: *babeltrace_publisher_email-ext_defaults diff --git a/scripts/babeltrace/pylint.sh b/scripts/babeltrace/pylint.sh index 839d862..63e02a8 100755 --- a/scripts/babeltrace/pylint.sh +++ b/scripts/babeltrace/pylint.sh @@ -34,15 +34,14 @@ fi virtualenv --system-site-packages -p ${PYTHON3} "$PYENV_HOME" set +ux -# shellcheck disable=SC1090 +# shellcheck disable=SC1090,SC1091 . "$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 + pip install black flake8 isort fi exit_code=0 @@ -52,4 +51,13 @@ cd "$SRCDIR" black --diff --check . | tee ../../black.out || exit_code=1 flake8 --output-file=../../flake8.out --tee || exit_code=1 +ISORT_UNSUPPORTED_BRANCH_REGEX='.*(stable-1\.5|stable-2\.0)$' + +if [[ ! ${GIT_BRANCH:-} =~ $ISORT_UNSUPPORTED_BRANCH_REGEX ]] && \ + [[ ! ${GERRIT_BRANCH:-} =~ $ISORT_UNSUPPORTED_BRANCH_REGEX ]]; then + isort . --diff --check | tee ../../isort.out || exit_code=1 +else + echo "isort is not supported on the 'stable-2.0' branch" > ../../isort.out +fi + exit $exit_code -- 2.34.1