Skip to content

Commit

Permalink
run static analysis in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
pd0wm committed May 28, 2020
1 parent 86b0476 commit 348446f
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ jobs:
- uses: actions/checkout@v2
- name: Build docker image
run: docker build -t rednose .
- name: Static analysis
run: |
docker run cereal bash -c "git init && git add -A && pre-commit run --all"
- name: Unit Tests
run: docker run rednose bash -c "cd /project/rednose/examples; python -m unittest discover"
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,12 +7,13 @@ 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 scons==3.1.1
RUN pip3 install scons==3.1.1 pre-commit==2.4.0 pylint==2.5.2

WORKDIR /project/rednose

ENV PYTHONPATH=/project

COPY . .
RUN rm -rf .git
RUN python3 setup.py install
RUN scons -c && scons -j$(nproc)
4 changes: 2 additions & 2 deletions examples/test_kinematic_kf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np
import unittest

from kinematic_kf import KinematicKalman, ObservationKind, States
from kinematic_kf import KinematicKalman, ObservationKind, States # pylint: disable=import-error

GENERATED_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), 'generated'))

Expand Down Expand Up @@ -55,7 +55,7 @@ def test_kinematic_kf(self):
self.assertAlmostEqual(vs_kf_std[-1], 0.6695762270974388)

if "PLOT" in os.environ:
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt # pylint: disable=import-error
plt.figure()
plt.subplot(2, 1, 1)
plt.plot(ts, xs, 'k', label='Simulation')
Expand Down
2 changes: 1 addition & 1 deletion rednose/helpers/sympy_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def euler2quat(eulers):
quats = np.array([q0, q1, q2, q3]).T
for i in range(len(quats)):
if quats[i,0] < 0:
quats[i] = -quats[i]
quats[i] = -quats[i] # pylint: disable=unsupported-assignment-operation
return quats.reshape(output_shape)


Expand Down

0 comments on commit 348446f

Please sign in to comment.