Static C/C++ analysis in CI (#1564)

albatross
Adeeb 2020-05-28 01:46:30 -07:00 committed by GitHub
parent 29aaa44740
commit 0499ae46b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 9 deletions

View File

@ -37,7 +37,7 @@ jobs:
# need these so docker copy won't fail # need these so docker copy won't fail
cp Pipfile Pipfile.lock flake8_openpilot.sh pylint_openpilot.sh .pylintrc \ cp Pipfile Pipfile.lock flake8_openpilot.sh pylint_openpilot.sh .pylintrc \
.coveragerc-app $TEST_DIR cppcheck_openpilot.sh .coveragerc-app $TEST_DIR
cd $TEST_DIR cd $TEST_DIR
mkdir pyextra laika laika_repo tools release mkdir pyextra laika laika_repo tools release
- name: Build Docker image - name: Build Docker image
@ -49,7 +49,7 @@ jobs:
name: docker push name: docker push
runs-on: ubuntu-16.04 runs-on: ubuntu-16.04
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'commaai/openpilot' if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'commaai/openpilot'
needs: linter # hack to ensure slow tests run first since this and linter are fast needs: static_analysis # hack to ensure slow tests run first since this and static_analysis are fast
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
@ -62,8 +62,8 @@ jobs:
docker tag tmppilot docker.io/commaai/openpilot:latest docker tag tmppilot docker.io/commaai/openpilot:latest
docker push docker.io/commaai/openpilot:latest docker push docker.io/commaai/openpilot:latest
linter: static_analysis:
name: linter name: static analysis
runs-on: ubuntu-16.04 runs-on: ubuntu-16.04
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
@ -75,6 +75,18 @@ jobs:
run: $RUN "cd /tmp/openpilot/ && ./flake8_openpilot.sh" run: $RUN "cd /tmp/openpilot/ && ./flake8_openpilot.sh"
- name: pylint - name: pylint
run: $RUN "cd /tmp/openpilot/ && ./pylint_openpilot.sh" run: $RUN "cd /tmp/openpilot/ && ./pylint_openpilot.sh"
- name: cppcheck
run: $PERSIST "cd /tmp/openpilot/ && ./cppcheck_openpilot.sh 2> cppcheck_report.txt"
- name: Print cppcheck report
if: always()
run: |
docker cp tmppilot:/tmp/openpilot/cppcheck_report.txt cppcheck_report.txt
cat cppcheck_report.txt
- uses: actions/upload-artifact@v2
if: always()
with:
name: cppcheck_report.txt
path: cppcheck_report.txt
unit_tests: unit_tests:
name: unit tests name: unit tests
@ -123,13 +135,11 @@ jobs:
run: | run: |
docker commit tmppilot tmppilotci docker commit tmppilot tmppilotci
$CI_RUN "cd /tmp/openpilot && bash <(curl -s https://codecov.io/bash) -Z -F process_replay" $CI_RUN "cd /tmp/openpilot && bash <(curl -s https://codecov.io/bash) -Z -F process_replay"
- name: Copy diff - name: Print diff
if: always() if: always()
run: | run: |
docker cp tmppilot:/tmp/openpilot/selfdrive/test/process_replay/diff.txt diff.txt docker cp tmppilot:/tmp/openpilot/selfdrive/test/process_replay/diff.txt diff.txt
- name: Print diff cat diff.txt
if: always()
run: cat diff.txt
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v2
if: always() if: always()
with: with:

1
.gitignore vendored
View File

@ -57,6 +57,7 @@ panda_jungle
.coverage* .coverage*
coverage.xml coverage.xml
cppcheck_report.txt
htmlcov htmlcov
pandaextra pandaextra

View File

@ -46,7 +46,6 @@ ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8 ENV LC_ALL en_US.UTF-8
# Install python dependencies
RUN curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash RUN curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
ENV PATH="/root/.pyenv/bin:/root/.pyenv/shims:${PATH}" ENV PATH="/root/.pyenv/bin:/root/.pyenv/shims:${PATH}"
@ -77,6 +76,7 @@ RUN pyenv install 3.8.2 && \
RUN mkdir -p /tmp/openpilot RUN mkdir -p /tmp/openpilot
COPY SConstruct \ COPY SConstruct \
cppcheck_openpilot.sh \
flake8_openpilot.sh \ flake8_openpilot.sh \
pylint_openpilot.sh \ pylint_openpilot.sh \
.pylintrc \ .pylintrc \

View File

@ -0,0 +1,4 @@
#!/bin/bash
cppcheck --force -j$(nproc) selfdrive/ common/ opendbc/ cereal/ installer/ 2> cppcheck_report.txt