From 07e668eca4b4ce21981df0f8bac7c55d87bb91bd Mon Sep 17 00:00:00 2001 From: Adeeb <8762862+adeebshihadeh@users.noreply.github.com> Date: Tue, 19 May 2020 12:50:32 -0700 Subject: [PATCH] Fast CI (#539) --- .github/workflows/test.yaml | 99 ++++++++++++++----------------------- Dockerfile.panda | 23 ++++----- 2 files changed, 45 insertions(+), 77 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index b5c395c325a5667..fd7d57cc47b0b4e 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -2,40 +2,23 @@ name: panda tests on: [push, pull_request] env: - RUN: docker run --rm panda /bin/sh -c + RUN: docker run --rm panda /bin/bash -c PERSIST: docker run --name panda panda /bin/sh -c - LOAD: docker load -i panda.tar.gz/panda.tar.gz + BUILD: | + docker pull $(grep -ioP '(?<=^from)\s+\S+' Dockerfile.panda) || true + docker pull docker.io/commaai/panda:latest || true + docker build --cache-from docker.io/commaai/panda:latest -t panda -f Dockerfile.panda . jobs: - docker_build: - name: docker build - runs-on: ubuntu-16.04 - timeout-minutes: 30 - steps: - - uses: actions/checkout@v2 - - name: Build docker image - run: | - docker pull $(grep -ioP '(?<=^from)\s+\S+' Dockerfile.panda) || true - docker pull docker.io/commaai/panda:latest || true - docker build --cache-from docker.io/commaai/panda:latest -t panda -f Dockerfile.panda . - docker save panda:latest | gzip > panda.tar.gz - - uses: actions/upload-artifact@v2 - with: - name: panda.tar.gz - path: panda.tar.gz - docker_push: name: docker push runs-on: ubuntu-16.04 - timeout-minutes: 10 - needs: docker_build + timeout-minutes: 45 if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'commaai/panda' steps: - - uses: actions/download-artifact@v1 - with: - name: panda.tar.gz - - name: Load image - run: $LOAD + - uses: actions/checkout@v2 + - name: Build Docker image + run: eval "$BUILD" - name: Login to dockerhub run: docker login -u wmelching -p ${{ secrets.DOCKERHUB_TOKEN }} - name: Tag image @@ -46,14 +29,11 @@ jobs: build: name: build runs-on: ubuntu-16.04 - timeout-minutes: 30 - needs: docker_build + timeout-minutes: 45 steps: - - uses: actions/download-artifact@v1 - with: - name: panda.tar.gz - - name: Load image - run: $LOAD + - uses: actions/checkout@v2 + - name: Build Docker image + run: eval "$BUILD" - name: Test python package installer run: $RUN "cd /tmp/openpilot/panda && python setup.py install" - name: Build panda STM image @@ -68,7 +48,7 @@ jobs: build_esp: name: build esp runs-on: ubuntu-16.04 - timeout-minutes: 40 + timeout-minutes: 45 steps: - uses: actions/checkout@v2 - name: Build docker image @@ -88,42 +68,38 @@ jobs: safety: name: safety runs-on: ubuntu-16.04 - timeout-minutes: 10 - needs: docker_build + timeout-minutes: 45 steps: - - uses: actions/download-artifact@v1 - with: - name: panda.tar.gz - - name: Load image - run: $LOAD + - uses: actions/checkout@v2 + - name: Build Docker image + run: eval "$BUILD" - name: Run safety tests - run: $RUN "cd /tmp/openpilot/panda/tests/safety && ./test.sh" + run: | + $RUN "cd /tmp/openpilot && \ + scons -c && \ + scons -j$(nproc) opendbc/ cereal/ && \ + cd panda/tests/safety && \ + ./test.sh" safety_replay: name: safety replay runs-on: ubuntu-16.04 - timeout-minutes: 10 - needs: docker_build + timeout-minutes: 45 steps: - - uses: actions/download-artifact@v1 - with: - name: panda.tar.gz - - name: Load image - run: $LOAD + - uses: actions/checkout@v2 + - name: Build Docker image + run: eval "$BUILD" - name: Run safety replay run: $RUN "cd /tmp/openpilot/panda/tests/safety_replay && ./test_safety_replay.py" misra: name: misra c2012 runs-on: ubuntu-16.04 - timeout-minutes: 10 - needs: docker_build + timeout-minutes: 45 steps: - - uses: actions/download-artifact@v1 - with: - name: panda.tar.gz - - name: Load image - run: $LOAD + - uses: actions/checkout@v2 + - name: Build Docker image + run: eval "$BUILD" - name: Run Misra C 2012 analysis run: $PERSIST "cd /tmp/openpilot/panda/tests/misra && ./test_misra.sh" - name: Copy analysis outputs @@ -142,14 +118,11 @@ jobs: python_linter: name: python linter runs-on: ubuntu-16.04 - timeout-minutes: 10 - needs: docker_build + timeout-minutes: 45 steps: - - uses: actions/download-artifact@v1 - with: - name: panda.tar.gz - - name: Load image - run: $LOAD + - uses: actions/checkout@v2 + - name: Build Docker image + run: eval "$BUILD" - name: Run linters run: | $RUN "cd /tmp/openpilot/panda/tests/linter_python/ && ./flake8_panda.sh" diff --git a/Dockerfile.panda b/Dockerfile.panda index 31808e67350adf8..bcae97319958500 100644 --- a/Dockerfile.panda +++ b/Dockerfile.panda @@ -1,5 +1,6 @@ FROM ubuntu:16.04 ENV PYTHONUNBUFFERED 1 +ENV PYTHONPATH /tmp/openpilot:$PYTHONPATH RUN apt-get update && apt-get install -y --no-install-recommends \ autoconf \ @@ -30,7 +31,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ unzip \ wget \ zlib1g-dev \ - && rm -rf /var/lib/apt/lists/* + && rm -rf /var/lib/apt/lists/* RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && locale-gen ENV LANG en_US.UTF-8 @@ -38,20 +39,17 @@ ENV LANGUAGE en_US:en ENV LC_ALL en_US.UTF-8 RUN curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash - ENV PATH="/root/.pyenv/bin:/root/.pyenv/shims:${PATH}" -RUN pyenv install 3.7.3 && pyenv global 3.7.3 -RUN pyenv rehash - -RUN pip install --no-cache-dir --upgrade pip==18.0 COPY requirements.txt /tmp/ -RUN pip install --no-cache-dir -r /tmp/requirements.txt +RUN pyenv install 3.7.3 && \ + pyenv global 3.7.3 && \ + pyenv rehash && \ + pip install --no-cache-dir --upgrade pip==18.0 && \ + pip install --no-cache-dir -r /tmp/requirements.txt -ENV PYTHONPATH /tmp/openpilot:$PYTHONPATH - -WORKDIR /tmp -RUN git clone https://github.com/commaai/openpilot.git tmppilot || true && \ +RUN cd /tmp && \ + git clone https://github.com/commaai/openpilot.git tmppilot || true && \ cd /tmp/tmppilot && \ git pull && git checkout 44560b5bb74e451767725144c3fa5f1564481a20 && \ git submodule update --init cereal opendbc && \ @@ -63,7 +61,4 @@ RUN cd /tmp/openpilot && \ pip install --no-cache-dir -r opendbc/requirements.txt && \ pip install --no-cache-dir -r tools/requirements.txt -WORKDIR /tmp/openpilot -RUN scons -c && scons -j$(nproc) opendbc/ cereal/ - COPY . /tmp/openpilot/panda