Skip to content

[CI] Add nightly ELD code coverage workflow with regression detection#1484

Open
Parth (parth-07) wants to merge 1 commit into
mainfrom
code-coverage-workflow
Open

[CI] Add nightly ELD code coverage workflow with regression detection#1484
Parth (parth-07) wants to merge 1 commit into
mainfrom
code-coverage-workflow

Conversation

@parth-07

Copy link
Copy Markdown
Contributor

Add nightly-eld-code-coverage.yml which runs daily after the nightly build. The workflow:

  • Builds LLVM+ELD with source-based coverage instrumentation (ELD_COVERAGE=ON)
  • Runs the full check-eld test suite under LLVM_PROFILE_FILE to collect per-process .profraw files
  • Downloads LLVM 22.1.8 from GitHub Releases and uses its llvm-profdata and llvm-cov tools to avoid profraw version mismatches with the built-in tools
  • Merges profiles with llvm-profdata and generates an HTML report with llvm-cov show
  • Extracts Line/Function/Region/Branch percentages from the TOTAL row of llvm-cov report
  • Compares each metric against a coverage-baseline.txt stored on the code-coverage-reports branch; fails the workflow if any metric regresses
  • On first run (no baseline present) records the baseline without failing
  • Force-pushes the HTML report and updated baseline to the code-coverage-reports orphan branch on every successful run

Also updates CMakeLists.txt: ELD_COVERAGE option now sets llvm-cov source-based instrumentation flags (-fprofile-instr-generate -fcoverage-mapping) instead of gcov (--coverage).

--show-branches=count \
--show-expansions \
--show-instantiations \
--ignore-filename-regex='llvm-project/llvm/(include|lib|utils|unittests|examples|docs|cmake|test|benchmarks|projects|runtimes)/|llvm-project/llvm/tools/[^e]|llvm-project/llvm/tools/e[^l]|llvm-project/llvm/tools/el[^d]|llvm-project/(clang|clang-tools-extra)/|third-party/|/obj/tools/[^e]|/obj/tools/e[^l]|/obj/tools/el[^d]|/obj/(include|lib|bin)/|llvm-project/llvm/tools/eld/test/|llvm-project/llvm/tools/eld/Plugins/HelloWorldPlugin/' \

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.

why ignore filename ? These projects are never built with coverage right ?

COV_SUMMARY=$($SDLLVM_BIN/llvm-cov report \
--instr-profile=eld.profdata \
--object lib/libLW.so \
--ignore-filename-regex='llvm-project/llvm/(include|lib|utils|unittests|examples|docs|cmake|test|benchmarks|projects|runtimes)/|llvm-project/llvm/tools/[^e]|llvm-project/llvm/tools/e[^l]|llvm-project/llvm/tools/el[^d]|llvm-project/(clang|clang-tools-extra)/|third-party/|/obj/tools/[^e]|/obj/tools/e[^l]|/obj/tools/el[^d]|/obj/(include|lib|bin)/|llvm-project/llvm/tools/eld/test/|llvm-project/llvm/tools/eld/Plugins/HelloWorldPlugin/')

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.

can this filename regex be checked in to the eld repo ?

echo "FUNC_COV=$FUNC_COV" >> "$GITHUB_ENV"
echo "REGION_COV=$REGION_COV" >> "$GITHUB_ENV"
echo "BRANCH_COV=$BRANCH_COV" >> "$GITHUB_ENV"

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.

Do we need this ?

../llvm-project/llvm \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON \
-DLLVM_ENABLE_PROJECTS="llvm;clang;clang-tools-extra" \

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.

why clang and clang-tools-extra ?

jobs:
coverage:
if: github.repository == 'qualcomm/eld'
runs-on: self-hosted

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.

We can use the free runners


- name: Build
working-directory: obj
run: ninja

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.

ninja ld.eld

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.

Use clang from the toolchain itself


- name: Merge profile data
working-directory: obj
run: $SDLLVM_BIN/llvm-profdata merge -sparse eld-*.profraw -o eld.profdata

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.

why SDLLVM_BIN ? :)

git commit -m "Update ELD coverage report ($(date -u '+%Y-%m-%d'))"
git push -f origin HEAD:refs/heads/code-coverage-reports

- name: Prune ccache after build

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.

You need save/restore ccache action.

@parth-07
Parth (parth-07) force-pushed the code-coverage-workflow branch from 7e09cbc to 15b56b4 Compare July 17, 2026 09:36
Add nightly-eld-code-coverage.yml which runs daily after the nightly build.
The workflow:
- Builds LLVM+ELD with source-based coverage instrumentation (ELD_COVERAGE=ON)
- Runs check-eld under LLVM_PROFILE_FILE to collect per-process .profraw files
- Merges profiles and generates an HTML report with llvm-profdata / llvm-cov
- Compares Line/Function/Region/Branch coverage against a baseline stored on
  the code-coverage-reports branch and fails if any metric regresses
- Records the baseline on the first run when none exists
- Publishes the HTML report and updated baseline to the code-coverage-reports
  branch

Also updates CMakeLists.txt: ELD_COVERAGE now sets the llvm-cov source-based
instrumentation flags (-fprofile-instr-generate -fcoverage-mapping).

Signed-off-by: bsaharsh <[email protected]>
@parth-07
Parth (parth-07) force-pushed the code-coverage-workflow branch from 15b56b4 to 96e0a2c Compare July 22, 2026 11:24
echo "COV_IGNORE_REGEX=$COV_IGNORE_REGEX" >> "$GITHUB_ENV"

- name: Restore ccache
uses: actions/cache@v4

- name: Save ccache
if: always()
uses: actions/cache/save@v4
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.

4 participants