Code Coverage #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Code Coverage | |
on: | |
workflow_dispatch: | |
jobs: | |
run-containers: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Create shared volume (assuming the volume is named shared_volume) | |
- name: Create and verify shared volume | |
run: | | |
# Create the shared volume | |
docker volume create shared_volume | |
echo "Shared volume created" | |
# List all volumes and check if shared_volume is in the list | |
echo "Listing all volumes:" | |
docker volume ls | |
if docker volume ls | grep -q 'shared_volume'; then | |
echo "Verification: shared_volume exists" | |
else | |
echo "Error: shared_volume was not created successfully" | |
exit 1 | |
fi | |
# Step 2: Pull Docker images | |
- name: Pull Docker image DockA | |
run: docker pull modularml/wrapyfi:0.4.32-zeromq-yarp-ros2 | |
- name: Pull Docker Image DockB | |
run: docker pull modularml/wrapyfi:0.4.32-zeromq-ros | |
# Step 3: Run YARP and ROS servers | |
- name: Run DockA with YARP server | |
run: docker run --name wrapyfi__yarpserver --net host --rm -dit -v shared_volume:/tmp/shared_volume modularml/wrapyfi:0.4.32-zeromq-yarp-ros2 yarpserver | |
- name: Run DockB with ROS server | |
run: docker run --name wrapyfi__roscore --net host --rm -dit -v shared_volume:/tmp/shared_volume modularml/wrapyfi:0.4.32-zeromq-ros roscore | |
# Step 4 & 5 & 6: Install packages, run tests, and append coverage data | |
- name: Run tests and coverage on DockA | |
run: | | |
docker run --name wrapyfi_zeromq_yarp_ros2 --net host --rm -dit -v shared_volume:/tmp/shared_volume modularml/wrapyfi:0.4.32-zeromq-yarp-ros2 -w /tmp/shared_volume bash -c "\ | |
yarp detect --write; \ | |
pip install coverage && \ | |
coverage run --source=wrapyfi -m unittest discover -s wrapyfi" | |
- name: Run tests and append coverage on DockB. Generate the final report from the combined .coverage file | |
run: | | |
docker run --name wrapyfi_zeromq_ros --net host --rm -dit -v shared_volume:/tmp/shared_volume modularml/wrapyfi:0.4.32-zeromq-ros -w /tmp/shared_volume bash -c "\ | |
pip install coverage && \ | |
coverage run -a --source=wrapyfi -m unittest discover -s wrapyfi && \ | |
coverage report --data-file=/tmp/shared_volume/.coverage && \ | |
coverage xml -o /tmp/shared_volume/coverage.xml" | |
# Step 7: Upload the coverage report | |
- name: Upload coverage report to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
file: /shared_volume/coverage.xml | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |