From 1f44d76602346cf9b4783aa155703089ced5af57 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sat, 6 Sep 2025 17:48:41 -0700 Subject: [PATCH 1/9] remove pre-commit --- .github/workflows/repo.yml | 27 --------------------- .pre-commit-config.yaml | 49 -------------------------------------- pyproject.toml | 4 +++- test.sh | 13 +++++++--- 4 files changed, 13 insertions(+), 80 deletions(-) delete mode 100644 .github/workflows/repo.yml delete mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/repo.yml b/.github/workflows/repo.yml deleted file mode 100644 index 5f12686f8..000000000 --- a/.github/workflows/repo.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: repo - -on: - schedule: - - cron: "0 15 1 * *" - workflow_dispatch: - -jobs: - pre-commit-autoupdate: - name: pre-commit autoupdate - runs-on: ubuntu-latest - container: - steps: - - uses: actions/checkout@v3 - - name: pre-commit autoupdate - run: | - git config --global --add safe.directory '*' - pre-commit autoupdate - - name: Create Pull Request - uses: peter-evans/create-pull-request@5b4a9f6a9e2af26e5f02351490b90d01eb8ec1e5 - with: - token: ${{ secrets.ACTIONS_CREATE_PR_PAT }} - commit-message: Update pre-commit hook versions - title: 'pre-commit: autoupdate hooks' - branch: pre-commit-updates - base: master - delete-branch: true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index 60271fafe..000000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,49 +0,0 @@ -files: ^msgq/ -repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v6.0.0 - hooks: - - id: check-ast - - id: check-yaml - - id: check-executables-have-shebangs - - id: check-shebang-scripts-are-executable -- repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.17.1 - hooks: - - id: mypy -- repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.12.12 - hooks: - - id: ruff -- repo: local - hooks: - - id: cppcheck - name: cppcheck - entry: cppcheck - language: system - types: [c++] - exclude: '^(msgq/msgq_tests.cc|msgq/test_runner.cc)' - args: - - --error-exitcode=1 - - --inline-suppr - - --language=c++ - - --force - - --quiet - - -j4 - - --check-level=exhaustive -- repo: https://github.com/cpplint/cpplint - rev: 2.0.2 - hooks: - - id: cpplint - args: - - --quiet - - --counting=detailed - - --linelength=240 - - --filter=-build,-legal,-readability,-runtime,-whitespace,+build/include_subdir,+build/forward_decl,+build/include_what_you_use,+build/deprecated,+whitespace/comma,+whitespace/line_length,+whitespace/empty_if_body,+whitespace/empty_loop_body,+whitespace/empty_conditional_body,+whitespace/forcolon,+whitespace/parens,+whitespace/semicolon,+whitespace/tab,+readability/braces -- repo: https://github.com/codespell-project/codespell - rev: v2.4.1 - hooks: - - id: codespell - args: - - -L ned - - --builtins clear,rare,informal,usage,code,names,en-GB_to_en-US diff --git a/pyproject.toml b/pyproject.toml index d7c4e336b..ebd7f40ad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,13 +15,15 @@ dependencies = [ "setuptools", # for distutils "Cython", "scons", - "pre-commit", "ruff", + "mypy", "parameterized", "coverage", "numpy", "pytest", "cppcheck", + "cpplint", + "codespell", ] # https://beta.ruff.rs/docs/configuration/#using-pyprojecttoml diff --git a/test.sh b/test.sh index e0cfe7c2a..75d1b717a 100755 --- a/test.sh +++ b/test.sh @@ -11,9 +11,16 @@ source ./setup.sh scons -j8 # *** lint *** -#ruff check . -#mypy python/ -pre-commit run --all-files +ruff check . +mypy msgq/ + +#codespell -L ned --builtin clear,rare,informal,usage,code,names,en-GB_to_en-US + +#cppcheck --error-exitcode=1 --inline-suppr --language=c++ \ +# --force --quiet -j4 --check-level=exhaustive +#pre-commit run --all-files + +exit 0 # *** test *** pytest From 32908b60030066c16c29b723d8e5b183276e1a45 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sat, 27 Dec 2025 23:56:16 -0800 Subject: [PATCH 2/9] cleanup --- test.sh | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/test.sh b/test.sh index 2122d8b72..899525c1b 100755 --- a/test.sh +++ b/test.sh @@ -12,15 +12,11 @@ scons -j8 # *** lint *** ruff check . -mypy msgq/ -#codespell -L ned --builtin clear,rare,informal,usage,code,names,en-GB_to_en-US +codespell -L ned --builtin clear,rare,informal,usage,code,names,en-GB_to_en-US -#cppcheck --error-exitcode=1 --inline-suppr --language=c++ \ -# --force --quiet -j4 --check-level=exhaustive -#pre-commit run --all-files - -exit 0 +cppcheck --error-exitcode=1 --inline-suppr --language=c++ \ + --force --quiet -j4 --check-level=exhaustive # *** test *** msgq/test_runner From 709435a30e770c254ccef398fc917a543f3c3567 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sat, 27 Dec 2025 23:59:12 -0800 Subject: [PATCH 3/9] fix codespell --- test.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test.sh b/test.sh index 899525c1b..1e9df810b 100755 --- a/test.sh +++ b/test.sh @@ -13,7 +13,8 @@ scons -j8 # *** lint *** ruff check . -codespell -L ned --builtin clear,rare,informal,usage,code,names,en-GB_to_en-US +codespell -L ned,stdio --builtin clear,rare,informal,usage,code,names,en-GB_to_en-US \ + --skip uv.lock,*_pyx.cpp,catch2* cppcheck --error-exitcode=1 --inline-suppr --language=c++ \ --force --quiet -j4 --check-level=exhaustive From 573f9075c7fa962dcb0ec97a31654d32d3f554dc Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sun, 28 Dec 2025 00:16:33 -0800 Subject: [PATCH 4/9] lil more --- test.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test.sh b/test.sh index 91c346efc..ffb3bf5db 100755 --- a/test.sh +++ b/test.sh @@ -18,7 +18,8 @@ codespell -L ned,stdio --builtin clear,rare,informal,usage,code,names,en-GB_to_e --skip uv.lock,*_pyx.cpp,catch2* cppcheck --error-exitcode=1 --inline-suppr --language=c++ \ - --force --quiet -j4 --check-level=exhaustive + --force --quiet -j4 --check-level=exhaustive \ + --suppress='*:msgq/catch2/*' --suppress='*:*_pyx.cpp' --suppress='*:*_tests.cc' msgq/ visionipc/ # *** test *** msgq/test_runner From f7893301c7fabeac32be357fb17627ccd9238d67 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sun, 28 Dec 2025 00:30:46 -0800 Subject: [PATCH 5/9] lefthook --- .pre-commit-config.yaml | 45 ----------------------------------------- lefthook.yml | 32 +++++++++++++++++++++++++++++ test.sh | 22 +++++++------------- 3 files changed, 39 insertions(+), 60 deletions(-) delete mode 100644 .pre-commit-config.yaml create mode 100644 lefthook.yml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index 9edc70481..000000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,45 +0,0 @@ -files: ^msgq/ -repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v6.0.0 - hooks: - - id: check-ast - - id: check-yaml - - id: check-executables-have-shebangs - - id: check-shebang-scripts-are-executable -- repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.12.12 - hooks: - - id: ruff -- repo: local - hooks: - - id: cppcheck - name: cppcheck - entry: cppcheck - language: system - types: [c++] - exclude: '^(msgq/msgq_tests.cc|msgq/test_runner.cc)' - args: - - --error-exitcode=1 - - --inline-suppr - - --language=c++ - - --force - - --quiet - - -j4 - - --check-level=exhaustive -- repo: https://github.com/cpplint/cpplint - rev: 2.0.2 - hooks: - - id: cpplint - args: - - --quiet - - --counting=detailed - - --linelength=240 - - --filter=-build,-legal,-readability,-runtime,-whitespace,+build/include_subdir,+build/forward_decl,+build/include_what_you_use,+build/deprecated,+whitespace/comma,+whitespace/line_length,+whitespace/empty_if_body,+whitespace/empty_loop_body,+whitespace/empty_conditional_body,+whitespace/forcolon,+whitespace/parens,+whitespace/semicolon,+whitespace/tab,+readability/braces -- repo: https://github.com/codespell-project/codespell - rev: v2.4.1 - hooks: - - id: codespell - args: - - -L ned - - --builtins clear,rare,informal,usage,code,names,en-GB_to_en-US diff --git a/lefthook.yml b/lefthook.yml new file mode 100644 index 000000000..46fef8a2e --- /dev/null +++ b/lefthook.yml @@ -0,0 +1,32 @@ +output: + - meta # Print lefthook version + - summary # Print summary block (successful and failed steps) + - empty_summary # Print summary heading when there are no steps to run + - success # Print successful steps + - failure # Print failed steps printing + - execution # Print any execution logs + #- execution_out # Print execution output + #- execution_info # Print `EXECUTE > ...` logging + - skips # Print "skip" (i.e. no files matched) + +test: + parallel: true + commands: + # *** static analysis *** + ruff: + run: ruff check . + ty: + run: ty check . + codespell: + run: codespell {files} -L ned,stdio --builtin clear,rare,informal,usage,code,names,en-GB_to_en-US -S uv.lock,*_pyx.cpp,catch2* + files: git ls-tree -r HEAD --name-only + cppcheck: + run: cppcheck --error-exitcode=1 --inline-suppr --language=c++ --force --quiet -j4 --check-level=exhaustive --suppress='*:msgq/catch2/*' --suppress='*:*_pyx.cpp' --suppress='*:*_tests.cc' msgq/ + cpplint: + run: cpplint --exclude=msgq/catch2/ --exclude=*_pyx.cpp --recursive --quiet --counting=detailed --linelength=240 --filter=-build,-legal,-readability,-runtime,-whitespace,+build/include_subdir,+build/forward_decl,+build/include_what_you_use,+build/deprecated,+whitespace/comma,+whitespace/line_length,+whitespace/empty_if_body,+whitespace/empty_loop_body,+whitespace/empty_conditional_body,+whitespace/forcolon,+whitespace/parens,+whitespace/semicolon,+whitespace/tab,+readability/braces msgq/ + + # *** tests *** + test_runner: + run: msgq/test_runner + pytest: + run: pytest diff --git a/test.sh b/test.sh index ffb3bf5db..d91afb035 100755 --- a/test.sh +++ b/test.sh @@ -1,26 +1,18 @@ -#!/usr/bin/env bash +#!/bin/bash set -e DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" cd $DIR -# *** env setup *** source ./setup.sh # *** build *** scons -j8 -# *** lint *** -ty check . -ruff check . +# *** lint + test *** +lefthook run test -codespell -L ned,stdio --builtin clear,rare,informal,usage,code,names,en-GB_to_en-US \ - --skip uv.lock,*_pyx.cpp,catch2* - -cppcheck --error-exitcode=1 --inline-suppr --language=c++ \ - --force --quiet -j4 --check-level=exhaustive \ - --suppress='*:msgq/catch2/*' --suppress='*:*_pyx.cpp' --suppress='*:*_tests.cc' msgq/ visionipc/ - -# *** test *** -msgq/test_runner -pytest +# *** all done *** +GREEN='\033[0;32m' +NC='\033[0m' +printf "\n${GREEN}All good!${NC} Finished build, lint, and test in ${SECONDS}s\n" From cfbbf7885fe20bf1bd4bad40815b887f65152389 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sun, 28 Dec 2025 00:31:43 -0800 Subject: [PATCH 6/9] lil more --- lefthook.yml | 2 +- pyproject.toml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lefthook.yml b/lefthook.yml index 46fef8a2e..8b7f0d0ba 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -18,7 +18,7 @@ test: ty: run: ty check . codespell: - run: codespell {files} -L ned,stdio --builtin clear,rare,informal,usage,code,names,en-GB_to_en-US -S uv.lock,*_pyx.cpp,catch2* + run: codespell {files} -L ned,stdio,master --builtin clear,rare,informal,usage,code,names,en-GB_to_en-US -S uv.lock,*_pyx.cpp,catch2* files: git ls-tree -r HEAD --name-only cppcheck: run: cppcheck --error-exitcode=1 --inline-suppr --language=c++ --force --quiet -j4 --check-level=exhaustive --suppress='*:msgq/catch2/*' --suppress='*:*_pyx.cpp' --suppress='*:*_tests.cc' msgq/ diff --git a/pyproject.toml b/pyproject.toml index 86f2aa05d..efbb89ad7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,6 +25,7 @@ dependencies = [ "cpplint", "codespell", "ty", + "lefthook", ] # https://beta.ruff.rs/docs/configuration/#using-pyprojecttoml From 1e85c88455c462f8bef9af5e172cff0eb9536644 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sun, 28 Dec 2025 08:42:12 -0800 Subject: [PATCH 7/9] fix cpplint --- lefthook.yml | 2 +- setup.sh | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lefthook.yml b/lefthook.yml index 8b7f0d0ba..09b20efaf 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -23,7 +23,7 @@ test: cppcheck: run: cppcheck --error-exitcode=1 --inline-suppr --language=c++ --force --quiet -j4 --check-level=exhaustive --suppress='*:msgq/catch2/*' --suppress='*:*_pyx.cpp' --suppress='*:*_tests.cc' msgq/ cpplint: - run: cpplint --exclude=msgq/catch2/ --exclude=*_pyx.cpp --recursive --quiet --counting=detailed --linelength=240 --filter=-build,-legal,-readability,-runtime,-whitespace,+build/include_subdir,+build/forward_decl,+build/include_what_you_use,+build/deprecated,+whitespace/comma,+whitespace/line_length,+whitespace/empty_if_body,+whitespace/empty_loop_body,+whitespace/empty_conditional_body,+whitespace/forcolon,+whitespace/parens,+whitespace/semicolon,+whitespace/tab,+readability/braces msgq/ + run: cpplint --exclude=msgq/catch2/ --exclude=msgq/ipc_pyx.cpp --exclude=msgq/visionipc/visionipc_pyx.cpp --recursive --quiet --counting=detailed --linelength=240 --filter=-build,-legal,-readability,-runtime,-whitespace,+build/include_subdir,+build/forward_decl,+build/include_what_you_use,+build/deprecated,+whitespace/comma,+whitespace/line_length,+whitespace/empty_if_body,+whitespace/empty_loop_body,+whitespace/empty_conditional_body,+whitespace/forcolon,+whitespace/parens,+whitespace/semicolon,+whitespace/tab,+readability/braces msgq/ # *** tests *** test_runner: diff --git a/setup.sh b/setup.sh index 8d0611628..abba95d05 100755 --- a/setup.sh +++ b/setup.sh @@ -8,8 +8,6 @@ PLATFORM=$(uname -s) echo "installing dependencies" if [[ $PLATFORM == "Darwin" ]]; then - export ZMQ=1 - export HOMEBREW_NO_AUTO_UPDATE=1 brew install python3 zeromq elif [[ $PLATFORM == "Linux" ]]; then From bed71fe63d596c331369a387b5f38473ce3e0c26 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sun, 28 Dec 2025 08:46:14 -0800 Subject: [PATCH 8/9] brew install has a ton of overhead --- setup.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/setup.sh b/setup.sh index abba95d05..f674859f3 100755 --- a/setup.sh +++ b/setup.sh @@ -8,8 +8,10 @@ PLATFORM=$(uname -s) echo "installing dependencies" if [[ $PLATFORM == "Darwin" ]]; then - export HOMEBREW_NO_AUTO_UPDATE=1 - brew install python3 zeromq + if ! command -v python3 &>/dev/null || ! pkg-config --exists libzmq 2>/dev/null; then + export HOMEBREW_NO_AUTO_UPDATE=1 + brew install python3 zeromq + fi elif [[ $PLATFORM == "Linux" ]]; then # for AGNOS since we clear the apt lists if [[ ! -d /"var/lib/apt/" ]]; then From 53f241071eb10d5339b34645fcdd6b42e3a97151 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sun, 28 Dec 2025 10:04:33 -0800 Subject: [PATCH 9/9] speed up cppcheck --- lefthook.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lefthook.yml b/lefthook.yml index 09b20efaf..7689a9ea2 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -21,7 +21,7 @@ test: run: codespell {files} -L ned,stdio,master --builtin clear,rare,informal,usage,code,names,en-GB_to_en-US -S uv.lock,*_pyx.cpp,catch2* files: git ls-tree -r HEAD --name-only cppcheck: - run: cppcheck --error-exitcode=1 --inline-suppr --language=c++ --force --quiet -j4 --check-level=exhaustive --suppress='*:msgq/catch2/*' --suppress='*:*_pyx.cpp' --suppress='*:*_tests.cc' msgq/ + run: cppcheck --error-exitcode=1 --inline-suppr --language=c++ --force --quiet -j4 --check-level=exhaustive $(git ls-files '*.cc' | grep -v -E '(msgq_tests|test_runner)\.cc') cpplint: run: cpplint --exclude=msgq/catch2/ --exclude=msgq/ipc_pyx.cpp --exclude=msgq/visionipc/visionipc_pyx.cpp --recursive --quiet --counting=detailed --linelength=240 --filter=-build,-legal,-readability,-runtime,-whitespace,+build/include_subdir,+build/forward_decl,+build/include_what_you_use,+build/deprecated,+whitespace/comma,+whitespace/line_length,+whitespace/empty_if_body,+whitespace/empty_loop_body,+whitespace/empty_conditional_body,+whitespace/forcolon,+whitespace/parens,+whitespace/semicolon,+whitespace/tab,+readability/braces msgq/