Skip to content

Conversation

@tenpercent
Copy link
Contributor

@tenpercent tenpercent commented Jan 16, 2026

Summary

This PR optimizes the Jenkins CI clang-format check to only run on C++ files that have been modified in the current branch, rather than checking all files in the repository.

Changes

  • Detect merge base with origin/develop branch using git merge-base
  • Check only C++ files modified since merge base: *.h, *.hpp, *.cpp, *.h.in, *.hpp.in, *.cpp.in, *.cl
  • Exclude build/ and include/rapidjson directories (same as before)
  • Provide clear error messages when formatting issues are found
  • Exit cleanly when no C++ files are changed
  • Preserve original logic:
    • When RUN_CPPCHECK=false: Run clang-format only (on changed files)
    • When RUN_CPPCHECK=true: Run both clang-format (on changed files) and cppcheck

Benefits

  • Faster CI times for branches that modify only a few files
  • Same coverage - all changed C++ files are still checked
  • Better feedback - shows exactly which files are being checked and which have issues
  • Maintains standards - code formatting requirements unchanged

Test Plan

  • Verify clang-format runs on branches with C++ file changes
  • Verify graceful exit on branches without C++ file changes
  • Verify both RUN_CPPCHECK=true and RUN_CPPCHECK=false scenarios work correctly
  • Confirm formatting errors are properly detected and reported

Instead of running clang-format on all files in the repository, this
change optimizes the Jenkins CI to only check files that have been
modified in the current branch compared to the develop branch.

Changes:
- Detect merge base with origin/develop branch
- Check only C++ files modified since merge base (*.h, *.hpp, *.cpp,
  *.h.in, *.hpp.in, *.cpp.in, *.cl)
- Skip build/ and include/rapidjson directories
- Provide clear error messages when formatting issues are found
- Exit cleanly when no C++ files are changed
- Preserve original logic: run clang-format only when RUN_CPPCHECK=false,
  or run both clang-format and cppcheck when RUN_CPPCHECK=true

This reduces CI time for branches that only modify a few files while
maintaining code formatting standards.
@tenpercent tenpercent changed the title Remove clang-format invocations from Jenkinsfile Run clang-format only on C++ files changed in branch Jan 16, 2026
@tenpercent tenpercent force-pushed the tenpercent/remove-clang-format-jenkinsfile branch from 3c3f007 to 1a7fbcd Compare January 16, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants