Skip to content

Optimize local DX and CI pipeline#239

Open
bburda wants to merge 12 commits intomainfrom
feat/test-optimization
Open

Optimize local DX and CI pipeline#239
bburda wants to merge 12 commits intomainfrom
feat/test-optimization

Conversation

@bburda
Copy link
Collaborator

@bburda bburda commented Feb 25, 2026

Summary

Reduces local test cycle from ~20 min to ~1-2 min and optimizes CI wall-clock time by splitting Jazzy into parallel jobs.

Local DX:

  • Make clang-tidy opt-in locally (-DENABLE_CLANG_TIDY=ON), mandatory in CI
  • Auto-detect and configure ccache for faster incremental rebuilds
  • Add precompiled headers for gateway package
  • Add scripts/test.sh convenience script with presets (unit, integ, lint, tidy, all)
  • Add incremental clang-tidy pre-push hook (scripts/clang-tidy-diff.sh)
  • Add ccache with PCH-compatible sloppiness to devcontainer

CI optimizations:

  • Split Jazzy into 3 jobs: jazzy-build -> jazzy-lint | jazzy-test (parallel after build)
  • Add ccache to coverage job
  • Add ccache to build-and-test matrix jobs (Humble, Rolling)

Other:

  • Centralize ENABLE_CLANG_TIDY into cmake/ROS2MedkitLinting.cmake
  • Update README with new scripts and CI structure

Issue


Type

  • Bug fix
  • New feature or tests
  • Breaking change
  • Documentation only

Testing

Local verification (requires ROS 2 Jazzy environment):

  1. ./scripts/test.sh - unit tests (~1-2 min with warm ccache)
  2. ./scripts/test.sh lint - linters excluding clang-tidy (~30s)
  3. ./scripts/test.sh tidy - clang-tidy only (opt-in, ~8-10 min)
  4. ./scripts/test.sh unit --packages-select ros2_medkit_gateway - single package
  5. ./scripts/merge-compile-commands.sh && ./scripts/clang-tidy-diff.sh - incremental clang-tidy
  6. colcon build 2>&1 | grep "ccache found" - verify ccache auto-detection

CI verification:

  • build-and-test (Humble + Rolling): build with ccache + unit/integration tests
  • jazzy-build: build with ccache + clang-tidy enabled
  • jazzy-lint + jazzy-test: run in parallel after jazzy-build
  • coverage: build with ccache (separate cache key for Debug builds)

Checklist

  • Breaking changes are clearly described (and announced in docs / changelog if needed)
  • Tests were added or updated if needed
  • Docs were updated if behavior or public API changed

Copilot AI review requested due to automatic review settings February 25, 2026 15:56
@bburda bburda changed the title Reduce local colcon test from ~20 min to ~1-2 min Reduce local colcon test time Feb 25, 2026
@bburda bburda self-assigned this Feb 25, 2026
@bburda bburda added the enhancement New feature or request label Feb 25, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces local colcon test time from ~20 minutes to ~1-2 minutes by making clang-tidy opt-in (default OFF), adding ccache support, introducing precompiled headers for the gateway package, adding parallel CTest execution, and providing convenience scripts. The changes enable faster development iteration while maintaining full linting coverage in CI.

Changes:

  • Made clang-tidy opt-in via ENABLE_CLANG_TIDY CMake option (OFF by default, enabled in CI for Jazzy)
  • Added ccache integration via new ROS2MedkitCcache.cmake module included in all 5 C++ packages
  • Added precompiled headers to gateway_lib (rclcpp, nlohmann/json, httplib, common STL headers)
  • Created test.sh convenience script with presets (unit, integ, lint, tidy, all) and parallel execution
  • Added incremental clang-tidy support via clang-tidy-diff.sh and pre-push hook
  • Configured CI ccache with persistent caching across builds

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
cmake/ROS2MedkitCcache.cmake New shared module for auto-detecting and enabling ccache
src/ros2_medkit_serialization/CMakeLists.txt Add ccache module, gate clang-tidy behind ENABLE_CLANG_TIDY option
src/ros2_medkit_gateway/CMakeLists.txt Add ccache module, PCH for gateway_lib, gate clang-tidy behind ENABLE_CLANG_TIDY option
src/ros2_medkit_fault_reporter/CMakeLists.txt Add ccache module, gate clang-tidy behind ENABLE_CLANG_TIDY option
src/ros2_medkit_fault_manager/CMakeLists.txt Add ccache module, gate clang-tidy behind ENABLE_CLANG_TIDY option
src/ros2_medkit_diagnostic_bridge/CMakeLists.txt Add ccache module, gate clang-tidy behind ENABLE_CLANG_TIDY option
scripts/test.sh New convenience script with named presets for fast test execution
scripts/merge-compile-commands.sh Utility to merge per-package compile_commands.json for project-wide tooling
scripts/clang-tidy-diff.sh Incremental clang-tidy for pre-push hook (changed .cpp files only)
.pre-commit-config.yaml Add pre-push hook for incremental clang-tidy
.gitignore Add git worktrees directory to ignore list
.github/workflows/ci.yml Install ccache, configure caching, conditionally enable clang-tidy on Jazzy

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 14 changed files in this pull request and generated 3 comments.

@bburda bburda force-pushed the feat/test-optimization branch from c34f805 to 13b6ab6 Compare February 27, 2026 08:45
@bburda bburda changed the title Reduce local colcon test time Optimize local DX and CI pipeline Feb 27, 2026
Provides named presets (unit, integ, lint, tidy, all) with parallel
CTest execution to avoid remembering ctest filter flags.
clang-tidy takes 8-10 min on the gateway package alone. Gated behind
ENABLE_CLANG_TIDY=OFF (default). CI sets it ON for the Jazzy linter
job. Developers can still run it with:
  colcon build --cmake-args -DENABLE_CLANG_TIDY=ON
  ./scripts/test.sh tidy
Adds ROS2MedkitCcache.cmake module that enables ccache when found on
PATH. All C++ packages include it. No effect when ccache is absent.
Set CCACHE_SLOPPINESS=pch_defines,time_macros for PCH compatibility.
PCH for rclcpp, nlohmann/json, httplib, and common STL headers.
Reduces full gateway build time by ~30-40%. Can be disabled with
-DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON.
ccache with persistent cache reduces CI rebuild times by ~30-50%
on subsequent runs. CCACHE_SLOPPINESS set for PCH compatibility.
Runs clang-tidy only on changed C++ source files using a merged
compile_commands.json. Typical run: 5-30s vs 8-10 min for full analysis.
Registered as pre-push hook (not pre-commit) to avoid slowing normal
commits. Run ./scripts/merge-compile-commands.sh after build.
…cmake

Extract duplicated option(ENABLE_CLANG_TIDY) and clang-tidy configuration
into a shared cmake module. Each package now calls ros2_medkit_clang_tidy()
with optional HEADER_FILTER and TIMEOUT parameters.
Adds ccache with persistent GitHub Actions cache to the coverage build.
Uses separate cache key (ccache-coverage-) from Release builds since
coverage builds with -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON.
Removes Jazzy from the build-and-test matrix and creates dedicated
jazzy-build, jazzy-lint, and jazzy-test jobs. Lint and test run in
parallel after the build job completes, reducing wall-clock time by
~3min (previously sequential: build -> lint -> test).

Humble and Rolling remain as single build-and-test matrix jobs.
- Replace raw colcon test commands with scripts/test.sh presets
- Add pre-push hook section documenting clang-tidy-diff.sh and
  merge-compile-commands.sh setup
- Update CI/CD section to reflect the split Jazzy build/lint/test jobs
@bburda bburda force-pushed the feat/test-optimization branch from 72fd28f to 1e2042f Compare February 27, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reduce local colcon test time

3 participants