Skip to content

Commit d37fd42

Browse files
add test coverage for python scripts (#62)
1 parent bbda197 commit d37fd42

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

.yamato/yamato-config.yml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,26 @@ agent:
44
image: robotics/ci-ubuntu20:latest
55
flavor: i1.large
66
commands:
7-
- source /opt/ros/noetic/setup.bash && echo "ROS_DISTRO == $ROS_DISTRO" &&
8-
cd .. && mkdir -p catkin_ws/src && cp -r ./ROS-TCP-Endpoint catkin_ws/src &&
9-
cd catkin_ws && catkin_make && source devel/setup.bash && python3 -m pytest
7+
# run unit tests and save test results in /home/bokken/build/output/Unity-Technologies/ROS-TCP-Endpoint
8+
- command: |
9+
source /opt/ros/noetic/setup.bash && echo "ROS_DISTRO == $ROS_DISTRO"
10+
cd .. && mkdir -p catkin_ws/src && cp -r ./ROS-TCP-Endpoint catkin_ws/src
11+
cd catkin_ws && catkin_make && source devel/setup.bash
12+
cd src/ROS-TCP-Endpoint
13+
python3 -m pytest --cov=. --cov-report xml:../../../ROS-TCP-Endpoint/test-results/coverage.xml --cov-report html:../../../ROS-TCP-Endpoint/test-results/coverage.html test/
14+
# check the test coverage
15+
- command: |
16+
linecoverage=$(head -2 test-results/coverage.xml | grep -Eo 'line-rate="[0-9]+([.][0-9]+)?"' | grep -Eo "[0-9]+([.][0-9]+)?")
17+
echo "Line coverage: $linecoverage"
18+
if [[ $linecoverage < 0 ]]; then exit 1; fi
1019
triggers:
1120
cancel_old_ci: true
1221
expression: |
1322
(pull_request.target eq "main" AND
1423
NOT pull_request.push.changes.all match "**/*.md") OR
15-
(push.branch eq "dev" AND
16-
NOT push.changes.all match "**/*.md")
24+
(pull_request.target eq "dev" AND
25+
NOT pull_request.push.changes.all match "**/*.md")
26+
artifacts:
27+
logs:
28+
paths:
29+
- "test-results/**/*"

0 commit comments

Comments
 (0)