Skip to content

Commit

Permalink
Tools: Install pre-commmit for mac, arch, ubuntu
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Friedman <[email protected]>
  • Loading branch information
Ryanf55 committed Sep 11, 2023
1 parent 27e5309 commit 9f2f02a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
6 changes: 5 additions & 1 deletion Tools/environment_install/install-prereqs-arch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ BASE_PKGS="base-devel ccache git gsfonts tk wget gcc"
SITL_PKGS="python-pip python-setuptools python-wheel python-wxpython opencv python-numpy python-scipy"
PX4_PKGS="lib32-glibc zip zlib ncurses"

PYTHON_PKGS="future lxml pymavlink MAVProxy pexpect argparse matplotlib pyparsing geocoder pyserial empy dronecan"
PYTHON_PKGS="future lxml pymavlink MAVProxy pexpect argparse matplotlib pyparsing geocoder pyserial empy dronecan pre-commit"

# GNU Tools for ARM Embedded Processors
# (see https://launchpad.net/gcc-arm-embedded/)
Expand Down Expand Up @@ -113,6 +113,10 @@ SCRIPT_DIR=$(dirname $(realpath ${BASH_SOURCE[0]}))
(
cd "$SCRIPT_DIR"
git submodule update --init --recursive
if [[ $ENABLE_PRE_COMMIT -n 1 ]]; then
echo "Enabling pre-commit."
pre-commit install
fi
)

echo "Done. Please log out and log in again."
2 changes: 1 addition & 1 deletion Tools/environment_install/install-prereqs-mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ if [[ $DO_AP_STM_ENV -eq 1 ]]; then
install_arm_none_eabi_toolchain
fi

PYTHON_PKGS="future lxml pymavlink MAVProxy pexpect geocoder flake8 empy dronecan"
PYTHON_PKGS="future lxml pymavlink MAVProxy pexpect geocoder flake8 empy dronecan pre-commit"
# add some Python packages required for commonly-used MAVProxy modules and hex file generation:
if [[ $SKIP_AP_EXT_ENV -ne 1 ]]; then
PYTHON_PKGS="$PYTHON_PKGS intelhex gnureadline"
Expand Down
16 changes: 13 additions & 3 deletions Tools/environment_install/install-prereqs-ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,13 @@ else
fi

# Lists of packages to install
BASE_PKGS="build-essential ccache g++ gawk git make wget valgrind screen"
PYTHON_PKGS="future lxml pymavlink pyserial MAVProxy pexpect geocoder empy ptyprocess dronecan"
PYTHON_PKGS="$PYTHON_PKGS flake8"
BASE_PKGS="build-essential ccache g++ gawk git make wget valgrind screen pre-commit"
if [ ${RELEASE_CODENAME} == 'bionic' ]; then
# use fixed version for package that drop python2 support
PYTHON_PKGS="future lxml pymavlink MAVProxy pexpect flake8==3.7.9 requests==2.27.1 monotonic==1.6 geocoder empy ptyprocess configparser==4.0.2 click==7.1.2 decorator==4.4.2 dronecan"
else
PYTHON_PKGS="future lxml pymavlink MAVProxy pexpect flake8 geocoder empy ptyprocess dronecan"
fi

# add some Python packages required for commonly-used MAVProxy modules and hex file generation:
if [[ $SKIP_AP_EXT_ENV -ne 1 ]]; then
Expand Down Expand Up @@ -443,4 +447,10 @@ if $IS_DOCKER; then
echo "source ~/.ardupilot_env">> ~/.bashrc
fi

if [[ $ENABLE_PRE_COMMIT -n 1 ]]; then
echo "Enabling pre-commit."
cd ${SCRIPT_DIR}
pre-commit install
fi

echo "---------- $0 end ----------"
7 changes: 7 additions & 0 deletions Tools/scripts/build_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,13 @@ for t in $CI_BUILD_TARGET; do
continue
fi

if [ "$t" == "pre-commit-cleanliness" ]; then
echo "Checking pre-commit code cleanliness"
pre-commit install
pre-commit run --all-files --verbose --show-diff-on-failure
continue
fi

if [ "$t" == "configure-all" ]; then
echo "Checking configure of all boards"
./Tools/scripts/configure_all.py
Expand Down

0 comments on commit 9f2f02a

Please sign in to comment.