Skip to content

Commit

Permalink
Fix tests and cache containers for CI (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
eholum committed Feb 7, 2024
1 parent f1beacb commit c43ff3e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
16 changes: 13 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,34 @@ jobs:
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Login to DockerHub Registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PAT }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker
driver: docker-container
- name: Build Docker image
uses: docker/build-push-action@v5
with:
file: docker/Dockerfile
context: .
build-args: |
ROS_DISTRO=${{ matrix.ros_distro }}
tags: pyrobosim:${{ matrix.ros_distro }}
tags: ${{ secrets.DOCKERHUB_USERNAME }}/pyrobosim:${{ matrix.ros_distro }}
push: true
cache-from: |
type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/pyrobosim:buildcache-${{ matrix.ros_distro }}
cache-to: |
type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/pyrobosim:buildcache-${{ matrix.ros_distro }},mode=max
- name: Run tests
run: |
docker run \
--volume ./test/:/pyrobosim_ws/test/:rw \
--volume ./pytest.ini:/pyrobosim_ws/pytest.ini:rw \
pyrobosim:${{ matrix.ros_distro }} \
${{ secrets.DOCKERHUB_USERNAME }}/pyrobosim:${{ matrix.ros_distro }} \
/bin/bash -c './test/run_tests.bash'
- name: Upload test results
uses: actions/upload-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion pyrobosim_ros/test/test_ros_conversions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Tests for pyrobosim ROS conversions functionality

import pytest
from rclpy import Duration
from rclpy.duration import Duration

import pyrobosim.planning.actions as acts
from pyrobosim.utils.motion import Path
Expand Down
14 changes: 12 additions & 2 deletions test/run_tests.bash
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
TEST_RESULTS_DIR="${SCRIPT_DIR}/results"
mkdir -p "$TEST_RESULTS_DIR"

# Ensure we run everything for coverage purposes, but ensure failures are returned by the script
SUCCESS=0

# Do not swallow errors with tee
set -o pipefail

# Run regular pytest tests
echo "Running Python package unit tests..."
Expand All @@ -21,7 +28,7 @@ python3 -m pytest "$SCRIPT_DIR" \
--junitxml="$TEST_RESULTS_DIR/test_results.xml" \
--html="$TEST_RESULTS_DIR/test_results.html" \
--self-contained-html \
| tee "$TEST_RESULTS_DIR"/pytest-coverage.txt
| tee "$TEST_RESULTS_DIR"/pytest-coverage.txt || SUCCESS=$?
echo ""

# Run colcon tests, if using a ROS distro
Expand All @@ -33,7 +40,10 @@ then
pushd "${WORKSPACE_DIR}" > /dev/null || exit
colcon test \
--event-handlers console_cohesion+ \
--pytest-with-coverage --pytest-args " --cov-report term"
--pytest-with-coverage --pytest-args " --cov-report term" || SUCCESS=$?
echo ""
colcon test-result --verbose
popd > /dev/null || exit
fi

exit $SUCCESS

0 comments on commit c43ff3e

Please sign in to comment.