scons cache in CI (#20197)

* scons cache in ci

* clean up cache

* fix cleanup step

* non fixed key

* quote
albatross
Adeeb Shihadeh 2021-02-28 15:50:20 -08:00 committed by GitHub
parent 9288031e6f
commit 7921759bbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 14 deletions

View File

@ -15,10 +15,11 @@ env:
docker pull $DOCKER_REGISTRY/$BASE_IMAGE:latest || true docker pull $DOCKER_REGISTRY/$BASE_IMAGE:latest || true
docker build --cache-from $DOCKER_REGISTRY/$BASE_IMAGE:latest -t $DOCKER_REGISTRY/$BASE_IMAGE:latest -t $BASE_IMAGE:latest -f Dockerfile.openpilot_base . docker build --cache-from $DOCKER_REGISTRY/$BASE_IMAGE:latest -t $DOCKER_REGISTRY/$BASE_IMAGE:latest -t $BASE_IMAGE:latest -f Dockerfile.openpilot_base .
RUN: docker run --shm-size 1G -v $PWD:/tmp/openpilot -e PYTHONPATH=/tmp/openpilot -e GITHUB_ACTION -e GITHUB_REF -e GITHUB_HEAD_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -v /tmp/comma_download_cache:/tmp/comma_download_cache $BASE_IMAGE /bin/sh -c RUN: docker run --shm-size 1G -v $PWD:/tmp/openpilot -w /tmp/openpilot -e PYTHONPATH=/tmp/openpilot -e SCONS_CACHE=1 -e GITHUB_ACTION -e GITHUB_REF -e GITHUB_HEAD_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -v /tmp/scons_cache:/tmp/scons_cache -v /tmp/comma_download_cache:/tmp/comma_download_cache $BASE_IMAGE /bin/sh -c
UNIT_TEST: coverage run --append -m unittest discover UNIT_TEST: coverage run --append -m unittest discover
jobs: jobs:
# TODO: once actions/cache supports read only mode, use the cache for all jobs
build_release: build_release:
name: build release name: build release
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
@ -29,6 +30,13 @@ jobs:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
submodules: true submodules: true
- name: Cache dependencies
id: dependency-cache
uses: actions/cache@v2
with:
path: /tmp/scons_cache
key: scons-cache-${{ hashFiles('selfdrive/**') }}
restore-keys: scons-cache-
- name: Strip non-release files - name: Strip non-release files
run: | run: |
mkdir $STRIPPED_DIR mkdir $STRIPPED_DIR
@ -42,9 +50,14 @@ jobs:
- name: Build openpilot and run checks - name: Build openpilot and run checks
run: | run: |
cd $STRIPPED_DIR cd $STRIPPED_DIR
${{ env.RUN }} "cd /tmp/openpilot && \ ${{ env.RUN }} "scons -j$(nproc) && \
scons -j$(nproc) && \
python -m unittest discover selfdrive/car" python -m unittest discover selfdrive/car"
- name: Cleanup scons cache
run: |
cd $STRIPPED_DIR
${{ env.RUN }} "scons -j$(nproc) && \
rm -rf /tmp/scons_cache/* && \
scons -j$(nproc) --cache-populate"
build_mac: build_mac:
name: build macos name: build macos
@ -144,7 +157,7 @@ jobs:
- name: Build Docker image - name: Build Docker image
run: eval "$BUILD" run: eval "$BUILD"
- name: pre-commit - name: pre-commit
run: ${{ env.RUN }} "cd /tmp/openpilot/ && git init && git add -A && pre-commit run --all" run: ${{ env.RUN }} "git init && git add -A && pre-commit run --all"
valgrind: valgrind:
name: valgrind name: valgrind
@ -164,8 +177,7 @@ jobs:
run: eval "$BUILD" run: eval "$BUILD"
- name: Run valgrind - name: Run valgrind
run: | run: |
${{ env.RUN }} "cd /tmp/openpilot && \ ${{ env.RUN }} "scons -j$(nproc) && \
scons -j$(nproc) && \
FILEREADER_CACHE=1 python selfdrive/test/test_valgrind_replay.py" FILEREADER_CACHE=1 python selfdrive/test/test_valgrind_replay.py"
- name: Print logs - name: Print logs
if: always() if: always()
@ -183,8 +195,7 @@ jobs:
run: eval "$BUILD" run: eval "$BUILD"
- name: Run unit tests - name: Run unit tests
run: | run: |
${{ env.RUN }} "cd /tmp/openpilot && \ ${{ env.RUN }} "scons -j$(nproc) && \
scons -j$(nproc) && \
coverage run selfdrive/test/test_fingerprints.py && \ coverage run selfdrive/test/test_fingerprints.py && \
$UNIT_TEST common && \ $UNIT_TEST common && \
$UNIT_TEST opendbc/can && \ $UNIT_TEST opendbc/can && \
@ -218,8 +229,7 @@ jobs:
run: eval "$BUILD" run: eval "$BUILD"
- name: Run replay - name: Run replay
run: | run: |
${{ env.RUN }} "cd /tmp/openpilot && \ ${{ env.RUN }} "scons -j$(nproc) && \
scons -j$(nproc) && \
FILEREADER_CACHE=1 CI=1 coverage run selfdrive/test/process_replay/test_processes.py" FILEREADER_CACHE=1 CI=1 coverage run selfdrive/test/process_replay/test_processes.py"
- name: Upload coverage to Codecov - name: Upload coverage to Codecov
run: bash <(curl -s https://codecov.io/bash) -v -F process_replay run: bash <(curl -s https://codecov.io/bash) -v -F process_replay
@ -245,8 +255,7 @@ jobs:
run: eval "$BUILD" run: eval "$BUILD"
- name: Test longitudinal - name: Test longitudinal
run: | run: |
${{ env.RUN }} "mkdir -p /tmp/openpilot/selfdrive/test/out && \ ${{ env.RUN }} "mkdir -p selfdrive/test/out && \
cd /tmp/openpilot/ && \
scons -j$(nproc) && \ scons -j$(nproc) && \
cd selfdrive/test/longitudinal_maneuvers && \ cd selfdrive/test/longitudinal_maneuvers && \
./test_longitudinal.py" ./test_longitudinal.py"
@ -275,8 +284,7 @@ jobs:
run: eval "$BUILD" run: eval "$BUILD"
- name: Test car models - name: Test car models
run: | run: |
${{ env.RUN }} "cd /tmp/openpilot && \ ${{ env.RUN }} "scons -j$(nproc) && \
scons -j$(nproc) && \
FILEREADER_CACHE=1 coverage run --parallel-mode -m nose --processes=4 --process-timeout=60 \ FILEREADER_CACHE=1 coverage run --parallel-mode -m nose --processes=4 --process-timeout=60 \
selfdrive/test/test_models.py && \ selfdrive/test/test_models.py && \
coverage combine" coverage combine"