Skip to content

Fix LLVM Coverage job - skip non-C++ files - #99103

Merged
alexbakharew merged 7 commits into
masterfrom
abakharew/fix-llvm-coverage
Mar 10, 2026
Merged

alexbakharew merged 7 commits into
masterfrom
abakharew/fix-llvm-coverage

Conversation

@alexbakharew

@alexbakharew alexbakharew commented Mar 9, 2026 •

Copy link
Copy Markdown
Contributor

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Note

Medium Risk
Touches CI coverage gating and artifact-upload conditions; main risk is silently skipping expected diff reports or changing failure behavior in coverage-related jobs.

Overview
Fixes LLVM differential coverage reporting to only run when C/C++ sources changed and to avoid producing misleading/empty artifacts.

The diff-generation script now filters changed files by C/C++ extensions, validates required env vars, fails fast on missing baseline/inputs, and exits cleanly when no relevant files changed. The Python coverage job then treats the presence of the diff report directory as the signal that the diff actually ran, gating HTML uploads, uncovered-code analysis, and GitHub/CIDB comment generation accordingly.

Additionally, functional and integration LLVM coverage jobs now attach the merged .profdata to the CI Result so it uploads even on test failure, and the runner now uploads provided artifacts even when a job is marked non-blocking via do_not_block_pipeline_on_failure.

Written by Cursor Bugbot for commit 157faca. This will update automatically on new commits. Configure here.

Version info

  • Merged into: 26.3.1.545

@clickhouse-gh

clickhouse-gh Bot commented Mar 9, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [157faca]

Summary: ✅

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates the LLVM differential coverage CI job to ignore PRs that don’t touch C/C++ sources, preventing failures on non-C++-only changes.

Changes:

  • Add a stateless SQL test to represent a “non-C++ only” PR change set.
  • Filter changed files down to C/C++ extensions before running lcov --extract, and skip the report when none match.
  • Harden the coverage-report script with set -euo pipefail and required env var validation.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
tests/queries/0_stateless/04032_test_non_cpp_coverage.sql Adds a minimal SQL query so a PR can consist only of non-C++ changes.
tests/queries/0_stateless/04032_test_non_cpp_coverage.reference Adds the expected output for the new stateless test.
ci/jobs/scripts/generate_diff_coverage_report.sh Filters changed files to C/C++ and conditionally skips coverage extraction/report generation.
CMakeLists.txt Adds a comment clarifying CI behavior for differential coverage.
Comments suppressed due to low confidence (1)

ci/jobs/scripts/generate_diff_coverage_report.sh:1

  • With set -u enabled, referencing ${PR_NUMBER} will terminate the script if PR_NUMBER is unset. Use a default expansion (e.g., ${PR_NUMBER:-}) in the conditional and when interpolating to keep PR_NUMBER optional.
#!/bin/bash

Comment on lines +75 to +83
lcov --extract llvm_coverage.info "${patterns[@]}" \
--ignore-errors inconsistent,corrupt \
--quiet \
-o current.changed.info 2>/dev/null
-o current.changed.info

lcov --extract base_llvm_coverage.info "${patterns[@]}" \
--ignore-errors inconsistent,corrupt \
--quiet \
-o baseline.changed.info 2>/dev/null
-o baseline.changed.info

Copilot AI Mar 9, 2026

Copy link

Choose a reason for hiding this comment

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

With set -e enabled, lcov --extract returning a non-zero exit (e.g., when patterns match no entries in the .info) will abort the whole script. To keep “no coverage entries for changed files” from becoming a job failure, handle these calls explicitly (e.g., tolerate specific non-zero outcomes and/or check whether the output .info contains any records before proceeding).

Copilot uses AI. Check for mistakes.
Comment thread CMakeLists.txt Resolved

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Shell.get_output(
"gh pr view --json number -q .number", verbose=True
).strip()
or 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Removing or 0 fallback crashes job on master branch

High Severity

The or 0 fallback was removed from the pr_number resolution in get_git_info(). On master/push events, info.pr_number is 0 (confirmed in _environment.py line 106), so the else branch executes gh pr view --json number -q .number. On master there is no associated PR, so this command returns an empty string. int("".strip()) raises a ValueError, crashing the entire coverage job. The or 0 was the safety net for this exact scenario.

Fix in Cursor Fix in Web

_comment_data = {
# GitHub comment fields
"b_line_cov": b_line_cov,
"c_line_cov": c_line_cov,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Non-existent log file appended when diff skipped

Low Severity

When _diff_inputs_exist is False, the tee command that creates the log file at _print_log is never executed, yet print_res.files.append(_print_log) runs unconditionally on line 272. This adds a reference to a non-existent file, which triggers a warning during upload and sets a misleading "file not found" info message on the result. The append of _print_log needs to be inside the if _diff_inputs_exist block or guarded by a file-existence check.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants