ci: run test car models in matrix (#22884)

* Run test car models in matrix

* cache key per job

* actually cache files

* ci

* make files readable

* actually expose variables

* fix quote

* get cache unstuck

* ro cache can use more prefixes

* ci
pull/22879/head
Willem Melching 4 years ago committed by GitHub
parent 579994ced9
commit 264c5f4e61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 41
      .github/workflows/selfdrive_tests.yaml
  2. 5
      selfdrive/test/test_models.py

@ -15,7 +15,7 @@ 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 -w /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/scons_cache:/tmp/scons_cache -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 NUM_JOBS -e JOB_ID -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:
@ -42,7 +42,9 @@ jobs:
with: with:
path: /tmp/scons_cache path: /tmp/scons_cache
key: scons-${{ hashFiles('.github/workflows/selfdrive_tests.yaml') }}- key: scons-${{ hashFiles('.github/workflows/selfdrive_tests.yaml') }}-
restore-keys: scons-${{ hashFiles('.github/workflows/selfdrive_tests.yaml') }}- restore-keys: |
scons-${{ hashFiles('.github/workflows/selfdrive_tests.yaml') }}-
scons-
- name: Strip non-release files - name: Strip non-release files
run: | run: |
mkdir $STRIPPED_DIR mkdir $STRIPPED_DIR
@ -188,7 +190,9 @@ jobs:
with: with:
path: /tmp/scons_cache path: /tmp/scons_cache
key: scons-${{ hashFiles('.github/workflows/selfdrive_tests.yaml') }}- key: scons-${{ hashFiles('.github/workflows/selfdrive_tests.yaml') }}-
restore-keys: scons-${{ hashFiles('.github/workflows/selfdrive_tests.yaml') }}- restore-keys: |
scons-${{ hashFiles('.github/workflows/selfdrive_tests.yaml') }}-
scons-
- name: Build Docker image - name: Build Docker image
run: eval "$BUILD" run: eval "$BUILD"
- name: pre-commit - name: pre-commit
@ -217,7 +221,9 @@ jobs:
with: with:
path: /tmp/scons_cache path: /tmp/scons_cache
key: scons-${{ hashFiles('.github/workflows/selfdrive_tests.yaml') }}- key: scons-${{ hashFiles('.github/workflows/selfdrive_tests.yaml') }}-
restore-keys: scons-${{ hashFiles('.github/workflows/selfdrive_tests.yaml') }}- restore-keys: |
scons-${{ hashFiles('.github/workflows/selfdrive_tests.yaml') }}-
scons-
- name: Build Docker image - name: Build Docker image
run: eval "$BUILD" run: eval "$BUILD"
- name: Run valgrind - name: Run valgrind
@ -245,7 +251,9 @@ jobs:
with: with:
path: /tmp/scons_cache path: /tmp/scons_cache
key: scons-${{ hashFiles('.github/workflows/selfdrive_tests.yaml') }}- key: scons-${{ hashFiles('.github/workflows/selfdrive_tests.yaml') }}-
restore-keys: scons-${{ hashFiles('.github/workflows/selfdrive_tests.yaml') }}- restore-keys: |
scons-${{ hashFiles('.github/workflows/selfdrive_tests.yaml') }}-
scons-
- name: Build Docker image - name: Build Docker image
run: eval "$BUILD" run: eval "$BUILD"
- name: Run unit tests - name: Run unit tests
@ -294,7 +302,9 @@ jobs:
with: with:
path: /tmp/scons_cache path: /tmp/scons_cache
key: scons-${{ hashFiles('.github/workflows/selfdrive_tests.yaml') }}- key: scons-${{ hashFiles('.github/workflows/selfdrive_tests.yaml') }}-
restore-keys: scons-${{ hashFiles('.github/workflows/selfdrive_tests.yaml') }}- restore-keys: |
scons-${{ hashFiles('.github/workflows/selfdrive_tests.yaml') }}-
scons-
- name: Build Docker image - name: Build Docker image
run: eval "$BUILD" run: eval "$BUILD"
- name: Run replay - name: Run replay
@ -345,7 +355,9 @@ jobs:
with: with:
path: /tmp/scons_cache path: /tmp/scons_cache
key: scons-${{ hashFiles('.github/workflows/selfdrive_tests.yaml') }}- key: scons-${{ hashFiles('.github/workflows/selfdrive_tests.yaml') }}-
restore-keys: scons-${{ hashFiles('.github/workflows/selfdrive_tests.yaml') }}- restore-keys: |
scons-${{ hashFiles('.github/workflows/selfdrive_tests.yaml') }}-
scons-
- name: Build Docker image - name: Build Docker image
run: eval "$BUILD" run: eval "$BUILD"
- name: Test longitudinal - name: Test longitudinal
@ -365,6 +377,9 @@ jobs:
name: car models name: car models
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
timeout-minutes: 50 timeout-minutes: 50
strategy:
matrix:
job: [0, 1, 2, 3]
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
@ -374,7 +389,7 @@ jobs:
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: /tmp/comma_download_cache path: /tmp/comma_download_cache
key: ${{ hashFiles('.github/workflows/selfdrive_tests.yaml', 'selfdrive/test/test_routes.py') }} key: car_models-${{ hashFiles('selfdrive/test/test_models.py', 'selfdrive/test/test_routes.py') }}-${{ matrix.job }}
- name: Cache scons - name: Cache scons
id: scons-cache id: scons-cache
# TODO: Change the version to the released version when https://github.com/actions/cache/pull/489 (or 571) is merged. # TODO: Change the version to the released version when https://github.com/actions/cache/pull/489 (or 571) is merged.
@ -384,13 +399,19 @@ jobs:
with: with:
path: /tmp/scons_cache path: /tmp/scons_cache
key: scons-${{ hashFiles('.github/workflows/selfdrive_tests.yaml') }}- key: scons-${{ hashFiles('.github/workflows/selfdrive_tests.yaml') }}-
restore-keys: scons-${{ hashFiles('.github/workflows/selfdrive_tests.yaml') }}- restore-keys: |
scons-${{ hashFiles('.github/workflows/selfdrive_tests.yaml') }}-
scons-
- name: Build Docker image - name: Build Docker image
run: eval "$BUILD" run: eval "$BUILD"
- name: Test car models - name: Test car models
run: | run: |
${{ env.RUN }} "scons -j$(nproc) --test && \ ${{ env.RUN }} "scons -j$(nproc) --test && \
coverage run selfdrive/test/test_models.py" FILEREADER_CACHE=1 coverage run selfdrive/test/test_models.py && \
chmod -R 777 /tmp/comma_download_cache"
env:
NUM_JOBS: 4
JOB_ID: ${{ matrix.job }}
- name: Upload coverage to Codecov - name: Upload coverage to Codecov
run: bash <(curl -s https://codecov.io/bash) -v -F test_car_models run: bash <(curl -s https://codecov.io/bash) -v -F test_car_models

@ -22,6 +22,9 @@ from panda.tests.safety.common import package_can_msg
PandaType = log.PandaState.PandaType PandaType = log.PandaState.PandaType
NUM_JOBS = int(os.environ.get("NUM_JOBS", "1"))
JOB_ID = int(os.environ.get("JOB_ID", "0"))
ROUTES = {rt.car_fingerprint: rt.route for rt in routes} ROUTES = {rt.car_fingerprint: rt.route for rt in routes}
# TODO: get updated routes for these cars # TODO: get updated routes for these cars
@ -34,7 +37,7 @@ ignore_carstate_check = [
CHRYSLER.PACIFICA_2017_HYBRID, CHRYSLER.PACIFICA_2017_HYBRID,
] ]
@parameterized_class(('car_model'), [(car,) for car in all_known_cars()]) @parameterized_class(('car_model'), [(car,) for i, car in enumerate(all_known_cars()) if i % NUM_JOBS == JOB_ID])
class TestCarModel(unittest.TestCase): class TestCarModel(unittest.TestCase):
@classmethod @classmethod

Loading…
Cancel
Save