Skip to content

coverage: restore the scripts .gitignore swallowed - #9486

Open
cdecker wants to merge 4 commits into
ElementsProject:masterfrom
cdecker:2026w37-restore-coverage-scripts
Open

coverage: restore the scripts .gitignore swallowed#9486
cdecker wants to merge 4 commits into
ElementsProject:masterfrom
cdecker:2026w37-restore-coverage-scripts

Conversation

@cdecker

@cdecker cdecker commented Sep 8, 2026

Copy link
Copy Markdown
Member

4b9cffe183 landed the coverage documentation, the coverage-clang-* Makefile
targets, the LLVM_PROFILE_FILE plumbing in pyln-testing and the nightly
workflow — but not contrib/coverage/ itself. The reason is .gitignore:

coverage

That entry is unanchored, so it matches contrib/coverage/ just as well as the
coverage/ build output directory it was meant for, and git add skipped the
whole directory without a word. First commit anchors it to /coverage.

Everything that calls those scripts is broken on master today:

  • Makefile coverage-clang-collect / coverage-clang-report
  • .github/workflows/coverage-nightly.yaml — the nightly fails at
    "Merge coverage data" every night
  • doc/COVERAGE.md, which additionally documents per-test-coverage.sh,
    per-test-coverage-html.sh and cleanup-corrupt-profraw.sh
  • doc/contribute-to-core-lightning/contributor-workflow.md, which points at
    contrib/coverage/clang-coverage-report.sh — the same commit deleted
    contrib/clang-coverage-report.sh and re-pointed the doc at the new path

So the second commit restores all six, unmodified: two of them are the files
reviewed in #8885, and clang-coverage-report.sh is byte-identical to the one
4b9cffe183 removed from contrib/.

The rest of the series fixes the three things that break the nightly after
the scripts exist:

  • lcov export. generate-coverage-report.sh gains one
    llvm-cov export -format=lcov writing coverage/coverage.lcov beside the
    HTML report and the summary; the profile and binary list are already built
    there. The nightly currently hands Codecov coverage/merged.profdata, which
    Codecov cannot parse — it now gets the lcov.
  • Profile location. pyln-testing sets CLN_TEST_NAME for every test, so
    profiles land in $CLN_COVERAGE_DIR/<test-name>/, never directly in
    $CLN_COVERAGE_DIR. The coverage-raw/*.profraw upload glob therefore
    matches nothing, under if-no-files-found: error. Both jobs now hand the
    directory to collect-coverage.sh, which already walks it and drops the
    profiles that crashed tests left half-written. That also removes the
    flattening cp, which could collide on <pid>-<signature>.profraw between
    matrix cells.
  • LLVM version. The build uses the runner's default clang while the
    report job installed LLVM 18 and symlinked llvm-profdata to it. The
    clang docs are explicit that "there are no backwards or forwards
    compatibility guarantees for the raw profile format", so the two have to come
    from the same release — the distro default in both cases.

Verified locally

./configure --enable-debugbuild --enable-coverage CC=clang && make, then a
three-test pytest run with CLN_COVERAGE_DIR set, then make coverage-clang.
The run produced 515 profiles, all of them under per-test subdirectories and
none at the top level, confirming the glob above. clang 14 with matching
llvm-profdata 14.


🤖 Generated with Claude Code

https://claude.ai/code/session_01HGKo3ccLpkH2xFeEXUzEBK

cdecker and others added 4 commits September 8, 2026 19:07
The entry is unanchored, so it matches contrib/coverage/ as well as the
coverage/ build output directory it was meant for. That is how 4b9cffe
came to add the coverage documentation, the Makefile targets, the
pyln-testing plumbing and the nightly workflow while silently leaving the
scripts they all call out of the commit.

Changelog-None
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HGKo3ccLpkH2xFeEXUzEBK
None of these are new: 4b9cffe wrote the documentation and the callers
for them, but .gitignore swallowed the directory itself, so master ships
a coverage feature whose every entry point is a missing file.

  - Makefile's coverage-clang-collect and coverage-clang-report call
    collect-coverage.sh and generate-coverage-report.sh
  - .github/workflows/coverage-nightly.yaml calls the same two, and has
    failed at "Merge coverage data" every night since
  - doc/COVERAGE.md documents those two plus per-test-coverage.sh,
    per-test-coverage-html.sh and cleanup-corrupt-profraw.sh
  - doc/contribute-to-core-lightning/contributor-workflow.md points at
    clang-coverage-report.sh, which the same commit deleted from
    contrib/ after re-pointing the doc at contrib/coverage/

The files are restored unmodified; clang-coverage-report.sh is
byte-identical to the one removed from contrib/.

Changelog-None
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HGKo3ccLpkH2xFeEXUzEBK
llvm-cov can emit lcov from the profile and binary list the script has
already assembled, so this costs one more invocation and gives the
report a machine-readable form. The nightly needs it: it currently hands
Codecov coverage/merged.profdata, which Codecov cannot parse. It is also
what GitLab's coverage visualization wants, via lcov_cobertura.

Paths are rewritten relative to the repository root, since both
consumers match the report against the repository tree.

Changelog-None
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HGKo3ccLpkH2xFeEXUzEBK
Three things stand between the restored scripts and a nightly that
finishes:

pyln-testing sets CLN_TEST_NAME for every test, so the profiles land in
$CLN_COVERAGE_DIR/<test-name>/ and never directly in $CLN_COVERAGE_DIR.
The coverage-raw/*.profraw upload glob therefore matches nothing, under
if-no-files-found: error. A local three-test run produced 515 profiles,
all of them in subdirectories. Both jobs now hand the directory to
collect-coverage.sh, which walks it and drops what crashed tests left
half-written; that also retires the flattening cp, which could collide
on <pid>-<signature>.profraw between matrix cells.

The build uses the runner's default clang while the report job installed
LLVM 18 and symlinked llvm-profdata to it. There are no compatibility
guarantees for the raw profile format across LLVM releases, so the two
have to come from the same one.

Codecov cannot read a .profdata; it gets the lcov export instead.

Changelog-None
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HGKo3ccLpkH2xFeEXUzEBK
@cdecker
cdecker force-pushed the 2026w37-restore-coverage-scripts branch from 7023e0c to a4b5738 Compare September 8, 2026 19:52
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.

1 participant