From 7191f4472fcc505a566c31bde5075c9506c2810f Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sat, 15 Apr 2023 23:18:45 -0700 Subject: [PATCH] CI: split up jobs + update requirements (#819) --- .github/workflows/tests.yml | 58 ++++++++++++++++++++++++------------- Dockerfile | 12 ++++---- requirements.txt | 14 ++++----- 3 files changed, 50 insertions(+), 34 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 512fc24..e325d23 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,7 +3,7 @@ name: tests on: [push, pull_request] env: - RUN: docker run -e PYTHONWARNINGS=error --shm-size 1G --rm opendbc /bin/sh -c + RUN: docker run -v $GITHUB_WORKSPACE:/project/opendbc -w /project/opendbc -e PYTHONWARNINGS=error --shm-size 1G --rm opendbc /bin/bash -c BUILD: | docker pull $(grep -ioP '(?<=^from)\s+\S+' Dockerfile) || true docker pull ghcr.io/commaai/opendbc:latest || true @@ -11,25 +11,43 @@ env: PYTHONWARNINGS: error jobs: - test: + unit-tests: + name: unit tests runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 - - name: Build Docker image - run: eval "$BUILD" - - name: Static analysis - run: | - docker run opendbc bash -c "cd opendbc && git init && git add -A && pre-commit run --all" - - name: Generator test - run: | - docker run opendbc bash -c "cd opendbc/generator && ./test_generator.py" - - name: Unit tests - run: | - docker run opendbc bash -c "python -m unittest discover opendbc" - - name: Push to dockerhub - if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'commaai/opendbc' - run: | - docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} - docker tag opendbc ghcr.io/commaai/opendbc:latest - docker push ghcr.io/commaai/opendbc:latest + - uses: actions/checkout@v3 + - name: Build Docker image + run: eval "$BUILD" + - name: Build opendbc + run: ${{ env.RUN }} "cd ../ && scons -j$(nproc)" + - name: Unit tests + run: ${{ env.RUN }} "python -m unittest discover ." + static-analysis: + name: static analysis + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + - name: Build Docker image + run: eval "$BUILD" + - name: Build opendbc + run: ${{ env.RUN }} "cd ../ && scons -j$(nproc)" + - name: pre-commit + # TODO: a package pre-commit installs has a warning, remove the unset once that's fixed + run: ${{ env.RUN }} "unset PYTHONWARNINGS && pre-commit run --all" + - name: Generator test + run: ${{ env.RUN }} "generator/test_generator.py" + + docker-push: + name: docker push + runs-on: ubuntu-20.04 + if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'commaai/opendbc' + steps: + - uses: actions/checkout@v3 + - name: Build Docker image + run: eval "$BUILD" + - name: Push to dockerhub + run: | + docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} + docker tag opendbc ghcr.io/commaai/opendbc:latest + docker push ghcr.io/commaai/opendbc:latest diff --git a/Dockerfile b/Dockerfile index e075f4f..c406413 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,16 +44,14 @@ RUN pip install --no-cache-dir pre-commit==2.15.0 pylint==2.5.2 ENV PYTHONPATH=/project +RUN git config --global --add safe.directory '*' + WORKDIR /project -# TODO: Add tag to cereal RUN git clone https://github.com/commaai/cereal.git /project/cereal && \ cd /project/cereal && \ - git checkout 959ff79963b80829be9902d146c31fda44dbbd20 + git checkout 959ff79963b80829be9902d146c31fda44dbbd20 && \ + rm -rf .git && \ + scons -j$(nproc) COPY SConstruct . COPY ./site_scons /project/site_scons -COPY . /project/opendbc - -RUN rm -rf /project/opendbc/.git && \ - rm -rf /project/cereal/.git -RUN scons -c && scons -j$(nproc) diff --git a/requirements.txt b/requirements.txt index 3c0ce45..62b29a2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ -Cython==0.29.14 -flake8==3.7.9 -Jinja2==3.0.3 -numpy==1.21.0 -pycapnp==1.0.0 -pylint==2.15.4 -pyyaml==5.4 +Cython==0.29.34 +flake8==6.0.0 +Jinja2==3.1.2 +numpy==1.24.2 +pycapnp==1.3.0 +pylint==2.17.2 +pyyaml==6.0 scons