Skip to content

Commit

Permalink
CI: split up jobs + update requirements (commaai#819)
Browse files Browse the repository at this point in the history
  • Loading branch information
adeebshihadeh authored and mlocoteta committed Apr 29, 2023
1 parent dc86b1a commit 4fb5dc6
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 34 deletions.
58 changes: 38 additions & 20 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,51 @@ 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
docker build --cache-from ghcr.io/commaai/opendbc:latest -t opendbc -f Dockerfile .
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
12 changes: 5 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
14 changes: 7 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 4fb5dc6

Please sign in to comment.