diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2141cb02..c0296cc5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,6 +12,9 @@ jobs: set -e docker build -t opendbc . name: "Build" + - name: Static analysis + run: | + docker run opendbc bash -c "cd opendbc && git init && git add -A && pre-commit run --all" - run: | docker run opendbc bash -c "python -m unittest discover opendbc" name: "Unit tests" diff --git a/.gitignore b/.gitignore index 1e219f2b..26a5b456 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.mypy_cache/ *.pyc *.os *.tmp diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..602d9d8e --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,27 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: master + hooks: + - id: check-ast + - id: check-json + - id: check-xml + - id: check-yaml +- repo: https://github.com/pre-commit/mirrors-mypy + rev: master + hooks: + - id: mypy +- repo: https://github.com/PyCQA/flake8 + rev: master + hooks: + - id: flake8 + args: + - --select=F +- repo: local + hooks: + - id: pylint + name: pylint + entry: pylint + language: system + types: [python] + args: + - --disable=R,C,W diff --git a/Dockerfile b/Dockerfile index 6a4bc4e5..4b5a2fe3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,7 @@ RUN pyenv rehash COPY requirements.txt /tmp/ RUN pip install -r /tmp/requirements.txt +RUN pip install pre-commit==2.4.0 pylint==2.5.2 ENV PYTHONPATH=/project @@ -20,4 +21,5 @@ RUN git clone https://github.com/commaai/cereal.git /project/cereal COPY SConstruct . COPY . /project/opendbc +RUN rm -rf /project/opendbc/.git RUN scons -c && scons -j$(nproc)