Skip to content

Commit

Permalink
add pre-commit static analysis (emmertex#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
pd0wm authored May 28, 2020
1 parent f27222f commit 8e2d212
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ jobs:
- uses: actions/checkout@v2
- name: Build docker image
run: docker build -t cereal .
- name: Static analysis
run: |
docker run cereal bash -c "git init && git add -A && pre-commit run --all"
- name: Unit Tests
run: |
docker run cereal bash -c "scons --test --asan -j$(nproc) && messaging/test_runner"
Expand All @@ -20,4 +23,3 @@ jobs:
- name: Test MSGQ
run: |
docker run cereal bash -c "MSGQ=1 python -m unittest discover ."
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ libmessaging_shared.*
services.h
.sconsign.dblite
libcereal_shared.*

.mypy_cache/
27 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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://gitlab.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
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ ENV PATH="/root/.pyenv/bin:/root/.pyenv/shims:${PATH}"
RUN pyenv install 3.7.3
RUN pyenv global 3.7.3
RUN pyenv rehash
RUN pip3 install pyyaml==5.1.2 Cython==0.29.14 scons==3.1.1 pycapnp==0.6.4
RUN pip3 install pyyaml==5.1.2 Cython==0.29.14 scons==3.1.1 pycapnp==0.6.4 pre-commit==2.4.0 pylint==2.5.2

WORKDIR /project/cereal

ENV PYTHONPATH=/project

COPY . .
RUN rm -rf .git
RUN scons -c && scons -j$(nproc)
1 change: 1 addition & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pylint: skip-file
import os
import capnp

Expand Down
2 changes: 1 addition & 1 deletion messaging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def __init__(self, services, ignore_alive=None, addr="127.0.0.1"):

try:
data = new_message(s)
except capnp.lib.capnp.KjException:
except capnp.lib.capnp.KjException: # pylint: disable=c-extension-no-member
# lists
data = new_message(s, 0)

Expand Down

0 comments on commit 8e2d212

Please sign in to comment.