Code Coverage #37
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 0: Checkout Wrapyfi for local code coverage | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# Step 1: Create a local directory with full read-write permissions | |
- name: Create and verify local directory | |
run: | | |
# Create the directory | |
mkdir -p ${GITHUB_WORKSPACE} | |
echo "Local directory created" | |
# Grant full read-write permissions | |
chmod 777 ${GITHUB_WORKSPACE} | |
echo "Granted full read-write permissions to the directory" | |
# Verify creation | |
if [ -d "${GITHUB_WORKSPACE}" ]; then | |
echo "Verification: shared_directory exists and is writable" | |
else | |
echo "Error: shared_directory was not created successfully" | |
exit 1 | |
fi | |
# Step 2: Pull Docker images (remains unchanged) | |
- 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 (replace volume mounts with bind mounts) | |
- name: Run DockA with YARP server | |
run: docker run --name wrapyfi__yarpserver --net host --rm -d -v ${GITHUB_WORKSPACE}:/wrapyfi -w /wrapyfi modularml/wrapyfi:0.4.32-zeromq-yarp-ros2 yarpserver | |
- name: Run DockB with ROS server | |
run: docker run --name wrapyfi__roscore --net host --rm -d -v ${GITHUB_WORKSPACE}:/wrapyfi -w /wrapyfi modularml/wrapyfi:0.4.32-zeromq-ros roscore | |
# Step 4 & 5 & 6: Install packages, run tests, and append coverage data (replace volume mounts with bind mounts) | |
# Run ROS 2, YARP, and ZeroMQ environment | |
- name: Run tests and coverage on DockA | |
run: | | |
docker run --name wrapyfi_zeromq_yarp_ros2 --net host --rm -v ${GITHUB_WORKSPACE}:/wrapyfi -w /wrapyfi modularml/wrapyfi:0.4.32-zeromq-yarp-ros2 bash -c "\ | |
yarp detect --write; \ | |
pip install coverage && \ | |
pip uninstall -y wrapyfi && \ | |
ROS_LOG_DIR=/tmp WRAPYFI_ZEROMQ_PUBSUB_MONITOR_LISTENER_SPAWN=thread WRAPYFI_ZEROMQ_PROXY_BROKER_SPAWN=thread coverage run --source=wrapyfi -m unittest discover -s wrapyfi && \ | |
coverage report --data-file=/wrapyfi/.coverage && \ | |
coverage xml -o /wrapyfi/coverage.xml --data-file=/wrapyfi/.coverage" | |
# Run ROS environment | |
- 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 -v ${GITHUB_WORKSPACE}:/wrapyfi -w /wrapyfi modularml/wrapyfi:0.4.32-zeromq-ros bash -c "\ | |
pip install coverage && \ | |
pip uninstall -y pyzmq && \ | |
pip uninstall -y wrapyfi && \ | |
coverage run -a --source=wrapyfi -m unittest discover -s wrapyfi; \ | |
coverage report --data-file=/wrapyfi/.coverage && \ | |
coverage xml -o /wrapyfi/coverage.xml --data-file=/wrapyfi/.coverage" | |
# Step 7: Modify codecov paths | |
- name: Modify paths in coverage.xml | |
run: | | |
cat ${GITHUB_WORKSPACE}/coverage.xml # Optional: Print to verify | |
# Step 8: Upload the coverage report (remains unchanged) | |
- name: Upload coverage report to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
file: ${{ github.workspace }}/coverage.xml | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |