Skip to content

Commit c671cce

Browse files
committed
ci: fix clang-tidy-diff path mismatch between RunsOn and GitHub-hosted runners
The gate job runs on RunsOn/AWS where GITHUB_WORKSPACE is /__w/... The annotation job runs on ubuntu-latest where it is /home/runner/work/... compile_commands.json bakes in absolute paths from the gate runner. When clang-tidy-diff invokes clang-tidy on the annotation runner, it reads the "directory" field and calls chdir() on the AWS-style path which does not exist, causing a silent crash and empty fixes.yml. Rewrite the workspace prefix in compile_commands.json before invoking clang-tidy-diff so paths resolve correctly on the annotation runner.
1 parent 1d77e04 commit c671cce

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

.github/workflows/ci-orchestrator.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -814,10 +814,28 @@ jobs:
814814

815815
- name: Analysis - Run clang-tidy-diff and export fixes
816816
run: |
817-
# clang-tidy uses the absolute build dir from compile_commands.json to chdir.
818-
# That path (/__w/.../build/...) doesn't exist here — symlink it to our workspace.
819-
sudo mkdir -p /__w/PX4-Autopilot
820-
sudo ln -sfn ${{ github.workspace }} /__w/PX4-Autopilot/PX4-Autopilot
817+
# WHY WE REWRITE compile_commands.json PATHS
818+
#
819+
# The clang-tidy gate job runs on a RunsOn/AWS runner where the workspace
820+
# root is "/__w/PX4-Autopilot/PX4-Autopilot". All absolute paths baked
821+
# into compile_commands.json (the "file" and "directory" fields, and every
822+
# -I include path in "command") use that prefix.
823+
#
824+
# This annotation job runs on a GitHub-hosted runner where the workspace
825+
# root is "/home/runner/work/PX4-Autopilot/PX4-Autopilot". When
826+
# clang-tidy-diff invokes clang-tidy, it reads the "directory" field from
827+
# compile_commands.json and calls chdir() on it. Since the AWS-style path
828+
# does not exist here, clang-tidy crashes with:
829+
# LLVM ERROR: Cannot chdir into "/__w/.../build/px4_sitl_default-clang"
830+
# and silently produces an empty fixes.yml — so no annotations are posted.
831+
#
832+
# Fix: rewrite all occurrences of the AWS workspace prefix to the current
833+
# runner workspace ($GITHUB_WORKSPACE) before invoking clang-tidy-diff.
834+
# This is safe because compile_commands.json is a local scratch file we
835+
# downloaded from the artifact; we are not modifying any source file.
836+
sed -i "s|/__w/PX4-Autopilot/PX4-Autopilot|${GITHUB_WORKSPACE}|g" \
837+
build/px4_sitl_default-clang/compile_commands.json
838+
821839
mkdir -p clang-tidy-result
822840
git diff -U0 origin/${{ github.base_ref }}...HEAD \
823841
| clang-tidy-diff-18.py -p1 \

0 commit comments

Comments
 (0)