Skip to content

Commit

Permalink
make pylint
Browse files Browse the repository at this point in the history
make local python style checking easier
moved pylint.sh from contrib/CI to contrib
  • Loading branch information
calccrypto committed Oct 25, 2023
1 parent 7b8ff44 commit 8dd5b71
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
run: cmake -B ${{ github.workspace }}/build ${{ env.COMMON_CONFIG }} -DCMAKE_BUILD_TYPE=Debug -DPRINT_CUMULATIVE_TIMES=On

- name: Run Python3 Pylint
run: contrib/CI/pylint.sh ${{ github.workspace }}/build
run: make pylint

Older_CMake:
needs: [ShellCheck, Pylint]
Expand Down
11 changes: 11 additions & 0 deletions contrib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@ if (CMAKE_CXX_COMPILER)
add_dependencies(verifytraceintree install_dependencies)
endif()

# add 'make pylint'
find_program(PYLINT pylint)
if (PYLINT)
message(STATUS "Found pylint: ${PYLINT}")
configure_file(pylint.sh pylint.sh @ONLY)
add_custom_target(pylint
COMMAND "${CMAKE_CURRENT_BINARY_DIR}/pylint.sh" "${CMAKE_BINARY_DIR}")
else()
message(STATUS "pylint not found")
endif()

# potentially useful scripts
set(USEFUL
canned_queries.sh
Expand Down
17 changes: 15 additions & 2 deletions contrib/CI/pylint.sh → contrib/pylint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,24 @@ set -e
BUILD="$(realpath $1)"

# shellcheck disable=SC2155
export PYTHONPATH="$(realpath ${BUILD}/contrib):$(realpath ${BUILD}/contrib/performance):$(realpath ${BUILD}/scripts):$(realpath ${BUILD}/test):${PYTHONPATH}"
export PYTHONPATH="${BUILD}/contrib:${BUILD}/scripts:${BUILD}/test:${PYTHONPATH}"

# not scanning ${BUILD}/contrib
PATHS=(
"${BUILD}/scripts"
"${BUILD}/test"
)

# performance history framework is optional
PERF="${BUILD}/contrib/performance"
if [[ -d "${PERF}" ]]
then
export PYTHONPATH="${PERF}:${PYTHONPATH}"
PATHS+=("${PERF}")
fi

# shellcheck disable=SC2044
for file in $(find "${BUILD}/contrib/performance" "${BUILD}/scripts" "${BUILD}/test" -type f)
for file in $(find "${PATHS[@]}" -type f)
do
if [[ "$(head -n 1 ${file} | strings)" =~ ^#!/usr/bin/env\ python(2|3).*$ ]]
then
Expand Down

0 comments on commit 8dd5b71

Please sign in to comment.