Skip to content

ci: Add clang tidy to ci#6369

Open
kuznetsss wants to merge 9 commits intoXRPLF:developfrom
kuznetsss:Add_clang_tidy_to_CI
Open

ci: Add clang tidy to ci#6369
kuznetsss wants to merge 9 commits intoXRPLF:developfrom
kuznetsss:Add_clang_tidy_to_CI

Conversation

@kuznetsss
Copy link
Collaborator

@kuznetsss kuznetsss commented Feb 13, 2026

High Level Overview of Change

This PR adds clang-tidy check to CI. It also includes fixes of the issues clang-tidy found with the enabled checks.

Context of Change

Automation added:

  • clang-tidy check of the changed c++ files on PR
  • clang-tidy check of all c++ files on merge to develop
  • clang-tidy check of all files c++ on nightly schedule and creating an issue if the check failed

Clang-tidy configuration is taken from Clio but almost all the checks are commented for now.

I didn't test issue creation, but the rest should be fine.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (non-breaking change that only restructures code)
  • Performance (increase or change in throughput and/or latency)
  • Tests (you added tests for code that already exists, or your new feature included in this PR)
  • Documentation update
  • Chore (no impact to binary, e.g. .gitignore, formatting, dropping support for older tooling)
  • Release

API Impact

  • Public API: New feature (new methods and/or new fields)
  • Public API: Breaking change (in general, breaking changes should only impact the next api_version)
  • libxrpl change (any change that may affect libxrpl or dependents of libxrpl)
  • Peer protocol change (must be backward compatible or bump the peer protocol version)

@mvadari
Copy link
Collaborator

mvadari commented Feb 13, 2026

Can clang-tidy also be included in the pre-commit config?

@kuznetsss
Copy link
Collaborator Author

@mvadari, clang-tidy requires to run conan, cmake and generate c++ code from proto files. Pre-commit checks don't require any extra files. Also clang-tidy check is relatively heavy (comparable to compilation or even slower depending on enabled checks). Running it locally on each commit will significantly slow down development process.

@kuznetsss kuznetsss marked this pull request as ready for review February 13, 2026 18:28
Copilot AI review requested due to automatic review settings February 13, 2026 18:28
Copy link

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 adds clang-tidy static analysis checks to the CI pipeline with three different triggers: on PRs (checking only changed files), on merges to develop (checking all files), and on a nightly schedule (checking all files and creating issues on failure). The PR includes a fix for argument comments in View.cpp that were flagged by the newly enabled bugprone-argument-comment check. The clang-tidy configuration is based on Clio's setup but starts with almost all checks commented out, enabling only the argument-comment check initially.

Changes:

  • Added reusable GitHub Actions workflows for clang-tidy checks
  • Enabled clang-tidy on PR, merge-to-develop, and scheduled runs
  • Fixed argument comments in trustCreate function call to match actual parameter names
  • Added .clang-tidy configuration file with bugprone-argument-comment check enabled

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
.github/workflows/reusable-clang-tidy.yml Orchestrates clang-tidy execution, determining which files to check based on PR context
.github/workflows/reusable-clang-tidy-files.yml Executes clang-tidy on specified files, builds dependencies, and optionally creates issues on failure
.github/workflows/on-trigger.yml Integrates clang-tidy check into merge/scheduled workflow
.github/workflows/on-pr.yml Integrates clang-tidy check into PR workflow
src/libxrpl/ledger/View.cpp Updates argument comments to match function parameter names (though still contains errors)
.clang-tidy Adds clang-tidy configuration with bugprone-argument-comment check enabled
.gitignore Adds .cache directory (used by clang-tidy) to ignore list
cspell.config.yaml Excludes .clang-tidy from spell checking

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +47 to +49
run-clang-tidy:
needs: determine-files
if: ${{ always() && (inputs.check_all_files || needs.determine-files.outputs.any_changed == 'true') }}
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

The run-clang-tidy job declares needs: determine-files, but the determine-files job only runs when check_all_files is false (line 22). When check_all_files is true, the determine-files job is skipped, which means run-clang-tidy will also be skipped due to the dependency, even though the condition on line 49 uses always(). You should either make the needs conditional or restructure the job dependencies to avoid this issue.

Copilot uses AI. Check for mistakes.
Comment on lines +101 to +143
cat > issue.md <<'EOF'
## Clang-tidy Check Failed

**Workflow:** ${{ github.workflow }}
**Run ID:** ${{ github.run_id }}
**Commit:** ${{ github.sha }}
**Branch/Ref:** ${{ github.ref }}
**Triggered by:** ${{ github.actor }}

### Clang-tidy Output:
```
EOF

# Append clang-tidy output (filter for errors and code snippets)
if [ -f clang-tidy-output.txt ]; then
# Extract lines containing 'error:' or '|' (code snippet markers)
grep -E '(error:|\|)' clang-tidy-output.txt > filtered-output.txt || true

# If filtered output is empty, use original (might be a different error format)
if [ ! -s filtered-output.txt ]; then
cp clang-tidy-output.txt filtered-output.txt
fi

# Truncate if too large
head -c 60000 filtered-output.txt >> issue.md
if [ $(wc -c < filtered-output.txt) -gt 60000 ]; then
echo "" >> issue.md
echo "... (output truncated, see artifacts for full output)" >> issue.md
fi

rm filtered-output.txt
else
echo "No output file found" >> issue.md
fi

cat >> issue.md <<'EOF'
```

**Workflow run:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}

---
*This issue was automatically created by the clang-tidy workflow.*
EOF
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

The heredoc delimiter uses single quotes (<<'EOF'), which prevents variable expansion in bash. This means the GitHub Actions expressions like ${{ github.workflow }}, ${{ github.run_id }}, etc. will be treated as literal text and not expanded. To fix this, either use <<EOF (without quotes) and escape any literal dollar signs, or construct the issue body differently using echo statements with proper quoting.

Copilot uses AI. Check for mistakes.
Comment on lines +1298 to +1299
/*uSrcQualityIn=*/0,
/*uSrcQualityOut=*/0,
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

The argument comment uses uSrcQualityIn and uSrcQualityOut, but the actual parameter names in the trustCreate function are uQualityIn and uQualityOut (without the "Src" prefix). The comments should match the exact parameter names to satisfy the bugprone-argument-comment check.

Suggested change
/*uSrcQualityIn=*/0,
/*uSrcQualityOut=*/0,
/*uQualityIn=*/0,
/*uQualityOut=*/0,

Copilot uses AI. Check for mistakes.
Comment on lines +56 to +58
# Set the verbosity to "quiet" for Windows to avoid an excessive
# amount of logs. For other OSes, the "verbose" logs are more useful.
log_verbosity: ${{ runner.os == 'Windows' && 'quiet' || 'verbose' }}
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

The comment references Windows behavior, but this workflow only runs on Linux (as specified by the runs-on and container configuration). This appears to be a copy-paste artifact from another workflow. The comment should be removed or updated to reflect the actual behavior for this Linux-only workflow.

Suggested change
# Set the verbosity to "quiet" for Windows to avoid an excessive
# amount of logs. For other OSes, the "verbose" logs are more useful.
log_verbosity: ${{ runner.os == 'Windows' && 'quiet' || 'verbose' }}
# Use verbose logs for this Linux-only workflow.
log_verbosity: verbose

Copilot uses AI. Check for mistakes.
uses: XRPLF/actions/get-nproc@cf0433aa74563aead044a1e395610c96d65a37cf
id: nproc
with:
subtract: ${{ inputs.nproc_subtract }}
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

The workflow references inputs.nproc_subtract but this input is not declared in the workflow_call inputs section. This will cause the workflow to fail when executed. You should either add nproc_subtract as an input parameter or remove the subtract parameter from the get-nproc action call.

Copilot uses AI. Check for mistakes.
run-clang-tidy:
name: Run clang tidy
runs-on: ["self-hosted", "Linux", "X64", "heavy"]
container: "ghcr.io/xrplf/ci/debian-trixie:clang-21-sha-53033a2"
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

The workflow attempts to create GitHub issues using gh issue create but does not declare the necessary permissions. The workflow needs permissions: issues: write at the job level to create issues. Without this, the issue creation step will fail with a permissions error.

Suggested change
container: "ghcr.io/xrplf/ci/debian-trixie:clang-21-sha-53033a2"
container: "ghcr.io/xrplf/ci/debian-trixie:clang-21-sha-53033a2"
permissions:
issues: write

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Feb 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.9%. Comparing base (ac0ad36) to head (8a5505b).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #6369     +/-   ##
=========================================
- Coverage     79.9%   79.9%   -0.0%     
=========================================
  Files          842     842             
  Lines        65538   65538             
  Branches      7253    7256      +3     
=========================================
- Hits         52379   52373      -6     
- Misses       13159   13165      +6     
Files with missing lines Coverage Δ
src/libxrpl/ledger/View.cpp 94.7% <100.0%> (ø)

... and 4 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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