From 59f49a06a4c5d306674e27c607cfbbb05e7f4588 Mon Sep 17 00:00:00 2001 From: Davide De Tommaso Date: Thu, 4 Jun 2026 17:22:40 +0200 Subject: [PATCH 1/2] Refined running tests --- docker/.env | 2 +- docker/build.sh | 5 +++ docker/compose.yaml | 88 +++++++++++++++++++++++++++------------------ docker/run_tests.sh | 6 +--- pyicub/__init__.py | 2 +- scripts/common.sh | 20 ----------- scripts/nogui.sh | 14 ++++++++ scripts/setup.sh | 7 +++- scripts/start.sh | 7 ---- 9 files changed, 82 insertions(+), 69 deletions(-) create mode 100644 scripts/nogui.sh diff --git a/docker/.env b/docker/.env index d756f00..5fb2f31 100644 --- a/docker/.env +++ b/docker/.env @@ -1,4 +1,4 @@ -PYICUB_VERSION=8.3.7 +PYICUB_VERSION=8.3.8 PYICUB_APPS_VERSION=master PYICUB_FRONTEND_VERSION=v8.8-ng diff --git a/docker/build.sh b/docker/build.sh index 483285d..be09bb2 100644 --- a/docker/build.sh +++ b/docker/build.sh @@ -1,3 +1,8 @@ #!/bin/bash +set -e + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +cd "$SCRIPT_DIR" + docker compose build diff --git a/docker/compose.yaml b/docker/compose.yaml index f66cf3b..d1579a3 100644 --- a/docker/compose.yaml +++ b/docker/compose.yaml @@ -5,96 +5,97 @@ x-pyicub-common: &pyicub-common network_mode: host privileged: true -x-pyicub-build: &pyicub-build - context: .. - dockerfile: docker/Dockerfile.pyicub - args: - DOCKER_SRC: ${ROBOTOLOGY_IMAGE_NAME} - PYICUB_VERSION: ${PYICUB_VERSION:-master} - PYICUB_APPS_VERSION: ${PYICUB_APPS_VERSION:-master} - WORKDIR: ${WORKDIR:-/usr/local/src/robot} - -x-pyicub-headless: &pyicub-headless - <<: *pyicub-common - build: *pyicub-build - env_file: - - pyicub.env - environment: - - DISPLAY=:99 - + services: - pyicub-yarpserver: <<: *pyicub-common container_name: pyicub-yarpserver + command: ["/bin/bash", "-c", "yarpserver --write"] + restart: unless-stopped + healthcheck: test: ["CMD", "/bin/bash", "-c", "yarp detect"] interval: 10s timeout: 5s retries: 6 start_period: 1s - profiles: - - backend - - frontend - + pyicub-backend: <<: *pyicub-common - container_name: pyicub-backend - build: *pyicub-build + container_name: pyicub-backend + + build: + context: .. + dockerfile: docker/Dockerfile.pyicub + args: + DOCKER_SRC: ${ROBOTOLOGY_IMAGE_NAME} + PYICUB_VERSION: ${PYICUB_VERSION:-master} + PYICUB_APPS_VERSION: ${PYICUB_APPS_VERSION:-master} + WORKDIR: ${WORKDIR:-/usr/local/src/robot} + runtime: ${DOCKER_RUNTIME:-runc} + env_file: - pyicub.env + environment: - DISPLAY=${DISPLAY:-:0} - PULSE_SERVER=unix:${XDG_RUNTIME_DIR:?error}/pulse/native - PULSE_COOKIE=/run/pulse/cookie - - XDG_RUNTIME_DIR=/tmp/runtime-root + - XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR:?error} - XDG_DATA_DIRS=${XDG_DATA_DIRS:-/usr/local/share/:/usr/share/} - QT_X11_NO_MITSHM=1 - NO_AT_BRIDGE=1 - NVIDIA_VISIBLE_DEVICES=${GPU_DEVICES:-none} - NVIDIA_DRIVER_CAPABILITIES=all - - SSH_AUTH_SOCK=/ssh-agent + command: ["/bin/bash", "-c", "bash ${WORKDIR:?error}/pyicub/scripts/start.sh"] + profiles: - backend + healthcheck: test: ["CMD", "/bin/bash", "-c", "yarp ping /${PYICUB_NODE:?error}"] interval: 1m30s timeout: 30s retries: 5 start_period: 30s + depends_on: pyicub-yarpserver: condition: service_healthy + volumes: - /tmp/.X11-unix:/tmp/.X11-unix - ${HOME}/.config/pulse/cookie:/run/pulse/cookie - ${XDG_RUNTIME_DIR:?error}/pulse:${XDG_RUNTIME_DIR:?error}/pulse - - ${HOME}/.gitconfig:/root/.gitconfig:ro - - ${SSH_AUTH_SOCK:-/dev/null}:/ssh-agent - - ${HOME}/.ssh:/root/.ssh:ro pyicub.frontend: image: ${PYICUB_FRONTEND_IMAGE_NAME:?error} container_name: pyicub-frontend + build: context: . dockerfile: Dockerfile.pyicub-frontend args: - PYICUB_FRONTEND_VERSION=${PYICUB_FRONTEND_VERSION:?error} + environment: - SSH_AUTH_SOCK=/ssh-agent + network_mode: host + volumes: - pyicub-frontend-workspace:${WORKDIR:?error}/pyicub-frontend - ${HOME}/.gitconfig:/root/.gitconfig:ro - ${HOME}/.ssh:/root/.ssh:ro - ${SSH_AUTH_SOCK:-/dev/null}:/ssh-agent + profiles: - frontend + depends_on: pyicub-yarpserver: condition: service_healthy @@ -102,9 +103,19 @@ services: condition: service_healthy pyicub.simulation-nogui: - <<: *pyicub-headless + <<: *pyicub-common container_name: pyicub-simulation-nogui - command: ["/bin/bash", "-c", "bash ${WORKDIR:?error}/pyicub/scripts/start.sh --simulation_nogui"] + command: ["/bin/bash", "-c", "bash ${WORKDIR:?error}/pyicub/scripts/nogui.sh"] + depends_on: + pyicub-yarpserver: + condition: service_healthy + + env_file: + - pyicub.env + + environment: + - ICUB_APP_XML=${ICUB_APP_XML:-} + healthcheck: test: ["CMD", "/bin/bash", "-c", "yarp exists /icubSim/head/rpc:i"] interval: 10s @@ -112,21 +123,30 @@ services: retries: 12 start_period: 30s profiles: - - simulation_nogui - test pyicub.test: - <<: *pyicub-headless + <<: *pyicub-common container_name: pyicub-test + command: ["/bin/bash", "-c", "bash ${WORKDIR:?error}/pyicub/scripts/run_tests.sh"] + + env_file: + - pyicub.env + + environment: + - DISPLAY=:99 + volumes: - ./shared:/shared + depends_on: pyicub.simulation-nogui: condition: service_healthy + profiles: - test volumes: pyicub-frontend-workspace: - name: pyicub-frontend-workspace + name: pyicub-frontend-workspace \ No newline at end of file diff --git a/docker/run_tests.sh b/docker/run_tests.sh index e922343..ba270e6 100755 --- a/docker/run_tests.sh +++ b/docker/run_tests.sh @@ -4,10 +4,6 @@ set -e source "$(dirname "$0")/setup.sh" -docker compose --profile simulation_nogui up --build -d - docker compose --profile test up --build pyicub.test -docker container stop pyicub-simulation-nogui - -docker compose --profile test down --remove-orphans +docker compose --profile test down --remove-orphans \ No newline at end of file diff --git a/pyicub/__init__.py b/pyicub/__init__.py index 7d1d31e..ccd9481 100755 --- a/pyicub/__init__.py +++ b/pyicub/__init__.py @@ -31,5 +31,5 @@ __authors__ = 'Davide De Tommaso, Adam Lukomski, Nicola Russi, Enrico Piacenti, Gioele Migno, Mohammad Gharb' __emails__ = 'davide.detommaso@iit.it, adam.lukomski@iit.it, nicola.russi@iit.it, enrico.piacenti@iit.it, gioele.migno@iit.it, mohammad.gharb@iit.it' __license__ = 'BSD-2' -__version__ = '8.3.7' +__version__ = '8.3.8' __description__ = 'Developing iCub applications using Python' diff --git a/scripts/common.sh b/scripts/common.sh index afc7821..c1427b1 100755 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -92,26 +92,6 @@ ensure_ssh_key_installed() { ssh-copy-id -o StrictHostKeyChecking=no icub@"$ICUB_HOST" } -start_simulation() { - export DISPLAY=:99 - sudo Xvfb :99 -screen 0 1024x768x24 & - sleep 1 - - initialize_environment - start_yarpserver_detached >/dev/null 2>&1 - start_local_yarprun >/dev/null 2>&1 - - echo "Starting Gazebo simulation..." - gzserver ${ICUB_APPS}/gazebo/icub-world.sdf >/dev/null 2>&1 & - sleep 5 - - echo "Starting robot interface..." - yarprobotinterface --context gazeboCartesianControl --config no_legs.xml --portprefix /icubSim >/dev/null 2>&1 & - sleep 5 - - exec "$@" -} - check_existing_yarpserver() { for i in {1..5}; do if yarp detect --write >/dev/null 2>&1; then diff --git a/scripts/nogui.sh b/scripts/nogui.sh new file mode 100644 index 0000000..7602528 --- /dev/null +++ b/scripts/nogui.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +source "$(dirname "$0")/common.sh" +export ICUB_NAME=icubSim +export DISPLAY=:99 +sudo Xvfb :99 -screen 0 1024x768x24 & +sleep 1 # Give it time to start + +initialize_environment +start_yarpserver_detached >/dev/null 2>&1 +start_local_yarprun >/dev/null 2>&1 + +SIM_APP_XML="${ICUB_APP_XML:-${ICUB_APPS}/applications/icubSim/icub-gazebo.xml}" +yarpmanager-console --application "$SIM_APP_XML" --run --connect \ No newline at end of file diff --git a/scripts/setup.sh b/scripts/setup.sh index 2796f36..244d2f9 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -26,7 +26,12 @@ else fi # Check PulseAudio socket -if [[ ! -S ${XDG_RUNTIME_DIR}/pulse/native ]]; then +PULSE_SOCKET_PATH="${XDG_RUNTIME_DIR}/pulse/native" +if [[ -n "${PULSE_SERVER:-}" && "${PULSE_SERVER}" == unix:* ]]; then + PULSE_SOCKET_PATH="${PULSE_SERVER#unix:}" +fi + +if [[ ! -S "${PULSE_SOCKET_PATH}" ]]; then echo "🟡 PulseAudio socket missing. Audio via Pulse may fail." else echo "🟢 PulseAudio socket is ready." diff --git a/scripts/start.sh b/scripts/start.sh index 700422a..b16719c 100755 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -2,13 +2,6 @@ source "$(dirname "$0")/common.sh" -MODE="${1:-}" - -if [[ "$MODE" == "--simulation_nogui" ]]; then - start_simulation sleep infinity - exit 0 -fi - initialize_environment source "$(dirname "$0")/setup.sh" From b79ef39a6899c12a4c3e7e46c0891bcc7f2eba9c Mon Sep 17 00:00:00 2001 From: Davide De Tommaso Date: Thu, 4 Jun 2026 17:33:35 +0200 Subject: [PATCH 2/2] Fixing CI --- .github/workflows/run_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 6e5f2a2..7e9cb96 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -15,4 +15,4 @@ jobs: - name: Run tests working-directory: docker - run: bash run_tests.sh + run: bash build.sh && bash run_tests.sh