From 526043e053cb65b9fe9b54262e829710e060ae40 Mon Sep 17 00:00:00 2001 From: Jack Rosenthal Date: Thu, 5 May 2022 12:29:17 -0600 Subject: zephyr: zmake: Skip running flake8 on BUILD.py files during pre-upload flake8 reports more errors than necessary on BUILD.py files because: - They are out of the zmake tree, and therefore do not have the correct .flake8 config file. - flake8 is confused by undefined variables like "here" and "register_project", which come from the execution context zmake provides. These are just config files anyway, running flake8 on them is likely overkill. Turn that off. BUG=none BRANCH=none TEST=for f in $(git ls-files); do zephyr/zmake/pre-upload.sh "$(realpath "${f}")" done Signed-off-by: Jack Rosenthal Change-Id: Ia6eae025ec560d3f6dbdc5c8a4ce50d7b9b94459 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3630476 Reviewed-by: Jeremy Bettis --- zephyr/zmake/pre-upload.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/zephyr/zmake/pre-upload.sh b/zephyr/zmake/pre-upload.sh index 3c2c42b49e..15b6637f44 100755 --- a/zephyr/zmake/pre-upload.sh +++ b/zephyr/zmake/pre-upload.sh @@ -4,16 +4,22 @@ # found in the LICENSE file. set -e -AFFECTED_FILES=() +ZMAKE_FILES=() +BUILD_PY_FILES=() for path in "$@"; do case "${path}" in - *zephyr/zmake/*.py | *zephyr/projects/*.py) - AFFECTED_FILES+=("${path}") + *zephyr/zmake/*.py ) + ZMAKE_FILES+=("${path}") + ;; + */BUILD.py ) + BUILD_PY_FILES+=("${path}") ;; esac done +AFFECTED_FILES=("${ZMAKE_FILES[@]}" "${BUILD_PY_FILES[@]}") + if [ "${#AFFECTED_FILES}" -eq 0 ]; then # No zmake changes made, do nothing. exit 0 @@ -46,7 +52,9 @@ if [ -f /etc/cros_chroot_version ]; then cd "$(dirname "$(realpath -e "${BASH_SOURCE[0]}")")" wrap_fix_msg black --check --diff "${AFFECTED_FILES[@]}" wrap_fix_msg isort --check "${AFFECTED_FILES[@]}" - flake8 "${AFFECTED_FILES[@]}" || EXIT_STATUS=1 + if [ "${#ZMAKE_FILES[@]}" -gt 0 ]; then + flake8 "${ZMAKE_FILES[@]}" || EXIT_STATUS=1 + fi exit "${EXIT_STATUS}" else cat <&2 -- cgit v1.2.1