github workflows

This commit is contained in:
Denis Angell
2026-05-13 18:21:39 +02:00
parent a761b0d43c
commit 536f87b952
9 changed files with 1358 additions and 2 deletions

109
.github/workflows/doc-coverage.yml vendored Normal file
View File

@@ -0,0 +1,109 @@
name: Documentation Coverage
on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- 'include/**'
- 'src/libxrpl/**'
- 'src/xrpld/**'
- 'docs/Doxyfile'
- '.github/doc-coverage-thresholds.json'
- '.github/workflows/doc-coverage.yml'
concurrency:
group: doc-coverage-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
coverage:
runs-on: ubuntu-latest
container: ghcr.io/xrplf/ci/tools-rippled-documentation:sha-a8c7be1
steps:
- name: Checkout PR branch
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Install coverxygen
run: pip install coverxygen
- name: Determine new C++ files
id: new-files
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files: |
include/**/*.h
src/**/*.h
src/**/*.cpp
since_last_remote_commit: false
- name: Build Doxygen XML (PR branch)
env:
BUILD_DIR: build-pr
run: |
mkdir -p "${BUILD_DIR}"
cd "${BUILD_DIR}"
cmake -Donly_docs=ON ..
cmake --build . --target docs
- name: Generate coverage report (PR branch)
run: |
coverxygen \
--xml-dir build-pr/docs/xml \
--src-dir . \
--output doc-coverage.info \
--kind class,struct,function,enum,typedef,variable \
--scope public
- name: Build Doxygen XML (base branch)
env:
BUILD_DIR: build-base
run: |
git checkout ${{ github.event.pull_request.base.sha }}
mkdir -p "${BUILD_DIR}"
cd "${BUILD_DIR}"
cmake -Donly_docs=ON ..
cmake --build . --target docs || true
git checkout ${{ github.event.pull_request.head.sha }}
- name: Generate coverage report (base branch)
run: |
if [ -d "build-base/docs/xml" ]; then
coverxygen \
--xml-dir build-base/docs/xml \
--src-dir . \
--output base-doc-coverage.info \
--kind class,struct,function,enum,typedef,variable \
--scope public || true
fi
- name: Check coverage thresholds
run: |
BASE_FLAG=""
if [ -f "base-doc-coverage.info" ]; then
BASE_FLAG="--base-lcov-file base-doc-coverage.info"
fi
NEW_FILES=""
if [ -n "${{ steps.new-files.outputs.added_files }}" ]; then
NEW_FILES="--new-files ${{ steps.new-files.outputs.added_files }}"
fi
python3 .github/scripts/doc-coverage-check.py \
--lcov-file doc-coverage.info \
--threshold-file .github/doc-coverage-thresholds.json \
--output doc-coverage-report.md \
${BASE_FLAG} \
${NEW_FILES} || true
- name: Post coverage report to PR
if: always()
uses: marocchino/sticky-pull-request-comment@67d0dec7b07ed060a405f9b2a64b8ab319fdd7db # v2.9.2
with:
header: doc-coverage
path: doc-coverage-report.md

98
.github/workflows/doc-review.yml vendored Normal file
View File

@@ -0,0 +1,98 @@
name: Documentation Review
on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- 'include/**/*.h'
- 'src/libxrpl/**/*.h'
- 'src/libxrpl/**/*.cpp'
- 'src/xrpld/**/*.h'
- 'src/xrpld/**/*.cpp'
concurrency:
group: doc-review-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
review:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.12'
- name: Install dependencies
run: pip install anthropic
- name: Determine changed C++ files
id: changes
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files: |
include/**/*.h
src/libxrpl/**/*.h
src/libxrpl/**/*.cpp
src/xrpld/**/*.h
src/xrpld/**/*.cpp
- name: Run documentation review
if: steps.changes.outputs.any_changed == 'true'
env:
CHANGED_FILES: ${{ steps.changes.outputs.all_changed_files }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: python3 .github/scripts/doc-review.py
- name: Post review summary
if: steps.changes.outputs.any_changed == 'true' && always()
uses: marocchino/sticky-pull-request-comment@67d0dec7b07ed060a405f9b2a64b8ab319fdd7db # v2.9.2
with:
header: doc-review
path: doc-review-report.md
- name: Post inline review comments
if: steps.changes.outputs.any_changed == 'true' && always()
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const fs = require('fs');
if (!fs.existsSync('doc-review-comments.json')) return;
const comments = JSON.parse(fs.readFileSync('doc-review-comments.json', 'utf8'));
if (comments.length === 0) return;
const pull_number = context.payload.pull_request.number;
const owner = context.repo.owner;
const repo = context.repo.repo;
for (const comment of comments) {
try {
await github.rest.pulls.createReviewComment({
owner,
repo,
pull_number,
body: comment.body,
commit_id: '${{ github.event.pull_request.head.sha }}',
path: comment.path,
line: comment.line,
side: 'RIGHT',
});
} catch (e) {
console.log(`Failed to post comment on ${comment.path}:${comment.line}: ${e.message}`);
}
}