Skip to content

Commit 3ef1591

Browse files
authored
feat[#13]: Add integration tests to CI pipeline (#14)
* feat: add integration tests to CI pipeline - Split CI test step into unit and integration tests - Add python3-requests test dependency to package.xml - Update README with instructions for running tests separately * Improve CI workflow with ROS 2 best practices - Add separate step for linting checks - Add console_direct+ event handler for real-time output - Show test results after each test category (linters, unit, integration) - Add rosdep package caching to speed up builds - Add timeout for integration tests (10 min) and overall job (60 min) - Upload test artifacts for all runs - Run CI on pushes to main branch in addition to PRs - Update README with improved testing documentation * Run full test suite once in CI - drop the unused rosdep cache step - run a single `colcon test` covering lint/unit/integration - document the new workflow and artifact upload in README
1 parent f1f326d commit 3ef1591

3 files changed

Lines changed: 55 additions & 6 deletions

File tree

.github/workflows/ci.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ name: CI
33
on:
44
pull_request:
55
branches: [main]
6+
push:
7+
branches: [main]
68

79
jobs:
810
build-and-test:
911
runs-on: ubuntu-24.04
12+
timeout-minutes: 60
1013

1114
steps:
1215
- name: Checkout repository
@@ -26,15 +29,27 @@ jobs:
2629
- name: Build packages
2730
run: |
2831
source /opt/ros/jazzy/setup.bash
29-
colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release
32+
colcon build --symlink-install \
33+
--cmake-args -DCMAKE_BUILD_TYPE=Release \
34+
--event-handlers console_direct+
3035
3136
- name: Run tests
37+
timeout-minutes: 15
3238
run: |
3339
source /opt/ros/jazzy/setup.bash
3440
source install/setup.bash
35-
colcon test --return-code-on-test-failure
41+
colcon test --return-code-on-test-failure \
42+
--event-handlers console_direct+
3643
3744
- name: Show test results
3845
if: always()
39-
run: |
40-
colcon test-result --verbose
46+
run: colcon test-result --verbose
47+
48+
- name: Upload test results
49+
if: always()
50+
uses: actions/upload-artifact@v4
51+
with:
52+
name: test-results
53+
path: |
54+
log/
55+
build/*/test_results/

README.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,48 @@ colcon build --symlink-install
4949

5050
### Testing
5151

52+
Run all tests:
53+
5254
```bash
55+
source install/setup.bash
5356
colcon test
5457
colcon test-result --verbose
5558
```
5659

60+
Run linters:
61+
62+
```bash
63+
source install/setup.bash
64+
colcon test --ctest-args -L linters
65+
colcon test-result --verbose
66+
```
67+
68+
Run only unit tests (everything except integration):
69+
70+
```bash
71+
source install/setup.bash
72+
colcon test --ctest-args -E test_integration
73+
colcon test-result --verbose
74+
```
75+
76+
Run only integration tests:
77+
78+
```bash
79+
source install/setup.bash
80+
colcon test --ctest-args -R test_integration
81+
colcon test-result --verbose
82+
```
83+
5784
### CI/CD
5885

59-
All pull requests are automatically built and tested using GitHub Actions.
60-
The CI workflow runs on Ubuntu 24.04 with ROS 2 Jazzy.
86+
All pull requests and pushes to main are automatically built and tested using GitHub Actions.
87+
The CI workflow runs on Ubuntu 24.04 with ROS 2 Jazzy, executes a single `colcon test` to cover:
88+
89+
- Code linting and formatting checks
90+
- Unit tests
91+
- Integration tests with demo automotive nodes
92+
93+
After every run the workflow always calls `colcon test-result --verbose` and uploads the generated logs/results as artifacts for debugging.
6194

6295
## Contributing
6396

src/ros2_medkit_gateway/package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<test_depend>ament_cmake_gtest</test_depend>
2525
<test_depend>ament_cmake_pytest</test_depend>
2626
<test_depend>launch_testing_ament_cmake</test_depend>
27+
<test_depend>python3-requests</test_depend>
2728

2829
<export>
2930
<build_type>ament_cmake</build_type>

0 commit comments

Comments
 (0)