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 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..7689a9ea2 --- /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,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 $(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/ + + # *** tests *** + test_runner: + run: msgq/test_runner + pytest: + run: pytest diff --git a/pyproject.toml b/pyproject.toml index d9f5f81ef..efbb89ad7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,6 @@ dependencies = [ "setuptools", # for distutils "Cython", "scons", - "pre-commit", "ruff", "parameterized", "coverage", @@ -23,7 +22,10 @@ dependencies = [ "pytest", "pytest-retry", "cppcheck", + "cpplint", + "codespell", "ty", + "lefthook", ] # https://beta.ruff.rs/docs/configuration/#using-pyprojecttoml 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 diff --git a/test.sh b/test.sh index a740680b4..d91afb035 100755 --- a/test.sh +++ b/test.sh @@ -1,20 +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 . -pre-commit run --all-files +# *** lint + test *** +lefthook run test -# *** 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"