Docker layer caching in CI (#54)

* push to dockerhub

* build using cached image

* static analysis get its own job

* remove duplicate step
This commit is contained in:
Adeeb 2020-06-11 18:11:43 -07:00 committed by GitHub
parent 9915b2086a
commit d49ca496ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 15 deletions

View File

@ -2,24 +2,43 @@ name: Tests
on: [push, pull_request]
env:
RUN: docker run --shm-size 1G --rm cereal /bin/sh -c
BUILD: |
docker pull $(grep -ioP '(?<=^from)\s+\S+' Dockerfile) || true
docker pull docker.io/commaai/cereal:latest || true
docker build --cache-from docker.io/commaai/cereal:latest -t cereal -f Dockerfile .
jobs:
test:
name: tests
runs-on: ubuntu-16.04
steps:
- uses: actions/checkout@v2
- name: Build docker image
run: docker build -t cereal .
- name: Static analysis
run: |
docker run cereal bash -c "git init && git add -A && pre-commit run --all"
run: eval "$BUILD"
- name: Unit Tests
run: |
docker run cereal bash -c "scons --test --asan -j$(nproc) && messaging/test_runner"
$RUN "scons --test --asan -j$(nproc) && messaging/test_runner"
- name: Test ZMQ
run: |
docker run cereal bash -c "ZMQ=1 python -m unittest discover ."
$RUN "ZMQ=1 python -m unittest discover ."
- name: Test MSGQ
run: |
docker run cereal bash -c "MSGQ=1 python -m unittest discover ."
$RUN "MSGQ=1 python -m unittest discover ."
- name: Push to dockerhub
run: |
docker login -u wmelching -p ${{ secrets.COMMA_DOCKERHUB_TOKEN}}
docker tag cereal docker.io/commaai/cereal:latest
docker push docker.io/commaai/cereal:latest
static_analysis:
name: static analysis
runs-on: ubuntu-16.04
steps:
- uses: actions/checkout@v2
- name: Build docker image
run: eval "$BUILD"
- name: Static analysis
run: |
$RUN "git init && git add -A && pre-commit run --all"

View File

@ -31,15 +31,15 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
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
RUN pyenv global 3.7.3
RUN pyenv rehash
RUN pip3 install pyyaml==5.1.2 Cython==0.29.14 scons==3.1.1 pycapnp==0.6.4 pre-commit==2.4.0 pylint==2.5.2
RUN pyenv install 3.7.3 && \
pyenv global 3.7.3 && \
pyenv rehash && \
pip3 install --no-cache-dir pyyaml==5.1.2 Cython==0.29.14 scons==3.1.1 pycapnp==0.6.4 pre-commit==2.4.0 pylint==2.5.2
WORKDIR /project/cereal
ENV PYTHONPATH=/project
COPY . .
RUN rm -rf .git
RUN scons -c && scons -j$(nproc)
RUN rm -rf .git && \
scons -c && scons -j$(nproc)