Skip to content

Fix clang-tidy-check: distinguish tooling failures from issue detection#357

Merged
greenc-FNAL merged 5 commits intomaintenance/ensure-clang-tidy-info-retrievalfrom
copilot/sub-pr-355
Feb 24, 2026
Merged

Fix clang-tidy-check: distinguish tooling failures from issue detection#357
greenc-FNAL merged 5 commits intomaintenance/ensure-clang-tidy-info-retrievalfrom
copilot/sub-pr-355

Conversation

Copy link
Contributor

Copilot AI commented Feb 24, 2026

cmake --build . --target clang-tidy-check exits non-zero both when clang-tidy finds code issues and when a tooling failure occurs. The previous || true masked both cases, silently passing on real infrastructure failures.

Changes

  • clang-tidy-check.yaml: Replace || true with explicit exit-code capture and log content analysis to distinguish the two non-zero cases:
Situation Exit code Log diagnostics Outcome
clang-tidy found issues non-zero present continue, report issues
tooling failure non-zero absent ::error:: + fail job
clean code 0 absent report pass
cmake --build . --target clang-tidy-check -- --export-fixes clang-tidy-fixes.yaml > clang-tidy.log 2>&1
cmake_status=$?

# Distinguish tooling failures from issue detection by checking log content
if [ "$cmake_status" -ne 0 ]; then
  if ! grep -qE '^/.+\.(cpp|hpp|c|h):[0-9]+:[0-9]+: (warning|error):' clang-tidy.log; then
    echo "::error::clang-tidy failed without producing diagnostic output (exit code $cmake_status)"
    exit "$cmake_status"
  fi
fi

The heuristic checks for clang-tidy diagnostic output (file:line:col format) rather than relying on the fixes file, which is only populated when auto-fixes are available. Many clang-tidy checks do not provide automatic fixes.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Address feedback on clang-tidy-check log visibility Fix clang-tidy-check: distinguish tooling failures from issue detection Feb 24, 2026
@greenc-FNAL greenc-FNAL force-pushed the maintenance/ensure-clang-tidy-info-retrieval branch from 594da03 to 8ee4851 Compare February 24, 2026 17:04
Copilot AI and others added 2 commits February 24, 2026 11:06
cmake exits non-zero both when clang-tidy finds issues (fixes YAML
populated) and when a tooling failure occurs (fixes YAML absent/empty).
The previous `|| true` discarded all non-zero exit codes, masking real
failures. Now we capture the exit code and fail the job only when cmake
is non-zero AND no fixes YAML was produced.

Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com>
The previous logic incorrectly used the fixes YAML file to distinguish
tooling failures from issue detection. This fails when clang-tidy finds
issues without automatic fixes (many checks don't provide auto-fixes).

Now checks for diagnostic output in the log to determine if clang-tidy
ran successfully. Only fails CI when exit code is non-zero AND no
diagnostics are present, indicating a true tooling failure.
@greenc-FNAL
Copy link
Contributor

@phlexbot format

@github-actions
Copy link
Contributor

No automatic cmake-format fixes were necessary.

@github-actions
Copy link
Contributor

No automatic markdownlint fixes were necessary.

@github-actions
Copy link
Contributor

No automatic jsonnetfmt fixes were necessary.

@github-actions
Copy link
Contributor

No automatic clang-format fixes were necessary.

@greenc-FNAL greenc-FNAL marked this pull request as ready for review February 24, 2026 17:19
Copilot AI review requested due to automatic review settings February 24, 2026 17:19
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 updates the clang-tidy GitHub Actions workflow to correctly differentiate “clang-tidy found issues” from “clang-tidy infrastructure/tooling failed,” so real tooling failures no longer get silently masked.

Changes:

  • Capture the cmake --build ... clang-tidy-check exit code and analyze the log to decide whether to fail the job (tooling failure) or continue (issues found).
  • Switch issue detection from “non-empty fixes YAML” to “diagnostic output present in log.”

greenc-FNAL and others added 2 commits February 24, 2026 11:27
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@greenc-FNAL greenc-FNAL merged commit e177322 into maintenance/ensure-clang-tidy-info-retrieval Feb 24, 2026
41 checks passed
greenc-FNAL added a commit that referenced this pull request Feb 24, 2026
…355)

* Resolve `clang-tidy-check` issues with log visibility and CI status

* Fix clang-tidy-check: distinguish tooling failures from issue detection (#357)

* Initial plan

* Distinguish clang-tidy tooling failures from issue detection

cmake exits non-zero both when clang-tidy finds issues (fixes YAML
populated) and when a tooling failure occurs (fixes YAML absent/empty).
The previous `|| true` discarded all non-zero exit codes, masking real
failures. Now we capture the exit code and fail the job only when cmake
is non-zero AND no fixes YAML was produced.

Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com>

* Fix clang-tidy failure detection: check log content not fixes file

The previous logic incorrectly used the fixes YAML file to distinguish
tooling failures from issue detection. This fails when clang-tidy finds
issues without automatic fixes (many checks don't provide auto-fixes).

Now checks for diagnostic output in the log to determine if clang-tidy
ran successfully. Only fails CI when exit code is non-zero AND no
diagnostics are present, indicating a true tooling failure.

* Bypass early exit due to `exit_on_error`

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Remove unwanted whitespace

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com>
Co-authored-by: Chris Green <greenc@fnal.gov>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@greenc-FNAL greenc-FNAL deleted the copilot/sub-pr-355 branch February 24, 2026 17:39
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.

3 participants