From 76bd9e93d777a50ef253864d92b895b6ba33e277 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sat, 19 Jul 2025 15:49:41 -0700 Subject: [PATCH] make jenkins green again (#2230) * just make it green * fix resetter * fix perms * better caching * just copy * simplify more * fix that up * nope --- Dockerfile | 24 +++++++++--------------- Jenkinsfile | 5 +++-- python/__init__.py | 8 ++++---- tests/hitl/reset_jungles.py | 14 +++++++++----- tests/libs/resetter.py | 7 ++++--- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Dockerfile b/Dockerfile index 88190b08..1d1cff70 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,15 @@ FROM ubuntu:24.04 +ENV WORKDIR=/tmp/panda/ ENV PYTHONUNBUFFERED=1 -ENV PYTHONPATH=/tmp/pythonpath +ENV PATH="$WORKDIR/.venv/bin:$PATH" + +WORKDIR $WORKDIR # deps install -COPY pyproject.toml __init__.py setup.sh /tmp/ -COPY python/__init__.py /tmp/python/ -ENV DEBIAN_FRONTEND=noninteractive -RUN apt-get update && apt-get install -y --no-install-recommends sudo && /tmp/setup.sh +COPY pyproject.toml __init__.py setup.sh $WORKDIR +RUN mkdir -p $WORKDIR/python/ && touch $WORKDIR/__init__.py +RUN apt-get update && apt-get install -y --no-install-recommends sudo && DEBIAN_FRONTEND=noninteractive $WORKDIR/setup.sh -COPY pyproject.toml __init__.py $PYTHONPATH/panda/ -COPY python/__init__.py $PYTHONPATH/panda/python/ -RUN pip3 install --break-system-packages --no-cache-dir $PYTHONPATH/panda/[dev] - -RUN git config --global --add safe.directory $PYTHONPATH/panda - -# for Jenkins -COPY README.md panda.tar.* /tmp/ -RUN mkdir -p /tmp/pythonpath/panda && \ - tar -xvf /tmp/panda.tar.gz -C /tmp/pythonpath/panda/ || true +RUN git config --global --add safe.directory $WORKDIR/panda +COPY . $WORKDIR diff --git a/Jenkinsfile b/Jenkinsfile index da692afe..22786b1d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,7 +4,6 @@ def docker_run(String step_label, int timeout_mins, String cmd) { --env PYTHONWARNINGS=error \ --volume /dev/bus/usb:/dev/bus/usb \ --volume /var/run/dbus:/var/run/dbus \ - --workdir /tmp/pythonpath/panda \ --net host \ ${env.DOCKER_IMAGE_TAG} \ bash -c 'scons -j8 && ${cmd}'", \ @@ -35,6 +34,9 @@ export PYTHONPATH=${env.TEST_DIR}/../ export PYTHONWARNINGS=error ln -sf /data/openpilot/opendbc_repo/opendbc /data/opendbc +# TODO: this is an agnos issue +export PYTEST_ADDOPTS="-p no:asyncio" + cd ${env.TEST_DIR} || true ${cmd} exit 0 @@ -83,7 +85,6 @@ pipeline { steps { timeout(time: 20, unit: 'MINUTES') { script { - sh 'git archive -v -o panda.tar.gz --format=tar.gz HEAD' dockerImage = docker.build("${env.DOCKER_IMAGE_TAG}") } } diff --git a/python/__init__.py b/python/__init__.py index f745ba32..c27a80df 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -522,16 +522,16 @@ class Panda: dfu_list = PandaDFU.list() return True - @staticmethod - def wait_for_panda(serial: str | None, timeout: int) -> bool: + @classmethod + def wait_for_panda(cls, serial: str | None, timeout: int) -> bool: t_start = time.monotonic() - serials = Panda.list() + serials = cls.list() while (serial is None and len(serials) == 0) or (serial is not None and serial not in serials): logger.debug("waiting for panda...") time.sleep(0.1) if timeout is not None and (time.monotonic() - t_start) > timeout: return False - serials = Panda.list() + serials = cls.list() return True def up_to_date(self, fn=None) -> bool: diff --git a/tests/hitl/reset_jungles.py b/tests/hitl/reset_jungles.py index fb946731..09bd04ad 100755 --- a/tests/hitl/reset_jungles.py +++ b/tests/hitl/reset_jungles.py @@ -4,7 +4,9 @@ import concurrent.futures from panda import PandaJungle, PandaJungleDFU, McuType from panda.tests.libs.resetter import Resetter -SERIALS = {'180019001451313236343430', '1d0017000c50435635333720'} +SERIALS = { + '180019001451313236343430', # jungle v2 +} def recover(s): with PandaJungleDFU(s) as pd: @@ -25,9 +27,9 @@ if __name__ == "__main__": for i in range(1, 4): r.enable_power(i, 0) r.cycle_power(ports=[1, 2], dfu=True) - + for s in SERIALS: + assert PandaJungle.wait_for_dfu(PandaJungleDFU.st_serial_to_dfu_serial(s, McuType.H7), timeout=10) dfu_serials = PandaJungleDFU.list() - print(len(dfu_serials), len(SERIALS)) assert len(dfu_serials) == len(SERIALS) with concurrent.futures.ProcessPoolExecutor(max_workers=len(dfu_serials)) as exc: @@ -36,7 +38,9 @@ if __name__ == "__main__": # power cycle for H7 bootloader bug r.cycle_power(ports=[1, 2]) - serials = PandaJungle.list() + # wait for them to come back up + for s in SERIALS: + assert PandaJungle.wait_for_panda(s, timeout=10) assert set(PandaJungle.list()) >= SERIALS mcu_types = list(exc.map(flash, SERIALS, timeout=20)) - assert set(mcu_types) == {McuType.F4, McuType.H7} + assert set(mcu_types) == {McuType.H7, } diff --git a/tests/libs/resetter.py b/tests/libs/resetter.py index 3868bde6..52c44e42 100644 --- a/tests/libs/resetter.py +++ b/tests/libs/resetter.py @@ -42,16 +42,17 @@ class Resetter(): def enable_boot(self, enabled): self._handle.controlWrite((usb1.ENDPOINT_OUT | usb1.TYPE_VENDOR | usb1.RECIPIENT_DEVICE), 0xff, 0, enabled, b'') - def cycle_power(self, delay=5, dfu=False, ports=None): + def cycle_power(self, dfu=False, ports=None): if ports is None: ports = [1, 2, 3] self.enable_boot(dfu) for port in ports: self.enable_power(port, False) - time.sleep(0.5) + time.sleep(0.05) for port in ports: self.enable_power(port, True) - time.sleep(delay) + time.sleep(0.05) self.enable_boot(False) + time.sleep(0.12) # takes the kernel this long to detect the disconnect