Ramon Roche 4c8c9a1e0f ci(clang-tidy): run incrementally on PRs and post inline annotations
Switch the Static Analysis workflow to two modes:
- Push to main: run the full "make clang-tidy" target as before.
- Pull request: build the clang compile database with
  "make px4_sitl_default-clang", then call Tools/ci/run-clang-tidy-pr.py
  (already in-tree) to compute the translation units actually affected
  by the PR diff and run clang-tidy only on that subset. PRs that touch
  no C++ files exit silently; the large majority of PRs will skip the
  slow full analysis entirely.

Replace the inline ccache restore/config/save steps with the composite
actions from .github/actions/setup-ccache and .github/actions/save-ccache,
which use content-hash cache keys (prefix-ref-sha with ref and base_ref
fallbacks), compression, and compiler_check=content. Same 120M cap.

Add a second job, post_clang_tidy_comments, that runs on a GitHub-hosted
runner when the analysis job reports has_findings=true. It downloads the
compile_commands.json artifact produced by the analysis job, rewrites
the AWS RunsOn workspace prefix (/__w/PX4-Autopilot/PX4-Autopilot) to the
GitHub-hosted runner workspace so clang-tidy can chdir into the build
directory, runs clang-tidy-diff-18 to export fixes, and posts inline
review annotations via platisd/clang-tidy-pr-comments@v1.

Annotations are set to request changes (request_changes: true), so a PR
with new clang-tidy findings will be blocked until they are addressed or
waived. suggestions_per_comment is capped at 10. Annotations are gated
to same-repo PRs only; forks skip the annotation job because GITHUB_TOKEN
has no write access there.

The post_clang_tidy_comments job uses if: always() && ... so it runs
whether the analysis job succeeded or failed (findings still need to be
surfaced when the analysis exits non-zero).

Signed-off-by: Ramon Roche <mrpollo@gmail.com>
2026-04-08 22:45:03 -06:00
..
2025-07-02 14:43:55 -07:00