← Back to Pull requests

Implement Automated Line and MC/DC Coverage CI Workflows #219165

Open
tapiwagonga opened this pull request with 3149 lines diff across 7 files
View on GitHub
tapiwagonga tapiwagonga commented on Aug 27, 2026 10:23 UTC
Author

I previously wrote an RFC regarding Enabling Code Coverage in LLVM-libc to address the circular dependencies and link-time failures caused by standard compiler-rt profiling in hermetic (-nostdlib) testing environments. After incorporating community feedback, the core freestanding instrumentation was merged in Code Coverage via Linux Syscalls.

Following that integration, I evaluated how best to surface this coverage data automatically within the monorepo. This resulted in a second RFC proposing an Automated Code Coverage Infrastructure utilising GitHub Actions to track coverage on commit. This pull request implements that infrastructure.

Implementation Details
The architecture of this infrastructure is explicitly decoupled into execution workflows and zero-dependency analytical scripts. The pipeline is entirely self-contained within the monorepo. The GitHub Actions workflows compile the test suite, generate the raw coverage payloads using llvm-cov, and pipe that data into the Python analysers to render native Markdown summaries.
This submission consists of 8 cohesive files:

_GitHub Actions Workflows (.github/workflows/):_
Execution Model:These workflows leverage the official ghcr.io/llvm/libc-ubuntu-24.04 container. By using a pre-installed toolchain and building exclusively at the runtimes layer (-DLLVM_ENABLE_RUNTIMES=libc), they eliminate the overhead of compiling Clang from source.

Pre-commit bots (libc-patch-coverage.yml, libc-patch-mcdc.yml) that evaluate patch diffs and provide actionable diagnostics regarding unexecuted lines and unverified boolean conditions on pull requests.

Post-commit bots (libc-full-coverage.yml, libc-full-mcdc.yml) that aggregate repository-wide metrics across all directories on a daily schedule.

_In-Tree Reporting Analysers (libc/utils/coverage/):_
diff_coverage.py: A Python utility that intercepts llvm-cov JSON exports, correlates them against unified Git diffs, filters out non-executable code lines (comments, macros, braces), and strictly evaluates MC/DC bitmasks to determine patch completeness.

codebase_coverage.py: Aggregates full repository execution segments into top-level directories (e.g., src/math, src/string), It implements explicit path filtering to drop internal mock dependencies and test infrastructure (libc/test/), ensuring the final metrics accurately reflect the core library implementation.

Unit Tests
The Python reporting scripts are supported by fast-executing unit test suites that verify the underlying analysis algorithms using synthetic, in-memory data structures:

test_diff_coverage.py: Verifies the integrity of the patch evaluation pipeline, including Git diff parsing, C++ heuristic filtering, segment intersection math, and MC/DC boolean extraction.

test_codebase_coverage.py: Verifies the global repository tracking logic, specifically asserting directory-level metric aggregation and infrastructure path exclusion.

Diff: 3149 lines (+3146 / -3) across 7 files Reviewer: boomanaiden154 Review duration: 142398m
All Vouch review confidence checks passed
Residual risk 0.06 = Change Risk (0.59) × (1 − Review Confidence (0.89)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.59 · 3149 lines diff across 7 files
0.59
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.91 · 5 substantive comment(s)
0.91
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
89%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.400
Real PR Conversation Timeline
42 items
github-actions[bot] github-actions[bot] commented on Aug 27, 2026 10:23 UTC
Bot

<!--LLVM NEW CONTRIBUTOR COMMENT-->

Hello @tapiwagonga :wave:

Thank you for submitting a Pull Request (PR) to the LLVM Project. Since this is your first PR, here are a few useful links covering our main contribution policies and review practices.

All contributions to LLVM must follow our LLVM AI Tool Use Policy. In particular, if you used AI while working on this PR, remember to add a note to the PR description.
The LLVM Code-Review Policy and Practices document contains practical information about the PR process, including how patches are reviewed and accepted, and who can review a PR.

  • Our LLVM Developer Policy describes our expectations for code quality, commit summaries and contains notes on our CI system.
  • Please reply to this message to confirm that you have read these policies, especially the LLVM AI Tool Use Policy, and that any AI tool usage has been noted in the PR description.

    ---

    Frequently asked questions

    How do I add reviewers?

    This PR will be automatically labeled, and the relevant teams will be notified. For some parts of the project, reviewers may also be added automatically.

    You can also add reviewers manually using the Reviewers section on this page. If you cannot use that section, it is probably because you do not have write permissions for the repository. In that case, you can request a review by tagging reviewers in a comment using @ followed by their GitHub username.

    What if there are no comments?

    If you have not received any comments on your PR after a week, you can request a review by pinging the PR with a comment such as “Ping”. The common courtesy ping rate is once a week. Please remember that you are asking for volunteer time from other developers.

    Are any special GitHub settings required to contribute to LLVM?

    We only require contributors to have a public email address associated with their GitHub commits, see this section of LLVM Developer Policy for details.

    ---

    If you have questions, feel free to leave a comment on this PR, or ask on LLVM Discord or LLVM Discourse.

    Thank you,
    The LLVM Community

    llvmorg-github-actions[bot] llvmorg-github-actions[bot] commented on Sep 02, 2026 17:06 UTC
    Bot

    <!--LLVM PR SUMMARY COMMENT-->
    @llvm/pr-subscribers-github-workflow

    @llvm/pr-subscribers-libc

    Author: Tapiwa Gonga (tapiwagonga)

    <details>
    <summary>Changes</summary>

    I previously wrote an RFC regarding Enabling Code Coverage in LLVM-libc to address the circular dependencies and link-time failures caused by standard compiler-rt profiling in hermetic (-nostdlib) testing environments. After incorporating community feedback, the core freestanding instrumentation was merged in Code Coverage via Linux Syscalls.

    Following that integration, I evaluated how best to surface this coverage data automatically within the monorepo. This resulted in a second RFC proposing an Automated Code Coverage Infrastructure utilising GitHub Actions to track coverage on commit. This pull request implements that infrastructure.

    Developer instructions on how to run coverage locally have been published in How To Run Code Coverage.

    Implementation Details
    The architecture of this infrastructure is explicitly decoupled into execution workflows and zero-dependency analytical scripts. The pipeline is entirely self-contained within the monorepo. The GitHub Actions workflows compile the test suite, generate the raw coverage payloads using llvm-cov, and pipe that data into the Python analysers to render native Markdown summaries.
    This submission consists of 8 cohesive files:

    _GitHub Actions Workflows (.github/workflows/):_
    Execution Model:These workflows leverage the official ghcr.io/llvm/libc-ubuntu-24.04 container. By using a pre-installed toolchain and building exclusively at the runtimes layer (-DLLVM_ENABLE_RUNTIMES=libc), they eliminate the overhead of compiling Clang from source.

    Pre-commit bots (libc-patch-coverage.yml, libc-patch-mcdc.yml) that evaluate patch diffs and provide actionable diagnostics regarding unexecuted lines and unverified boolean conditions on pull requests.

    Post-commit bots (libc-full-coverage.yml, libc-full-mcdc.yml) that aggregate repository-wide metrics across all directories on a daily schedule.

    _In-Tree Reporting Analysers (libc/utils/coverage/):_
    diff_coverage.py: A Python utility that intercepts llvm-cov JSON exports, correlates them against unified Git diffs, filters out non-executable code lines (comments, macros, braces), and strictly evaluates MC/DC bitmasks to determine patch completeness.

    codebase_coverage.py: Aggregates full repository execution segments into top-level directories (e.g., src/math, src/string), It implements explicit path filtering to drop internal mock dependencies and test infrastructure (libc/test/), ensuring the final metrics accurately reflect the core library implementation.

    Unit Tests
    The Python reporting scripts are supported by fast-executing unit test suites that verify the underlying analysis algorithms using synthetic, in-memory data structures:

    test_diff_coverage.py: Verifies the integrity of the patch evaluation pipeline, including Git diff parsing, C++ heuristic filtering, segment intersection math, and MC/DC boolean extraction.

    test_codebase_coverage.py: Verifies the global repository tracking logic, specifically asserting directory-level metric aggregation and infrastructure path exclusion.

    ---

    Patch is 95.24 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/219165.diff

    8 Files Affected:

  • (added) .github/workflows/libc-full-coverage.yml (+143)

  • (added) .github/workflows/libc-full-mcdc.yml (+149)

  • (added) .github/workflows/libc-patch-coverage.yml (+362)

  • (added) .github/workflows/libc-patch-mcdc.yml (+370)

  • (added) libc/utils/coverage/codebase_coverage.py (+308)

  • (added) libc/utils/coverage/diff_coverage.py (+661)

  • (added) libc/utils/coverage/test_codebase_coverage.py (+82)

  • (added) libc/utils/coverage/test_diff_coverage.py (+256)
  • ``````

    diff --git a/.github/workflows/libc-full-coverage.yml b/.github/workflows/libc-full-coverage.yml
    new file mode 100644
    index 0000000000000..ebaa9f2a39fb6
    --- /dev/null
    +++ b/.github/workflows/libc-full-coverage.yml
    @@ -0,0 +1,143 @@
    +name: Libc Full Codebase Coverage
    +
    +permissions:
    +  contents: write # Required to publish live HTML dashboard to gh-pages branch
    +
    +env:
    +  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
    +
    +on:
    +  # Daily overnight run at 02:00 UTC
    +  schedule:
    +    - cron: '0 2 * * *'
    +
    +  # Allow manual on-demand execution from GitHub Actions UI
    +  workflow_dispatch:
    +
    +  # Trigger on pushes to main / libc-coverage-ci-bots / post-commit-bot
    +  push:
    +    branches:
    +      - main
    +      - libc-coverage-ci-bots
    +      - post-commit-bot
    +    paths:
    +      - 'libc/**'
    +      - '.github/workflows/libc-full-coverage.yml'
    +
    +concurrency:
    +  group: ${{ github.workflow }}-${{ github.ref }}
    +  cancel-in-progress: true
    +
    +jobs:
    +  full-coverage:
    +    timeout-minutes: 60
    +    name: libc-full-coverage
    +    runs-on: ubuntu-24.04
    +    container:
    +      image: ghcr.io/llvm/libc-ubuntu-24.04:latest@sha256:8fee4c9ce5a1fd095686593cd36e032c48a31b6ae575378c82accd1d86a08d59
    +      options: --privileged
    +    defaults:
    +      run:
    +        shell: bash
    +    steps:
    +    - name: Checkout Code
    +      uses: actions/checkout@v4
    +      with:
    +        fetch-depth: 1
    +        persist-credentials: false
    +
    +    - name: Setup Compiler Cache (sccache)
    +      uses: hendrikmuhs/ccache-action@v1.2.23
    +      with:
    +        max-size: 1G
    +        key: libc_coverage_unified_v2_x86_64
    +        variant: sccache
    +
    +    - name: Configure CMake
    +      run: |
    +        echo "=== [STAGE 1/4] Starting CMake Configuration at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +        START_TIME=$(date +%s)
    +
    +        export CMAKE_FLAGS="
    +          -G Ninja
    +          -S runtimes
    +          -B build-cov
    +          -DCMAKE_C_COMPILER=clang-23
    +          -DCMAKE_CXX_COMPILER=clang++-23
    +          -DCMAKE_BUILD_TYPE=Debug
    +          -DCMAKE_C_COMPILER_LAUNCHER=sccache
    +          -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
    +          -DLLVM_USE_LINKER=lld-23
    +          -DLLVM_ENABLE_RUNTIMES=libc
    +          -DLLVM_LIBC_FULL_BUILD=ON
    +          -DLIBC_ENABLE_COVERAGE=ON
    +          -DLIBC_TEST_UNIT_TEST_ONLY=ON
    +          -DLIBC_TEST_SKIP_DEATH_TESTS=ON
    +          -DLIBC_TEST_SKIP_SHARED_TESTS=ON
    +        "
    +        cmake $CMAKE_FLAGS
    +
    +        END_TIME=$(date +%s)
    +        echo "=== [STAGE 1/4] CMake Configuration Completed in $((END_TIME - START_TIME))s ==="
    +
    +    - name: Run Full Codebase Unit Tests
    +      run: |
    +        echo "=== [STAGE 2/4] Running Full Unit Test Suite at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +        START_TIME=$(date +%s)
    +
    +        export LLVM_PROFILE_FILE="libc_cov_%p.profraw"
    +        ninja -k 0 -C build-cov libc-unit-tests || true
    +
    +        END_TIME=$(date +%s)
    +        echo "=== [STAGE 2/4] libc-unit-tests Completed in $((END_TIME - START_TIME))s ==="
    +
    +    - name: Merge Profiles
    +      run: |
    +        echo "=== [STAGE 3/4] Merging Raw Profiles at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +        find . build-cov -name "libc_cov_*.profraw" > profraw_list.txt
    +        NUM_PROFS=$(wc -l < profraw_list.txt || echo 0)
    +        echo "[LOG] Discovered $NUM_PROFS raw profile data files."
    +        llvm-profdata-23 merge -sparse --input-files=profraw_list.txt -o libc_full.profdata
    +        echo "[LOG] Merged full codebase profile into libc_full.profdata."
    +
    +    - name: Generate Reports and Summary
    +      env:
    +        COMMIT_SHA: ${{ github.sha }}
    +        BRANCH_REF: ${{ github.ref_name }}
    +      run: |
    +        echo "=== [STAGE 4/4] Generating Full Codebase Coverage Reports at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +        EXECUTABLES=($(find build-cov -type f -executable -name "*__build__"))
    +        OBJECTS=("${EXECUTABLES[@]:1}")
    +        OBJECTS=("${OBJECTS[@]/#/-object=}")
    +
    +        echo "[LOG] Exporting coverage data across ${#EXECUTABLES[@]} test binaries."
    +
    +        # 1. Generate JSON export for Full Coverage Analyzer
    +        llvm-cov-23 export -format=text -instr-profile=libc_full.profdata "${EXECUTABLES[0]}" "${OBJECTS[@]}" > coverage.json
    +
    +        # 2. Generate HTML Coverage Report with directory hierarchy and branch tracking
    +        llvm-cov-23 show -format=html \
    +          -output-dir=coverage_html \
    +          -instr-profile=libc_full.profdata \
    +          "${EXECUTABLES[0]}" "${OBJECTS[@]}" \
    +          --show-directory-coverage \
    +          --show-branches=count \
    +          --compilation-dir=. \
    +          --path-equivalence="$GITHUB_WORKSPACE,." \
    +          -ignore-filename-regex=".*(test|utils).*"
    +        touch coverage_html/.nojekyll
    +
    +        # 3. Run Codebase Coverage Analyzer
    +        PYTHONPATH="libc/utils/coverage" python3 libc/utils/coverage/codebase_coverage.py coverage.json "$COMMIT_SHA" "$BRANCH_REF" >> $GITHUB_STEP_SUMMARY
    +        echo "[LOG] Post-commit summary report written to GITHUB_STEP_SUMMARY."
    +
    +    - name: Deploy Coverage Dashboard to GitHub Pages
    +      if: github.repository != 'llvm/llvm-project'
    +      continue-on-error: true
    +      uses: peaceiris/actions-gh-pages@v4
    +      with:
    +        github_token: ${{ secrets.GITHUB_TOKEN }}
    +        publish_dir: ./coverage_html
    +        keep_files: true
    +        enable_jekyll: false
    +        force_orphan: false
    diff --git a/.github/workflows/libc-full-mcdc.yml b/.github/workflows/libc-full-mcdc.yml
    new file mode 100644
    index 0000000000000..fdebc1c66f399
    --- /dev/null
    +++ b/.github/workflows/libc-full-mcdc.yml
    @@ -0,0 +1,149 @@
    +name: Libc Full Codebase MC/DC Coverage
    +
    +permissions:
    +  contents: write
    +
    +env:
    +  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
    +
    +on:
    +  # Daily overnight run at 02:30 UTC (staggered by 30 mins from baseline sweep)
    +  schedule:
    +    - cron: '30 2 * * *'
    +
    +  # Allow manual on-demand execution from GitHub Actions UI ("Run workflow" button)
    +  workflow_dispatch:
    +
    +  # Trigger on pushes to main / libc-mcdc-coverage / post-commit-bot
    +  push:
    +    branches:
    +      - main
    +      - libc-mcdc-coverage
    +      - post-commit-bot
    +    paths:
    +      - 'libc/**'
    +      - '.github/workflows/libc-full-mcdc.yml'
    +
    +concurrency:
    +  group: ${{ github.workflow }}-${{ github.ref }}
    +  cancel-in-progress: true
    +
    +jobs:
    +  full-mcdc-coverage:
    +    timeout-minutes: 60
    +    name: libc-full-mcdc-coverage
    +    runs-on: ubuntu-24.04
    +    container:
    +      image: ghcr.io/llvm/libc-ubuntu-24.04:latest@sha256:8fee4c9ce5a1fd095686593cd36e032c48a31b6ae575378c82accd1d86a08d59
    +      options: --privileged
    +    defaults:
    +      run:
    +        shell: bash
    +    steps:
    +      - name: Checkout Code
    +        uses: actions/checkout@v4
    +        with:
    +          fetch-depth: 1
    +          persist-credentials: false
    +
    +      - name: Setup Compiler Cache (sccache)
    +        uses: hendrikmuhs/ccache-action@v1.2.23
    +        with:
    +          max-size: 1G
    +          key: libc_mcdc_coverage_unified_x86_64
    +          variant: sccache
    +
    +      - name: Configure CMake with MC/DC
    +        run: |
    +          echo "=== [STAGE 1/4] Starting CMake Configuration (MC/DC) at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +          START_TIME=$(date +%s)
    +
    +          export CMAKE_FLAGS="
    +            -G Ninja
    +            -S runtimes
    +            -B build-cov
    +            -DCMAKE_C_COMPILER=clang-23
    +            -DCMAKE_CXX_COMPILER=clang++-23
    +            -DCMAKE_BUILD_TYPE=Debug
    +            -DCMAKE_C_COMPILER_LAUNCHER=sccache
    +            -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
    +            -DLLVM_USE_LINKER=lld-23
    +            -DLLVM_ENABLE_RUNTIMES=libc
    +            -DLLVM_LIBC_FULL_BUILD=ON
    +            -DLIBC_ENABLE_COVERAGE=ON
    +            -DLIBC_ENABLE_MCDC=ON
    +            -DLIBC_TEST_UNIT_TEST_ONLY=ON
    +            -DLIBC_TEST_SKIP_DEATH_TESTS=ON
    +            -DLIBC_TEST_SKIP_SHARED_TESTS=ON
    +          "
    +          cmake $CMAKE_FLAGS
    +
    +          END_TIME=$(date +%s)
    +          echo "=== [STAGE 1/4] CMake Configuration Completed in $((END_TIME - START_TIME))s ==="
    +
    +      - name: Run Full Codebase Unit Tests
    +        run: |
    +          echo "=== [STAGE 2/4] Running Full Unit Test Suite at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +          START_TIME=$(date +%s)
    +
    +          export LLVM_PROFILE_FILE="libc_cov_%p.profraw"
    +          ninja -k 0 -C build-cov libc-unit-tests || true
    +
    +          END_TIME=$(date +%s)
    +          echo "=== [STAGE 2/4] libc-unit-tests Completed in $((END_TIME - START_TIME))s ==="
    +
    +      - name: Merge Profiles
    +        run: |
    +          echo "=== [STAGE 3/4] Merging Raw Profiles at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +          find build-cov -name "libc_cov_*.profraw" > profraw_list.txt
    +          NUM_PROFS=$(wc -l < profraw_list.txt || echo 0)
    +          echo "[LOG] Discovered $NUM_PROFS raw profile data files."
    +          llvm-profdata-23 merge -sparse --input-files=profraw_list.txt -o libc_full.profdata
    +          echo "[LOG] Merged full codebase profile into libc_full.profdata."
    +
    +      - name: Generate Reports and Summary
    +        env:
    +          COMMIT_SHA: ${{ github.sha }}
    +          BRANCH_REF: ${{ github.ref_name }}
    +        run: |
    +          echo "=== [STAGE 4/4] Generating Full Codebase MC/DC Coverage Reports at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +          EXECUTABLES=($(find build-cov -type f -executable -name "*__build__"))
    +          OBJECTS=("${EXECUTABLES[@]:1}")
    +          OBJECTS=("${OBJECTS[@]/#/-object=}")
    +
    +          echo "[LOG] Exporting coverage data across ${#EXECUTABLES[@]} test binaries."
    +
    +          # 1. Generate JSON export for Full Coverage Analyzer (contains mcdc_records)
    +          llvm-cov-23 export -format=text -instr-profile=libc_full.profdata "${EXECUTABLES[0]}" "${OBJECTS[@]}" > coverage.json
    +
    +          # 2. Generate HTML Coverage Report with directory hierarchy, branch tracking, and MC/DC truth tables
    +          llvm-cov-23 show -format=html \
    +            -output-dir=coverage_mcdc_html \
    +            -instr-profile=libc_full.profdata \
    +            "${EXECUTABLES[0]}" "${OBJECTS[@]}" \
    +            --show-directory-coverage \
    +            --show-branches=count \
    +            --show-mcdc \
    +            --show-mcdc-summary \
    +            --compilation-dir=. \
    +            --path-equivalence="$GITHUB_WORKSPACE,." \
    +            -ignore-filename-regex=".*(test|utils).*"
    +          touch coverage_mcdc_html/.nojekyll
    +
    +          # 3. Run Codebase Coverage Analyzer
    +          PYTHONPATH="libc/utils/coverage" python3 libc/utils/coverage/codebase_coverage.py coverage.json "$COMMIT_SHA" "$BRANCH_REF" >> $GITHUB_STEP_SUMMARY
    +          echo "[LOG] Post-commit summary report written to GITHUB_STEP_SUMMARY."
    +
    +      - name: Deploy MC/DC Coverage Report to GitHub Pages
    +        if: github.repository != 'llvm/llvm-project'
    +        continue-on-error: true
    +        uses: peaceiris/actions-gh-pages@v4
    +        with:
    +          github_token: ${{ secrets.GITHUB_TOKEN }}
    +          publish_dir: ./coverage_mcdc_html
    +          destination_dir: mcdc
    +          keep_files: true
    +          enable_jekyll: false
    +          force_orphan: false
    +
    +
    diff --git a/.github/workflows/libc-patch-coverage.yml b/.github/workflows/libc-patch-coverage.yml
    new file mode 100644
    index 0000000000000..5cd2b723862e1
    --- /dev/null
    +++ b/.github/workflows/libc-patch-coverage.yml
    @@ -0,0 +1,362 @@
    +name: Libc Patch Code Coverage
    +
    +permissions:
    +  contents: read
    +  pull-requests: write # Required to post/update patch coverage comments
    +
    +env:
    +  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
    +
    +on:
    +  workflow_dispatch:
    +  push:
    +    branches:
    +      - pre-commit-bot
    +      - libc-coverage-ci-bots
    +      - main
    +    paths:
    +      - 'libc/src/**'
    +      - 'libc/include/**'
    +      - 'libc/test/**'
    +      - 'libc/CMakeLists.txt'
    +      - '.github/workflows/libc-patch-coverage.yml'
    +      - '!libc/docs/**'
    +      - '!libc/benchmarks/**'
    +      - '!libc/fuzzing/**'
    +      - '!libc/utils/**'
    +      - '!**.md'
    +  pull_request:
    +    paths:
    +      - 'libc/src/**'
    +      - 'libc/include/**'
    +      - 'libc/test/**'
    +      - 'libc/CMakeLists.txt'
    +      - '.github/workflows/libc-patch-coverage.yml'
    +      - '!libc/docs/**'
    +      - '!libc/benchmarks/**'
    +      - '!libc/fuzzing/**'
    +      - '!libc/utils/**'
    +      - '!**.md'
    +
    +concurrency:
    +  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
    +  cancel-in-progress: true
    +
    +jobs:
    +  pre-commit-coverage:
    +    timeout-minutes: 60
    +    name: libc-pre-commit-coverage
    +    runs-on: ubuntu-24.04
    +    container:
    +      image: ghcr.io/llvm/libc-ubuntu-24.04:latest@sha256:8fee4c9ce5a1fd095686593cd36e032c48a31b6ae575378c82accd1d86a08d59
    +      options: >-
    +        --privileged
    +    defaults:
    +      run:
    +        shell: bash
    +    steps:
    +    - name: Checkout Code
    +      uses: actions/checkout@v4
    +      with:
    +        ref: ${{ github.event.pull_request.head.sha || github.sha }}
    +        fetch-depth: 2
    +        persist-credentials: false
    +
    +    - name: Setup Compiler Cache (sccache)
    +      uses: hendrikmuhs/ccache-action@v1.2.23
    +      with:
    +        max-size: 1G
    +        key: libc_coverage_unified_v2_x86_64
    +        variant: sccache
    +
    +    - name: Configure CMake
    +      run: |
    +        echo "=== [STAGE 1/4] Starting CMake Configuration at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +        START_TIME=$(date +%s)
    +
    +        export CMAKE_FLAGS="
    +          -G Ninja
    +          -S runtimes
    +          -B build-cov
    +          -DCMAKE_C_COMPILER=clang-23
    +          -DCMAKE_CXX_COMPILER=clang++-23
    +          -DCMAKE_BUILD_TYPE=Debug
    +          -DCMAKE_C_COMPILER_LAUNCHER=sccache
    +          -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
    +          -DLLVM_USE_LINKER=lld-23
    +          -DLLVM_ENABLE_RUNTIMES=libc
    +          -DLLVM_LIBC_FULL_BUILD=ON
    +          -DLIBC_ENABLE_COVERAGE=ON
    +          -DLIBC_TEST_UNIT_TEST_ONLY=ON
    +          -DLIBC_TEST_SKIP_DEATH_TESTS=ON
    +          -DLIBC_TEST_SKIP_SHARED_TESTS=ON
    +        "
    +        cmake $CMAKE_FLAGS
    +
    +        END_TIME=$(date +%s)
    +        echo "=== [STAGE 1/4] CMake Configuration Completed in $((END_TIME - START_TIME))s ==="
    +
    +    - name: Build and Run Targeted Tests
    +      env:
    +        EVENT_NAME: ${{ github.event_name }}
    +        PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
    +        PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
    +        PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
    +        PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
    +        PR_BASE_REPO: ${{ github.event.pull_request.base.repo.full_name }}
    +        PR_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
    +        COMMIT_SHA: ${{ github.sha }}
    +        BRANCH_REF: ${{ github.ref_name }}
    +        REPO_NAME: ${{ github.repository }}
    +      run: |
    +        echo "=== [STAGE 2/4] Starting Targeted Test Discovery at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +        START_TIME=$(date +%s)
    +
    +        # Ensure upstream llvm-project remote is configured
    +        git remote add upstream https://github.com/llvm/llvm-project.git 2>/dev/null || true
    +
    +        # 1. Deterministically resolve Base and Head references against upstream llvm-project
    +        if [ "$EVENT_NAME" == "pull_request" ]; then
    +          BASE_SHA="$PR_BASE_SHA"
    +          HEAD_SHA="$PR_HEAD_SHA"
    +          BASE_REF="$PR_BASE_REF"
    +          HEAD_REF="$PR_HEAD_REF"
    +          BASE_REPO="${PR_BASE_REPO:-llvm/llvm-project}"
    +          HEAD_REPO="${PR_HEAD_REPO:-$REPO_NAME}"
    +          git fetch upstream "$BASE_SHA" --depth=1 2>/dev/null || git fetch origin "$BASE_SHA" --depth=1 2>/dev/null || git fetch origin "$BASE_REF" --depth=1 2>/dev/null || true
    +          DIFF_BASE="$BASE_SHA"
    +        else
    +          # For direct pushes, compare the pushed commit against its parent (HEAD~1)
    +          BASE_SHA=$(git rev-parse HEAD~1 2>/dev/null || echo "HEAD~1")
    +          HEAD_SHA="$COMMIT_SHA"
    +          BASE_REF="main"
    +          HEAD_REF="$BRANCH_REF"
    +          BASE_REPO="llvm/llvm-project"
    +          HEAD_REPO="$REPO_NAME"
    +          DIFF_BASE="HEAD~1"
    +        fi
    +
    +        # Persist resolved commit references for all downstream steps
    +        echo "DIFF_BASE=$DIFF_BASE" >> $GITHUB_ENV
    +        echo "BASE_SHA=$BASE_SHA" >> $GITHUB_ENV
    +        echo "HEAD_SHA=$HEAD_SHA" >> $GITHUB_ENV
    +        echo "BASE_REF=$BASE_REF" >> $GITHUB_ENV
    +        echo "HEAD_REF=$HEAD_REF" >> $GITHUB_ENV
    +        echo "BASE_REPO=$BASE_REPO" >> $GITHUB_ENV
    +        echo "HEAD_REPO=$HEAD_REPO" >> $GITHUB_ENV
    +
    +        echo "[LOG] Resolved Base: ${BASE_REF} (${BASE_SHA:0:7}) in ${BASE_REPO}"
    +        echo "[LOG] Resolved Head: ${HEAD_REF} (${HEAD_SHA:0:7}) in ${HEAD_REPO}"
    +
    +        MODIFIED_FILES=$(git diff --name-only "$DIFF_BASE" HEAD -- libc/src/ || true)
    +        echo "[LOG] Modified files in libc/src/:"
    +        echo "$MODIFIED_FILES"
    +
    +        if [ -z "$MODIFIED_FILES" ]; then
    +          echo "[LOG] No source files modified in libc/src/. Exiting successfully."
    +          echo "TARGETS=" >> $GITHUB_ENV
    +
    +          echo "## LLVM-libc Patch Coverage Report" > coverage_report.md
    +          echo "" >> coverage_report.md
    +          echo "- **Base Branch:** [\`${BASE_REF}\` (${BASE_SHA:0:7})](https://github.com/${BASE_REPO}/commit/${BASE_SHA})" >> coverage_report.md
    +          echo "- **Head Commit:** [\`${HEAD_REF}\` (${HEAD_SHA:0:7})](https://github.com/${HEAD_REPO}/commit/${HEAD_SHA})" >> coverage_report.md
    +          echo "---" >> coverage_report.md
    +          echo "" >> coverage_report.md
    +          echo "**Coverage Validated**" >> coverage_report.md
    +          echo "No \`.cpp\` source files in \`libc/src/\` were modified in this patch." >> coverage_report.md
    +
    +          cat coverage_report.md >> $GITHUB_STEP_SUMMARY
    +          exit 0
    +        fi
    +
    +        # Get all valid ninja targets
    +        ninja -C build-cov -t targets > all_targets.txt
    +
    +        TARGETS=""
    +
    +        for FILE in $MODIFIED_FILES; do
    +          # Skip core support files from direct target mapping (tested transitively)
    +          if [[ "$FILE" == *"__support/"* ]]; then
    +            echo "[LOG] -> Support file ($FILE) will be tested transitively."
    +            continue
    +          fi
    +
    +          if [[ "$FILE" =~ ^libc/src/([^/]+)/(.*/)?([^/]+)\.cpp$ ]]; then
    +            DIR="${BASH_REMATCH[1]}"
    +            FUNC="${BASH_REMATCH[3]}"
    +            ALL_MATCHES=$(grep -oE "^libc\.test\.src\.${DIR}\.([a-zA-Z0-9_]+\.)*${FUNC}_test\.__unit__" all_targets.txt || true)
    +            FOUND_TARGET=$(echo "$ALL_MATCHES" | head -n 1 | tr -d '\r\n ' || true)
    +            if [ -n "$FOUND_TARGET" ]; then
    +              echo "[LOG] -> Matched $FILE -> $FOUND_TARGET"
    +              TARGETS="$TARGETS $FOUND_TARGET"
    +            else
    +              echo "[LOG] -> Notice: No direct unit test target found for $FILE."
    +            fi
    +          fi
    +        done
    +
    +        # Remove duplicate targets
    +        TARGETS=$(echo "$TARGETS" | xargs -n1 | sort -u | xargs || true)
    +        echo "[LOG] Executing Ninja targets: $TARGETS"
    +
    +        if [ -n "$TARGETS" ]; then
    +          export LLVM_PROFILE_FILE="libc_cov_%p.profraw"
    +          ninja -C build-cov $TARGETS
    +          echo "TARGETS=$TARGETS" >> $GITHUB_ENV
    +        else
    +          echo "[LOG] No standalone unit test targets to run."
    +          echo "TARGETS=" >> $GITHUB_ENV
    +
    +          echo "## LLVM-libc Patch Coverage Report" > coverage_report.md
    +          echo "" >> coverage_report.md
    +          echo "- **Base Branch:** [\`${BASE_REF}\` (${BASE_SHA:0:7})](https://github.com/${BASE_REPO}/commit/${BASE_SHA})" >> coverage_report.md
    +          echo "- **Head Commit:** [\`${HEAD_REF}\` (${HEAD_SHA:0:7})](https://github.com/${HEAD_REPO}/commit/${HEAD_SHA})" >> coverage_report.md
    +          echo "---" >> coverage_report.md
    +          echo "" >> coverage_report.md
    +          echo "**Coverage Validated**" >> coverage_report.md
    +          echo "Modified files do not have standalone unit test targets." >> coverage_report.md
    +
    +          cat coverage_report.md >> $GITHUB_STEP_SUMMARY
    +        fi
    +
    +        END_TIME=$(date +%s)
    +        echo "=== [STAGE 2/4] Targeted Tests Completed in $((END_TIME - START_TIME))s ==="
    +
    +    - name: Merge Profiles
    +      if: env.TARGETS != ''
    +      run: |
    +        echo "=== [STAGE 3/4] Merging Raw Profiles at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +        find build-cov -name "libc_cov_*.profraw" > profraw_list.txt
    +        NUM_PROFS=$(wc -l < profraw_li...
    [truncated]
    
    
    ``````

    </details>

    boomanaiden154 boomanaiden154 commented on code on Sep 02, 2026 17:09 UTC
    Code Review
    .github/workflows/libc-full-coverage.yml:1
    @@ -0,0 +1,143 @@
    +name: Libc Full Codebase Coverage
    +
    +permissions:
    +  contents: write # Required to publish live HTML dashboard to gh-pages branch
    +
    +env:
    +  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
    +
    +on:
    +  # Daily overnight run at 02:00 UTC
    +  schedule:
    +    - cron: '0 2 * * *'
    +
    +  # Allow manual on-demand execution from GitHub Actions UI
    +  workflow_dispatch:
    +
    +  # Trigger on pushes to main / libc-coverage-ci-bots / post-commit-bot
    +  push:
    +    branches:
    +      - main
    +      - libc-coverage-ci-bots
    +      - post-commit-bot
    +    paths:
    +      - 'libc/**'
    +      - '.github/workflows/libc-full-coverage.yml'
    +
    +concurrency:
    +  group: ${{ github.workflow }}-${{ github.ref }}
    +  cancel-in-progress: true
    +
    +jobs:
    +  full-coverage:
    +    timeout-minutes: 60
    +    name: libc-full-coverage
    +    runs-on: ubuntu-24.04
    +    container:
    +      image: ghcr.io/llvm/libc-ubuntu-24.04:latest@sha256:8fee4c9ce5a1fd095686593cd36e032c48a31b6ae575378c82accd1d86a08d59
    +      options: --privileged
    +    defaults:
    +      run:
    +        shell: bash
    +    steps:
    +    - name: Checkout Code
    +      uses: actions/checkout@v4
    +      with:
    +        fetch-depth: 1
    +        persist-credentials: false
    +
    +    - name: Setup Compiler Cache (sccache)
    +      uses: hendrikmuhs/ccache-action@v1.2.23
    +      with:
    +        max-size: 1G
    +        key: libc_coverage_unified_v2_x86_64
    +        variant: sccache
    +
    +    - name: Configure CMake
    +      run: |
    +        echo "=== [STAGE 1/4] Starting CMake Configuration at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +        START_TIME=$(date +%s)
    +
    +        export CMAKE_FLAGS="
    +          -G Ninja
    +          -S runtimes
    +          -B build-cov
    +          -DCMAKE_C_COMPILER=clang-23
    +          -DCMAKE_CXX_COMPILER=clang++-23
    +          -DCMAKE_BUILD_TYPE=Debug
    +          -DCMAKE_C_COMPILER_LAUNCHER=sccache
    +          -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
    +          -DLLVM_USE_LINKER=lld-23
    +          -DLLVM_ENABLE_RUNTIMES=libc
    +          -DLLVM_LIBC_FULL_BUILD=ON
    +          -DLIBC_ENABLE_COVERAGE=ON
    +          -DLIBC_TEST_UNIT_TEST_ONLY=ON
    +          -DLIBC_TEST_SKIP_DEATH_TESTS=ON
    +          -DLIBC_TEST_SKIP_SHARED_TESTS=ON
    +        "
    +        cmake $CMAKE_FLAGS
    +
    +        END_TIME=$(date +%s)
    +        echo "=== [STAGE 1/4] CMake Configuration Completed in $((END_TIME - START_TIME))s ==="
    +
    +    - name: Run Full Codebase Unit Tests
    +      run: |
    +        echo "=== [STAGE 2/4] Running Full Unit Test Suite at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +        START_TIME=$(date +%s)
    +
    +        export LLVM_PROFILE_FILE="libc_cov_%p.profraw"
    +        ninja -k 0 -C build-cov libc-unit-tests || true
    +
    +        END_TIME=$(date +%s)
    +        echo "=== [STAGE 2/4] libc-unit-tests Completed in $((END_TIME - START_TIME))s ==="
    +
    +    - name: Merge Profiles
    +      run: |
    +        echo "=== [STAGE 3/4] Merging Raw Profiles at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +        find . build-cov -name "libc_cov_*.profraw" > profraw_list.txt
    +        NUM_PROFS=$(wc -l < profraw_list.txt || echo 0)
    +        echo "[LOG] Discovered $NUM_PROFS raw profile data files."
    +        llvm-profdata-23 merge -sparse --input-files=profraw_list.txt -o libc_full.profdata
    +        echo "[LOG] Merged full codebase profile into libc_full.profdata."
    +
    +    - name: Generate Reports and Summary
    +      env:
    +        COMMIT_SHA: ${{ github.sha }}
    +        BRANCH_REF: ${{ github.ref_name }}
    +      run: |
    +        echo "=== [STAGE 4/4] Generating Full Codebase Coverage Reports at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +        EXECUTABLES=($(find build-cov -type f -executable -name "*__build__"))
    +        OBJECTS=("${EXECUTABLES[@]:1}")
    +        OBJECTS=("${OBJECTS[@]/#/-object=}")
    +
    +        echo "[LOG] Exporting coverage data across ${#EXECUTABLES[@]} test binaries."
    +
    +        # 1. Generate JSON export for Full Coverage Analyzer
    +        llvm-cov-23 export -format=text -instr-profile=libc_full.profdata "${EXECUTABLES[0]}" "${OBJECTS[@]}" > coverage.json
    +
    +        # 2. Generate HTML Coverage Report with directory hierarchy and branch tracking
    +        llvm-cov-23 show -format=html \
    +          -output-dir=coverage_html \
    +          -instr-profile=libc_full.profdata \
    +          "${EXECUTABLES[0]}" "${OBJECTS[@]}" \
    +          --show-directory-coverage \
    +          --show-branches=count \
    +          --compilation-dir=. \
    +          --path-equivalence="$GITHUB_WORKSPACE,." \
    +          -ignore-filename-regex=".*(test|utils).*"
    +        touch coverage_html/.nojekyll
    +
    +        # 3. Run Codebase Coverage Analyzer
    +        PYTHONPATH="libc/utils/coverage" python3 libc/utils/coverage/codebase_coverage.py coverage.json "$COMMIT_SHA" "$BRANCH_REF" >> $GITHUB_STEP_SUMMARY
    +        echo "[LOG] Post-commit summary report written to GITHUB_STEP_SUMMARY."
    +
    +    - name: Deploy Coverage Dashboard to GitHub Pages
    +      if: github.repository != 'llvm/llvm-project'

    We need a better solution than just using the GH Pages branch of the monorepo. For now we should probably just upload the report as an artifact.

    github-advanced-security[bot] github-advanced-security[bot] commented on code on Sep 03, 2026 10:10 UTC
    Code Review
    .github/workflows/libc-full-coverage.yml:1
    @@ -0,0 +1,149 @@
    +name: Libc Full Codebase Coverage
    +
    +permissions:
    +  contents: read
    +
    +env:
    +  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
    +
    +on:
    +  # Daily overnight run at 02:00 UTC
    +  schedule:
    +    - cron: '0 2 * * *'
    +
    +  # Allow manual on-demand execution from GitHub Actions UI
    +  workflow_dispatch:
    +
    +  # Trigger on pushes to main / libc-coverage-ci-bots / post-commit-bot
    +  push:
    +    branches:
    +      - main
    +      - libc-coverage-ci-bots
    +      - post-commit-bot
    +    paths:
    +      - 'libc/**'
    +      - '.github/workflows/libc-full-coverage.yml'
    +
    +concurrency:
    +  group: ${{ github.workflow }}-${{ github.ref }}
    +  cancel-in-progress: true
    +
    +jobs:
    +  full-coverage:
    +    timeout-minutes: 60
    +    name: libc-full-coverage
    +    runs-on: ubuntu-24.04
    +    container:
    +      image: ghcr.io/llvm/libc-ubuntu-24.04:latest@sha256:8fee4c9ce5a1fd095686593cd36e032c48a31b6ae575378c82accd1d86a08d59
    +      options: --privileged
    +    defaults:
    +      run:
    +        shell: bash
    +    steps:
    +    - name: Checkout Code
    +      uses: actions/checkout@v4
    +      with:
    +        fetch-depth: 1
    +        persist-credentials: false
    +
    +    - name: Setup Compiler Cache (sccache)
    +      uses: hendrikmuhs/ccache-action@v1.2.23

    CodeQL / Unpinned tag for a non-immutable Action or reusable workflow

    Unpinned 3rd party Action 'Libc Full Codebase Coverage' step [Uses Step](1) uses 'hendrikmuhs/ccache-action' with ref 'v1.2.23', not a pinned commit hash

    Show more details

    github-advanced-security[bot] github-advanced-security[bot] commented on code on Sep 03, 2026 10:10 UTC
    Code Review
    .github/workflows/libc-full-mcdc.yml:1
    @@ -0,0 +1,154 @@
    +name: Libc Full Codebase MC/DC Coverage
    +
    +permissions:
    +  contents: read
    +
    +env:
    +  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
    +
    +on:
    +  # Daily overnight run at 02:30 UTC (staggered by 30 mins from baseline sweep)
    +  schedule:
    +    - cron: '30 2 * * *'
    +
    +  # Allow manual on-demand execution from GitHub Actions UI ("Run workflow" button)
    +  workflow_dispatch:
    +
    +  # Trigger on pushes to main / libc-mcdc-coverage / post-commit-bot
    +  push:
    +    branches:
    +      - main
    +      - libc-mcdc-coverage
    +      - post-commit-bot
    +    paths:
    +      - 'libc/**'
    +      - '.github/workflows/libc-full-mcdc.yml'
    +
    +concurrency:
    +  group: ${{ github.workflow }}-${{ github.ref }}
    +  cancel-in-progress: true
    +
    +jobs:
    +  full-mcdc-coverage:
    +    timeout-minutes: 60
    +    name: libc-full-mcdc-coverage
    +    runs-on: ubuntu-24.04
    +    container:
    +      image: ghcr.io/llvm/libc-ubuntu-24.04:latest@sha256:8fee4c9ce5a1fd095686593cd36e032c48a31b6ae575378c82accd1d86a08d59
    +      options: --privileged
    +    defaults:
    +      run:
    +        shell: bash
    +    steps:
    +      - name: Checkout Code
    +        uses: actions/checkout@v4
    +        with:
    +          fetch-depth: 1
    +          persist-credentials: false
    +
    +      - name: Setup Compiler Cache (sccache)
    +        uses: hendrikmuhs/ccache-action@v1.2.23

    CodeQL / Unpinned tag for a non-immutable Action or reusable workflow

    Unpinned 3rd party Action 'Libc Full Codebase MC/DC Coverage' step [Uses Step](1) uses 'hendrikmuhs/ccache-action' with ref 'v1.2.23', not a pinned commit hash

    Show more details

    github-advanced-security[bot] github-advanced-security[bot] commented on code on Sep 03, 2026 10:10 UTC
    Code Review
    .github/workflows/libc-patch-coverage.yml:1
    @@ -0,0 +1,362 @@
    +name: Libc Patch Code Coverage
    +
    +permissions:
    +  contents: read
    +  pull-requests: write # Required to post/update patch coverage comments
    +
    +env:
    +  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
    +
    +on:
    +  workflow_dispatch:
    +  push:
    +    branches:
    +      - pre-commit-bot
    +      - libc-coverage-ci-bots
    +      - main
    +    paths:
    +      - 'libc/src/**'
    +      - 'libc/include/**'
    +      - 'libc/test/**'
    +      - 'libc/CMakeLists.txt'
    +      - '.github/workflows/libc-patch-coverage.yml'
    +      - '!libc/docs/**'
    +      - '!libc/benchmarks/**'
    +      - '!libc/fuzzing/**'
    +      - '!libc/utils/**'
    +      - '!**.md'
    +  pull_request:
    +    paths:
    +      - 'libc/src/**'
    +      - 'libc/include/**'
    +      - 'libc/test/**'
    +      - 'libc/CMakeLists.txt'
    +      - '.github/workflows/libc-patch-coverage.yml'
    +      - '!libc/docs/**'
    +      - '!libc/benchmarks/**'
    +      - '!libc/fuzzing/**'
    +      - '!libc/utils/**'
    +      - '!**.md'
    +
    +concurrency:
    +  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
    +  cancel-in-progress: true
    +
    +jobs:
    +  pre-commit-coverage:
    +    timeout-minutes: 60
    +    name: libc-pre-commit-coverage
    +    runs-on: ubuntu-24.04
    +    container:
    +      image: ghcr.io/llvm/libc-ubuntu-24.04:latest@sha256:8fee4c9ce5a1fd095686593cd36e032c48a31b6ae575378c82accd1d86a08d59
    +      options: >-
    +        --privileged
    +    defaults:
    +      run:
    +        shell: bash
    +    steps:
    +    - name: Checkout Code
    +      uses: actions/checkout@v4
    +      with:
    +        ref: ${{ github.event.pull_request.head.sha || github.sha }}
    +        fetch-depth: 2
    +        persist-credentials: false
    +
    +    - name: Setup Compiler Cache (sccache)
    +      uses: hendrikmuhs/ccache-action@v1.2.23

    CodeQL / Unpinned tag for a non-immutable Action or reusable workflow

    Unpinned 3rd party Action 'Libc Patch Code Coverage' step [Uses Step](1) uses 'hendrikmuhs/ccache-action' with ref 'v1.2.23', not a pinned commit hash

    Show more details

    github-advanced-security[bot] github-advanced-security[bot] commented on code on Sep 03, 2026 10:10 UTC
    Code Review
    .github/workflows/libc-patch-mcdc.yml:1
    @@ -0,0 +1,370 @@
    +name: Libc Patch MC/DC Coverage
    +
    +permissions:
    +  contents: read
    +  pull-requests: write # Required to post/update patch coverage comments
    +
    +env:
    +  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
    +
    +on:
    +  workflow_dispatch:
    +  push:
    +    branches:
    +      - 'test-*'
    +      - 'libc-mcdc-*'
    +      - main
    +    paths:
    +      - 'libc/src/**'
    +      - 'libc/include/**'
    +      - 'libc/test/**'
    +      - 'libc/CMakeLists.txt'
    +      - '.github/workflows/libc-patch-mcdc.yml'
    +      - '!libc/docs/**'
    +      - '!libc/benchmarks/**'
    +      - '!libc/fuzzing/**'
    +      - '!libc/utils/**'
    +      - '!**.md'
    +  pull_request:
    +    paths:
    +      - 'libc/src/**'
    +      - 'libc/include/**'
    +      - 'libc/test/**'
    +      - 'libc/CMakeLists.txt'
    +      - '.github/workflows/libc-patch-mcdc.yml'
    +      - '!libc/docs/**'
    +      - '!libc/benchmarks/**'
    +      - '!libc/fuzzing/**'
    +      - '!libc/utils/**'
    +      - '!**.md'
    +
    +concurrency:
    +  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
    +  cancel-in-progress: true
    +
    +jobs:
    +  pre-commit-mcdc-coverage:
    +    timeout-minutes: 60
    +    name: libc-pre-commit-mcdc-coverage
    +    runs-on: ubuntu-24.04
    +    container:
    +      image: ghcr.io/llvm/libc-ubuntu-24.04:latest@sha256:8fee4c9ce5a1fd095686593cd36e032c48a31b6ae575378c82accd1d86a08d59
    +      options: >-
    +        --privileged
    +    defaults:
    +      run:
    +        shell: bash
    +    steps:
    +    - name: Checkout Code
    +      uses: actions/checkout@v4
    +      with:
    +        ref: ${{ github.event.pull_request.head.sha || github.sha }}
    +        fetch-depth: 2
    +        persist-credentials: false
    +
    +    - name: Setup Compiler Cache (sccache)
    +      uses: hendrikmuhs/ccache-action@v1.2.23

    CodeQL / Unpinned tag for a non-immutable Action or reusable workflow

    Unpinned 3rd party Action 'Libc Patch MC/DC Coverage' step [Uses Step](1) uses 'hendrikmuhs/ccache-action' with ref 'v1.2.23', not a pinned commit hash

    Show more details

    github-advanced-security[bot] github-advanced-security[bot] commented on code on Sep 03, 2026 10:11 UTC
    Code Review
    .github/workflows/libc-full-coverage.yml:1
    @@ -0,0 +1,149 @@
    +name: Libc Full Codebase Coverage
    +
    +permissions:
    +  contents: read
    +
    +env:
    +  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
    +
    +on:
    +  # Daily overnight run at 02:00 UTC
    +  schedule:
    +    - cron: '0 2 * * *'
    +
    +  # Allow manual on-demand execution from GitHub Actions UI
    +  workflow_dispatch:
    +
    +  # Trigger on pushes to main / libc-coverage-ci-bots / post-commit-bot
    +  push:
    +    branches:
    +      - main
    +      - libc-coverage-ci-bots
    +      - post-commit-bot
    +    paths:
    +      - 'libc/**'
    +      - '.github/workflows/libc-full-coverage.yml'
    +
    +concurrency:
    +  group: ${{ github.workflow }}-${{ github.ref }}
    +  cancel-in-progress: true
    +
    +jobs:
    +  full-coverage:
    +    timeout-minutes: 60
    +    name: libc-full-coverage
    +    runs-on: ubuntu-24.04
    +    container:
    +      image: ghcr.io/llvm/libc-ubuntu-24.04:latest@sha256:8fee4c9ce5a1fd095686593cd36e032c48a31b6ae575378c82accd1d86a08d59
    +      options: --privileged
    +    defaults:
    +      run:
    +        shell: bash
    +    steps:
    +    - name: Checkout Code
    +      uses: actions/checkout@v4

    zizmor /

    unpinned action reference: action is not pinned to a hash (required by blanket policy)

    Show more details

    github-advanced-security[bot] github-advanced-security[bot] commented on code on Sep 03, 2026 10:11 UTC
    Code Review
    .github/workflows/libc-full-coverage.yml:1
    @@ -0,0 +1,149 @@
    +name: Libc Full Codebase Coverage
    +
    +permissions:
    +  contents: read
    +
    +env:
    +  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
    +
    +on:
    +  # Daily overnight run at 02:00 UTC
    +  schedule:
    +    - cron: '0 2 * * *'
    +
    +  # Allow manual on-demand execution from GitHub Actions UI
    +  workflow_dispatch:
    +
    +  # Trigger on pushes to main / libc-coverage-ci-bots / post-commit-bot
    +  push:
    +    branches:
    +      - main
    +      - libc-coverage-ci-bots
    +      - post-commit-bot
    +    paths:
    +      - 'libc/**'
    +      - '.github/workflows/libc-full-coverage.yml'
    +
    +concurrency:
    +  group: ${{ github.workflow }}-${{ github.ref }}
    +  cancel-in-progress: true
    +
    +jobs:
    +  full-coverage:
    +    timeout-minutes: 60
    +    name: libc-full-coverage
    +    runs-on: ubuntu-24.04
    +    container:
    +      image: ghcr.io/llvm/libc-ubuntu-24.04:latest@sha256:8fee4c9ce5a1fd095686593cd36e032c48a31b6ae575378c82accd1d86a08d59
    +      options: --privileged
    +    defaults:
    +      run:
    +        shell: bash
    +    steps:
    +    - name: Checkout Code
    +      uses: actions/checkout@v4
    +      with:
    +        fetch-depth: 1
    +        persist-credentials: false
    +
    +    - name: Setup Compiler Cache (sccache)
    +      uses: hendrikmuhs/ccache-action@v1.2.23

    zizmor /

    unpinned action reference: action is not pinned to a hash (required by blanket policy)

    Show more details

    github-advanced-security[bot] github-advanced-security[bot] commented on code on Sep 03, 2026 10:11 UTC
    Code Review
    .github/workflows/libc-full-coverage.yml:1
    @@ -0,0 +1,149 @@
    +name: Libc Full Codebase Coverage
    +
    +permissions:
    +  contents: read
    +
    +env:
    +  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
    +
    +on:
    +  # Daily overnight run at 02:00 UTC
    +  schedule:
    +    - cron: '0 2 * * *'
    +
    +  # Allow manual on-demand execution from GitHub Actions UI
    +  workflow_dispatch:
    +
    +  # Trigger on pushes to main / libc-coverage-ci-bots / post-commit-bot
    +  push:
    +    branches:
    +      - main
    +      - libc-coverage-ci-bots
    +      - post-commit-bot
    +    paths:
    +      - 'libc/**'
    +      - '.github/workflows/libc-full-coverage.yml'
    +
    +concurrency:
    +  group: ${{ github.workflow }}-${{ github.ref }}
    +  cancel-in-progress: true
    +
    +jobs:
    +  full-coverage:
    +    timeout-minutes: 60
    +    name: libc-full-coverage
    +    runs-on: ubuntu-24.04
    +    container:
    +      image: ghcr.io/llvm/libc-ubuntu-24.04:latest@sha256:8fee4c9ce5a1fd095686593cd36e032c48a31b6ae575378c82accd1d86a08d59
    +      options: --privileged
    +    defaults:
    +      run:
    +        shell: bash
    +    steps:
    +    - name: Checkout Code
    +      uses: actions/checkout@v4
    +      with:
    +        fetch-depth: 1
    +        persist-credentials: false
    +
    +    - name: Setup Compiler Cache (sccache)
    +      uses: hendrikmuhs/ccache-action@v1.2.23
    +      with:
    +        max-size: 1G
    +        key: libc_coverage_unified_v2_x86_64
    +        variant: sccache
    +
    +    - name: Configure CMake
    +      run: |
    +        echo "=== [STAGE 1/4] Starting CMake Configuration at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +        START_TIME=$(date +%s)
    +
    +        export CMAKE_FLAGS="
    +          -G Ninja
    +          -S runtimes
    +          -B build-cov
    +          -DCMAKE_C_COMPILER=clang-23
    +          -DCMAKE_CXX_COMPILER=clang++-23
    +          -DCMAKE_BUILD_TYPE=Debug
    +          -DCMAKE_C_COMPILER_LAUNCHER=sccache
    +          -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
    +          -DLLVM_USE_LINKER=lld-23
    +          -DLLVM_ENABLE_RUNTIMES=libc
    +          -DLLVM_LIBC_FULL_BUILD=ON
    +          -DLIBC_ENABLE_COVERAGE=ON
    +          -DLIBC_TEST_UNIT_TEST_ONLY=ON
    +          -DLIBC_TEST_SKIP_DEATH_TESTS=ON
    +          -DLIBC_TEST_SKIP_SHARED_TESTS=ON
    +        "
    +        cmake $CMAKE_FLAGS
    +
    +        END_TIME=$(date +%s)
    +        echo "=== [STAGE 1/4] CMake Configuration Completed in $((END_TIME - START_TIME))s ==="
    +
    +    - name: Run Full Codebase Unit Tests
    +      run: |
    +        echo "=== [STAGE 2/4] Running Full Unit Test Suite at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +        START_TIME=$(date +%s)
    +
    +        export LLVM_PROFILE_FILE="libc_cov_%p.profraw"
    +        ninja -k 0 -C build-cov libc-unit-tests || true
    +
    +        END_TIME=$(date +%s)
    +        echo "=== [STAGE 2/4] libc-unit-tests Completed in $((END_TIME - START_TIME))s ==="
    +
    +    - name: Merge Profiles
    +      run: |
    +        echo "=== [STAGE 3/4] Merging Raw Profiles at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +        find . -name "libc_cov_*.profraw" > profraw_list.txt
    +        NUM_PROFS=$(wc -l < profraw_list.txt || echo 0)
    +        echo "[LOG] Discovered $NUM_PROFS raw profile data files."
    +        if [ -s profraw_list.txt ]; then
    +          llvm-profdata-23 merge -sparse --input-files=profraw_list.txt -o libc_full.profdata
    +          echo "[LOG] Merged full codebase profile into libc_full.profdata."
    +        else
    +          echo "[LOG] Warning: No profraw files found."
    +        fi
    +
    +    - name: Generate Reports and Summary
    +      env:
    +        COMMIT_SHA: ${{ github.sha }}
    +        BRANCH_REF: ${{ github.ref_name }}
    +      run: |
    +        echo "=== [STAGE 4/4] Generating Full Codebase Coverage Reports at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +        EXECUTABLES=($(find build-cov -type f -executable -name "*__build__"))
    +        OBJECTS=("${EXECUTABLES[@]:1}")
    +        OBJECTS=("${OBJECTS[@]/#/-object=}")
    +
    +        echo "[LOG] Exporting coverage data across ${#EXECUTABLES[@]} test binaries."
    +
    +        if [ ! -f libc_full.profdata ] || [ ${#EXECUTABLES[@]} -eq 0 ]; then
    +          echo "[LOG] Warning: Profile data or test executables missing. Skipping report generation."
    +          echo "### LLVM-libc Coverage Report" >> $GITHUB_STEP_SUMMARY
    +          echo "No coverage data was generated for this run." >> $GITHUB_STEP_SUMMARY
    +          exit 0
    +        fi
    +
    +        # 1. Generate JSON export for Full Coverage Analyzer
    +        llvm-cov-23 export -format=text -instr-profile=libc_full.profdata "${EXECUTABLES[0]}" "${OBJECTS[@]}" > coverage.json
    +
    +        # 2. Generate HTML Coverage Report with directory hierarchy and branch tracking
    +        llvm-cov-23 show -format=html \
    +          -output-dir=coverage_html \
    +          -instr-profile=libc_full.profdata \
    +          "${EXECUTABLES[0]}" "${OBJECTS[@]}" \
    +          --show-directory-coverage \
    +          --show-branches=count \
    +          --compilation-dir=. \
    +          --path-equivalence="$GITHUB_WORKSPACE,." \
    +          -ignore-filename-regex=".*(test|utils).*"
    +        # 3. Run Codebase Coverage Analyzer
    +        PYTHONPATH="libc/utils/coverage" python3 libc/utils/coverage/codebase_coverage.py coverage.json "$COMMIT_SHA" "$BRANCH_REF" >> $GITHUB_STEP_SUMMARY
    +        echo "[LOG] Post-commit summary report written to GITHUB_STEP_SUMMARY."
    +
    +    - name: Upload HTML Coverage Artifact
    +      uses: actions/upload-artifact@v4

    zizmor /

    unpinned action reference: action is not pinned to a hash (required by blanket policy)

    Show more details

    github-advanced-security[bot] github-advanced-security[bot] commented on code on Sep 03, 2026 10:11 UTC
    Code Review
    .github/workflows/libc-full-mcdc.yml:1
    @@ -0,0 +1,154 @@
    +name: Libc Full Codebase MC/DC Coverage
    +
    +permissions:
    +  contents: read
    +
    +env:
    +  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
    +
    +on:
    +  # Daily overnight run at 02:30 UTC (staggered by 30 mins from baseline sweep)
    +  schedule:
    +    - cron: '30 2 * * *'
    +
    +  # Allow manual on-demand execution from GitHub Actions UI ("Run workflow" button)
    +  workflow_dispatch:
    +
    +  # Trigger on pushes to main / libc-mcdc-coverage / post-commit-bot
    +  push:
    +    branches:
    +      - main
    +      - libc-mcdc-coverage
    +      - post-commit-bot
    +    paths:
    +      - 'libc/**'
    +      - '.github/workflows/libc-full-mcdc.yml'
    +
    +concurrency:
    +  group: ${{ github.workflow }}-${{ github.ref }}
    +  cancel-in-progress: true
    +
    +jobs:
    +  full-mcdc-coverage:
    +    timeout-minutes: 60
    +    name: libc-full-mcdc-coverage
    +    runs-on: ubuntu-24.04
    +    container:
    +      image: ghcr.io/llvm/libc-ubuntu-24.04:latest@sha256:8fee4c9ce5a1fd095686593cd36e032c48a31b6ae575378c82accd1d86a08d59
    +      options: --privileged
    +    defaults:
    +      run:
    +        shell: bash
    +    steps:
    +      - name: Checkout Code
    +        uses: actions/checkout@v4

    zizmor /

    unpinned action reference: action is not pinned to a hash (required by blanket policy)

    Show more details

    github-advanced-security[bot] github-advanced-security[bot] commented on code on Sep 03, 2026 10:11 UTC
    Code Review
    .github/workflows/libc-full-mcdc.yml:1
    @@ -0,0 +1,154 @@
    +name: Libc Full Codebase MC/DC Coverage
    +
    +permissions:
    +  contents: read
    +
    +env:
    +  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
    +
    +on:
    +  # Daily overnight run at 02:30 UTC (staggered by 30 mins from baseline sweep)
    +  schedule:
    +    - cron: '30 2 * * *'
    +
    +  # Allow manual on-demand execution from GitHub Actions UI ("Run workflow" button)
    +  workflow_dispatch:
    +
    +  # Trigger on pushes to main / libc-mcdc-coverage / post-commit-bot
    +  push:
    +    branches:
    +      - main
    +      - libc-mcdc-coverage
    +      - post-commit-bot
    +    paths:
    +      - 'libc/**'
    +      - '.github/workflows/libc-full-mcdc.yml'
    +
    +concurrency:
    +  group: ${{ github.workflow }}-${{ github.ref }}
    +  cancel-in-progress: true
    +
    +jobs:
    +  full-mcdc-coverage:
    +    timeout-minutes: 60
    +    name: libc-full-mcdc-coverage
    +    runs-on: ubuntu-24.04
    +    container:
    +      image: ghcr.io/llvm/libc-ubuntu-24.04:latest@sha256:8fee4c9ce5a1fd095686593cd36e032c48a31b6ae575378c82accd1d86a08d59
    +      options: --privileged
    +    defaults:
    +      run:
    +        shell: bash
    +    steps:
    +      - name: Checkout Code
    +        uses: actions/checkout@v4
    +        with:
    +          fetch-depth: 1
    +          persist-credentials: false
    +
    +      - name: Setup Compiler Cache (sccache)
    +        uses: hendrikmuhs/ccache-action@v1.2.23

    zizmor /

    unpinned action reference: action is not pinned to a hash (required by blanket policy)

    Show more details

    github-advanced-security[bot] github-advanced-security[bot] commented on code on Sep 03, 2026 10:11 UTC
    Code Review
    .github/workflows/libc-full-mcdc.yml:1
    @@ -0,0 +1,154 @@
    +name: Libc Full Codebase MC/DC Coverage
    +
    +permissions:
    +  contents: read
    +
    +env:
    +  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
    +
    +on:
    +  # Daily overnight run at 02:30 UTC (staggered by 30 mins from baseline sweep)
    +  schedule:
    +    - cron: '30 2 * * *'
    +
    +  # Allow manual on-demand execution from GitHub Actions UI ("Run workflow" button)
    +  workflow_dispatch:
    +
    +  # Trigger on pushes to main / libc-mcdc-coverage / post-commit-bot
    +  push:
    +    branches:
    +      - main
    +      - libc-mcdc-coverage
    +      - post-commit-bot
    +    paths:
    +      - 'libc/**'
    +      - '.github/workflows/libc-full-mcdc.yml'
    +
    +concurrency:
    +  group: ${{ github.workflow }}-${{ github.ref }}
    +  cancel-in-progress: true
    +
    +jobs:
    +  full-mcdc-coverage:
    +    timeout-minutes: 60
    +    name: libc-full-mcdc-coverage
    +    runs-on: ubuntu-24.04
    +    container:
    +      image: ghcr.io/llvm/libc-ubuntu-24.04:latest@sha256:8fee4c9ce5a1fd095686593cd36e032c48a31b6ae575378c82accd1d86a08d59
    +      options: --privileged
    +    defaults:
    +      run:
    +        shell: bash
    +    steps:
    +      - name: Checkout Code
    +        uses: actions/checkout@v4
    +        with:
    +          fetch-depth: 1
    +          persist-credentials: false
    +
    +      - name: Setup Compiler Cache (sccache)
    +        uses: hendrikmuhs/ccache-action@v1.2.23
    +        with:
    +          max-size: 1G
    +          key: libc_mcdc_coverage_unified_x86_64
    +          variant: sccache
    +
    +      - name: Configure CMake with MC/DC
    +        run: |
    +          echo "=== [STAGE 1/4] Starting CMake Configuration (MC/DC) at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +          START_TIME=$(date +%s)
    +
    +          export CMAKE_FLAGS="
    +            -G Ninja
    +            -S runtimes
    +            -B build-cov
    +            -DCMAKE_C_COMPILER=clang-23
    +            -DCMAKE_CXX_COMPILER=clang++-23
    +            -DCMAKE_BUILD_TYPE=Debug
    +            -DCMAKE_C_COMPILER_LAUNCHER=sccache
    +            -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
    +            -DLLVM_USE_LINKER=lld-23
    +            -DLLVM_ENABLE_RUNTIMES=libc
    +            -DLLVM_LIBC_FULL_BUILD=ON
    +            -DLIBC_ENABLE_COVERAGE=ON
    +            -DLIBC_ENABLE_MCDC=ON
    +            -DLIBC_TEST_UNIT_TEST_ONLY=ON
    +            -DLIBC_TEST_SKIP_DEATH_TESTS=ON
    +            -DLIBC_TEST_SKIP_SHARED_TESTS=ON
    +          "
    +          cmake $CMAKE_FLAGS
    +
    +          END_TIME=$(date +%s)
    +          echo "=== [STAGE 1/4] CMake Configuration Completed in $((END_TIME - START_TIME))s ==="
    +
    +      - name: Run Full Codebase Unit Tests
    +        run: |
    +          echo "=== [STAGE 2/4] Running Full Unit Test Suite at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +          START_TIME=$(date +%s)
    +
    +          export LLVM_PROFILE_FILE="libc_cov_%p.profraw"
    +          ninja -k 0 -C build-cov libc-unit-tests || true
    +
    +          END_TIME=$(date +%s)
    +          echo "=== [STAGE 2/4] libc-unit-tests Completed in $((END_TIME - START_TIME))s ==="
    +
    +      - name: Merge Profiles
    +        run: |
    +          echo "=== [STAGE 3/4] Merging Raw Profiles at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +          find . -name "libc_cov_*.profraw" > profraw_list.txt
    +          NUM_PROFS=$(wc -l < profraw_list.txt || echo 0)
    +          echo "[LOG] Discovered $NUM_PROFS raw profile data files."
    +          if [ -s profraw_list.txt ]; then
    +            llvm-profdata-23 merge -sparse --input-files=profraw_list.txt -o libc_full.profdata
    +            echo "[LOG] Merged full codebase profile into libc_full.profdata."
    +          else
    +            echo "[LOG] Warning: No profraw files found."
    +          fi
    +
    +      - name: Generate Reports and Summary
    +        env:
    +          COMMIT_SHA: ${{ github.sha }}
    +          BRANCH_REF: ${{ github.ref_name }}
    +        run: |
    +          echo "=== [STAGE 4/4] Generating Full Codebase MC/DC Coverage Reports at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +          EXECUTABLES=($(find build-cov -type f -executable -name "*__build__"))
    +          OBJECTS=("${EXECUTABLES[@]:1}")
    +          OBJECTS=("${OBJECTS[@]/#/-object=}")
    +
    +          echo "[LOG] Exporting coverage data across ${#EXECUTABLES[@]} test binaries."
    +
    +          if [ ! -f libc_full.profdata ] || [ ${#EXECUTABLES[@]} -eq 0 ]; then
    +            echo "[LOG] Warning: Profile data or test executables missing. Skipping report generation."
    +            echo "### LLVM-libc MC/DC Coverage Report" >> $GITHUB_STEP_SUMMARY
    +            echo "No coverage data was generated for this run." >> $GITHUB_STEP_SUMMARY
    +            exit 0
    +          fi
    +
    +          # 1. Generate JSON export for Full Coverage Analyzer (contains mcdc_records)
    +          llvm-cov-23 export -format=text -instr-profile=libc_full.profdata "${EXECUTABLES[0]}" "${OBJECTS[@]}" > coverage.json
    +
    +          # 2. Generate HTML Coverage Report with directory hierarchy, branch tracking, and MC/DC truth tables
    +          llvm-cov-23 show -format=html \
    +            -output-dir=coverage_mcdc_html \
    +            -instr-profile=libc_full.profdata \
    +            "${EXECUTABLES[0]}" "${OBJECTS[@]}" \
    +            --show-directory-coverage \
    +            --show-branches=count \
    +            --show-mcdc \
    +            --show-mcdc-summary \
    +            --compilation-dir=. \
    +            --path-equivalence="$GITHUB_WORKSPACE,." \
    +            -ignore-filename-regex=".*(test|utils).*"
    +          # 3. Run Codebase Coverage Analyzer
    +          PYTHONPATH="libc/utils/coverage" python3 libc/utils/coverage/codebase_coverage.py coverage.json "$COMMIT_SHA" "$BRANCH_REF" >> $GITHUB_STEP_SUMMARY
    +          echo "[LOG] Post-commit summary report written to GITHUB_STEP_SUMMARY."
    +
    +      - name: Upload MC/DC Coverage Artifact
    +        uses: actions/upload-artifact@v4

    zizmor /

    unpinned action reference: action is not pinned to a hash (required by blanket policy)

    Show more details

    github-advanced-security[bot] github-advanced-security[bot] commented on code on Sep 03, 2026 10:11 UTC
    Code Review
    .github/workflows/libc-patch-coverage.yml:1
    @@ -0,0 +1,362 @@
    +name: Libc Patch Code Coverage
    +
    +permissions:
    +  contents: read
    +  pull-requests: write # Required to post/update patch coverage comments
    +
    +env:
    +  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
    +
    +on:
    +  workflow_dispatch:
    +  push:
    +    branches:
    +      - pre-commit-bot
    +      - libc-coverage-ci-bots
    +      - main
    +    paths:
    +      - 'libc/src/**'
    +      - 'libc/include/**'
    +      - 'libc/test/**'
    +      - 'libc/CMakeLists.txt'
    +      - '.github/workflows/libc-patch-coverage.yml'
    +      - '!libc/docs/**'
    +      - '!libc/benchmarks/**'
    +      - '!libc/fuzzing/**'
    +      - '!libc/utils/**'
    +      - '!**.md'
    +  pull_request:
    +    paths:
    +      - 'libc/src/**'
    +      - 'libc/include/**'
    +      - 'libc/test/**'
    +      - 'libc/CMakeLists.txt'
    +      - '.github/workflows/libc-patch-coverage.yml'
    +      - '!libc/docs/**'
    +      - '!libc/benchmarks/**'
    +      - '!libc/fuzzing/**'
    +      - '!libc/utils/**'
    +      - '!**.md'
    +
    +concurrency:
    +  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
    +  cancel-in-progress: true
    +
    +jobs:
    +  pre-commit-coverage:
    +    timeout-minutes: 60
    +    name: libc-pre-commit-coverage
    +    runs-on: ubuntu-24.04
    +    container:
    +      image: ghcr.io/llvm/libc-ubuntu-24.04:latest@sha256:8fee4c9ce5a1fd095686593cd36e032c48a31b6ae575378c82accd1d86a08d59
    +      options: >-
    +        --privileged
    +    defaults:
    +      run:
    +        shell: bash
    +    steps:
    +    - name: Checkout Code
    +      uses: actions/checkout@v4

    zizmor /

    unpinned action reference: action is not pinned to a hash (required by blanket policy)

    Show more details

    github-advanced-security[bot] github-advanced-security[bot] commented on code on Sep 03, 2026 10:11 UTC
    Code Review
    .github/workflows/libc-patch-coverage.yml:1
    @@ -0,0 +1,362 @@
    +name: Libc Patch Code Coverage
    +
    +permissions:
    +  contents: read
    +  pull-requests: write # Required to post/update patch coverage comments
    +
    +env:
    +  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
    +
    +on:
    +  workflow_dispatch:
    +  push:
    +    branches:
    +      - pre-commit-bot
    +      - libc-coverage-ci-bots
    +      - main
    +    paths:
    +      - 'libc/src/**'
    +      - 'libc/include/**'
    +      - 'libc/test/**'
    +      - 'libc/CMakeLists.txt'
    +      - '.github/workflows/libc-patch-coverage.yml'
    +      - '!libc/docs/**'
    +      - '!libc/benchmarks/**'
    +      - '!libc/fuzzing/**'
    +      - '!libc/utils/**'
    +      - '!**.md'
    +  pull_request:
    +    paths:
    +      - 'libc/src/**'
    +      - 'libc/include/**'
    +      - 'libc/test/**'
    +      - 'libc/CMakeLists.txt'
    +      - '.github/workflows/libc-patch-coverage.yml'
    +      - '!libc/docs/**'
    +      - '!libc/benchmarks/**'
    +      - '!libc/fuzzing/**'
    +      - '!libc/utils/**'
    +      - '!**.md'
    +
    +concurrency:
    +  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
    +  cancel-in-progress: true
    +
    +jobs:
    +  pre-commit-coverage:
    +    timeout-minutes: 60
    +    name: libc-pre-commit-coverage
    +    runs-on: ubuntu-24.04
    +    container:
    +      image: ghcr.io/llvm/libc-ubuntu-24.04:latest@sha256:8fee4c9ce5a1fd095686593cd36e032c48a31b6ae575378c82accd1d86a08d59
    +      options: >-
    +        --privileged
    +    defaults:
    +      run:
    +        shell: bash
    +    steps:
    +    - name: Checkout Code
    +      uses: actions/checkout@v4
    +      with:
    +        ref: ${{ github.event.pull_request.head.sha || github.sha }}
    +        fetch-depth: 2
    +        persist-credentials: false
    +
    +    - name: Setup Compiler Cache (sccache)
    +      uses: hendrikmuhs/ccache-action@v1.2.23

    zizmor /

    unpinned action reference: action is not pinned to a hash (required by blanket policy)

    Show more details

    github-advanced-security[bot] github-advanced-security[bot] commented on code on Sep 03, 2026 10:11 UTC
    Code Review
    .github/workflows/libc-patch-coverage.yml:1
    @@ -0,0 +1,362 @@
    +name: Libc Patch Code Coverage
    +
    +permissions:
    +  contents: read
    +  pull-requests: write # Required to post/update patch coverage comments
    +
    +env:
    +  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
    +
    +on:
    +  workflow_dispatch:
    +  push:
    +    branches:
    +      - pre-commit-bot
    +      - libc-coverage-ci-bots
    +      - main
    +    paths:
    +      - 'libc/src/**'
    +      - 'libc/include/**'
    +      - 'libc/test/**'
    +      - 'libc/CMakeLists.txt'
    +      - '.github/workflows/libc-patch-coverage.yml'
    +      - '!libc/docs/**'
    +      - '!libc/benchmarks/**'
    +      - '!libc/fuzzing/**'
    +      - '!libc/utils/**'
    +      - '!**.md'
    +  pull_request:
    +    paths:
    +      - 'libc/src/**'
    +      - 'libc/include/**'
    +      - 'libc/test/**'
    +      - 'libc/CMakeLists.txt'
    +      - '.github/workflows/libc-patch-coverage.yml'
    +      - '!libc/docs/**'
    +      - '!libc/benchmarks/**'
    +      - '!libc/fuzzing/**'
    +      - '!libc/utils/**'
    +      - '!**.md'
    +
    +concurrency:
    +  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
    +  cancel-in-progress: true
    +
    +jobs:
    +  pre-commit-coverage:
    +    timeout-minutes: 60
    +    name: libc-pre-commit-coverage
    +    runs-on: ubuntu-24.04
    +    container:
    +      image: ghcr.io/llvm/libc-ubuntu-24.04:latest@sha256:8fee4c9ce5a1fd095686593cd36e032c48a31b6ae575378c82accd1d86a08d59
    +      options: >-
    +        --privileged
    +    defaults:
    +      run:
    +        shell: bash
    +    steps:
    +    - name: Checkout Code
    +      uses: actions/checkout@v4
    +      with:
    +        ref: ${{ github.event.pull_request.head.sha || github.sha }}
    +        fetch-depth: 2
    +        persist-credentials: false
    +
    +    - name: Setup Compiler Cache (sccache)
    +      uses: hendrikmuhs/ccache-action@v1.2.23
    +      with:
    +        max-size: 1G
    +        key: libc_coverage_unified_v2_x86_64
    +        variant: sccache
    +
    +    - name: Configure CMake
    +      run: |
    +        echo "=== [STAGE 1/4] Starting CMake Configuration at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +        START_TIME=$(date +%s)
    +
    +        export CMAKE_FLAGS="
    +          -G Ninja
    +          -S runtimes
    +          -B build-cov
    +          -DCMAKE_C_COMPILER=clang-23
    +          -DCMAKE_CXX_COMPILER=clang++-23
    +          -DCMAKE_BUILD_TYPE=Debug
    +          -DCMAKE_C_COMPILER_LAUNCHER=sccache
    +          -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
    +          -DLLVM_USE_LINKER=lld-23
    +          -DLLVM_ENABLE_RUNTIMES=libc
    +          -DLLVM_LIBC_FULL_BUILD=ON
    +          -DLIBC_ENABLE_COVERAGE=ON
    +          -DLIBC_TEST_UNIT_TEST_ONLY=ON
    +          -DLIBC_TEST_SKIP_DEATH_TESTS=ON
    +          -DLIBC_TEST_SKIP_SHARED_TESTS=ON
    +        "
    +        cmake $CMAKE_FLAGS
    +
    +        END_TIME=$(date +%s)
    +        echo "=== [STAGE 1/4] CMake Configuration Completed in $((END_TIME - START_TIME))s ==="
    +
    +    - name: Build and Run Targeted Tests
    +      env:
    +        EVENT_NAME: ${{ github.event_name }}
    +        PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
    +        PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
    +        PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
    +        PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
    +        PR_BASE_REPO: ${{ github.event.pull_request.base.repo.full_name }}
    +        PR_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
    +        COMMIT_SHA: ${{ github.sha }}
    +        BRANCH_REF: ${{ github.ref_name }}
    +        REPO_NAME: ${{ github.repository }}
    +      run: |
    +        echo "=== [STAGE 2/4] Starting Targeted Test Discovery at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +        START_TIME=$(date +%s)
    +
    +        # Ensure upstream llvm-project remote is configured
    +        git remote add upstream https://github.com/llvm/llvm-project.git 2>/dev/null || true
    +
    +        # 1. Deterministically resolve Base and Head references against upstream llvm-project
    +        if [ "$EVENT_NAME" == "pull_request" ]; then
    +          BASE_SHA="$PR_BASE_SHA"
    +          HEAD_SHA="$PR_HEAD_SHA"
    +          BASE_REF="$PR_BASE_REF"
    +          HEAD_REF="$PR_HEAD_REF"
    +          BASE_REPO="${PR_BASE_REPO:-llvm/llvm-project}"
    +          HEAD_REPO="${PR_HEAD_REPO:-$REPO_NAME}"
    +          git fetch upstream "$BASE_SHA" --depth=1 2>/dev/null || git fetch origin "$BASE_SHA" --depth=1 2>/dev/null || git fetch origin "$BASE_REF" --depth=1 2>/dev/null || true
    +          DIFF_BASE="$BASE_SHA"
    +        else
    +          # For direct pushes, compare the pushed commit against its parent (HEAD~1)
    +          BASE_SHA=$(git rev-parse HEAD~1 2>/dev/null || echo "HEAD~1")
    +          HEAD_SHA="$COMMIT_SHA"
    +          BASE_REF="main"
    +          HEAD_REF="$BRANCH_REF"
    +          BASE_REPO="llvm/llvm-project"
    +          HEAD_REPO="$REPO_NAME"
    +          DIFF_BASE="HEAD~1"
    +        fi
    +
    +        # Persist resolved commit references for all downstream steps
    +        echo "DIFF_BASE=$DIFF_BASE" >> $GITHUB_ENV
    +        echo "BASE_SHA=$BASE_SHA" >> $GITHUB_ENV
    +        echo "HEAD_SHA=$HEAD_SHA" >> $GITHUB_ENV
    +        echo "BASE_REF=$BASE_REF" >> $GITHUB_ENV
    +        echo "HEAD_REF=$HEAD_REF" >> $GITHUB_ENV
    +        echo "BASE_REPO=$BASE_REPO" >> $GITHUB_ENV
    +        echo "HEAD_REPO=$HEAD_REPO" >> $GITHUB_ENV
    +
    +        echo "[LOG] Resolved Base: ${BASE_REF} (${BASE_SHA:0:7}) in ${BASE_REPO}"
    +        echo "[LOG] Resolved Head: ${HEAD_REF} (${HEAD_SHA:0:7}) in ${HEAD_REPO}"
    +
    +        MODIFIED_FILES=$(git diff --name-only "$DIFF_BASE" HEAD -- libc/src/ || true)
    +        echo "[LOG] Modified files in libc/src/:"
    +        echo "$MODIFIED_FILES"
    +
    +        if [ -z "$MODIFIED_FILES" ]; then
    +          echo "[LOG] No source files modified in libc/src/. Exiting successfully."
    +          echo "TARGETS=" >> $GITHUB_ENV
    +
    +          echo "## LLVM-libc Patch Coverage Report" > coverage_report.md
    +          echo "" >> coverage_report.md
    +          echo "- **Base Branch:** [\`${BASE_REF}\` (${BASE_SHA:0:7})](https://github.com/${BASE_REPO}/commit/${BASE_SHA})" >> coverage_report.md
    +          echo "- **Head Commit:** [\`${HEAD_REF}\` (${HEAD_SHA:0:7})](https://github.com/${HEAD_REPO}/commit/${HEAD_SHA})" >> coverage_report.md
    +          echo "---" >> coverage_report.md
    +          echo "" >> coverage_report.md
    +          echo "**Coverage Validated**" >> coverage_report.md
    +          echo "No \`.cpp\` source files in \`libc/src/\` were modified in this patch." >> coverage_report.md
    +
    +          cat coverage_report.md >> $GITHUB_STEP_SUMMARY
    +          exit 0
    +        fi
    +
    +        # Get all valid ninja targets
    +        ninja -C build-cov -t targets > all_targets.txt
    +
    +        TARGETS=""
    +
    +        for FILE in $MODIFIED_FILES; do
    +          # Skip core support files from direct target mapping (tested transitively)
    +          if [[ "$FILE" == *"__support/"* ]]; then
    +            echo "[LOG] -> Support file ($FILE) will be tested transitively."
    +            continue
    +          fi
    +
    +          if [[ "$FILE" =~ ^libc/src/([^/]+)/(.*/)?([^/]+)\.cpp$ ]]; then
    +            DIR="${BASH_REMATCH[1]}"
    +            FUNC="${BASH_REMATCH[3]}"
    +            ALL_MATCHES=$(grep -oE "^libc\.test\.src\.${DIR}\.([a-zA-Z0-9_]+\.)*${FUNC}_test\.__unit__" all_targets.txt || true)
    +            FOUND_TARGET=$(echo "$ALL_MATCHES" | head -n 1 | tr -d '\r\n ' || true)
    +            if [ -n "$FOUND_TARGET" ]; then
    +              echo "[LOG] -> Matched $FILE -> $FOUND_TARGET"
    +              TARGETS="$TARGETS $FOUND_TARGET"
    +            else
    +              echo "[LOG] -> Notice: No direct unit test target found for $FILE."
    +            fi
    +          fi
    +        done
    +
    +        # Remove duplicate targets
    +        TARGETS=$(echo "$TARGETS" | xargs -n1 | sort -u | xargs || true)
    +        echo "[LOG] Executing Ninja targets: $TARGETS"
    +
    +        if [ -n "$TARGETS" ]; then
    +          export LLVM_PROFILE_FILE="libc_cov_%p.profraw"
    +          ninja -C build-cov $TARGETS
    +          echo "TARGETS=$TARGETS" >> $GITHUB_ENV
    +        else
    +          echo "[LOG] No standalone unit test targets to run."
    +          echo "TARGETS=" >> $GITHUB_ENV
    +
    +          echo "## LLVM-libc Patch Coverage Report" > coverage_report.md
    +          echo "" >> coverage_report.md
    +          echo "- **Base Branch:** [\`${BASE_REF}\` (${BASE_SHA:0:7})](https://github.com/${BASE_REPO}/commit/${BASE_SHA})" >> coverage_report.md
    +          echo "- **Head Commit:** [\`${HEAD_REF}\` (${HEAD_SHA:0:7})](https://github.com/${HEAD_REPO}/commit/${HEAD_SHA})" >> coverage_report.md
    +          echo "---" >> coverage_report.md
    +          echo "" >> coverage_report.md
    +          echo "**Coverage Validated**" >> coverage_report.md
    +          echo "Modified files do not have standalone unit test targets." >> coverage_report.md
    +
    +          cat coverage_report.md >> $GITHUB_STEP_SUMMARY
    +        fi
    +
    +        END_TIME=$(date +%s)
    +        echo "=== [STAGE 2/4] Targeted Tests Completed in $((END_TIME - START_TIME))s ==="
    +
    +    - name: Merge Profiles
    +      if: env.TARGETS != ''
    +      run: |
    +        echo "=== [STAGE 3/4] Merging Raw Profiles at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +        find . -name "libc_cov_*.profraw" > profraw_list.txt
    +        NUM_PROFS=$(wc -l < profraw_list.txt || echo 0)
    +        echo "[LOG] Discovered $NUM_PROFS raw profile data files."
    +        if [ -s profraw_list.txt ]; then
    +          llvm-profdata-23 merge -sparse --input-files=profraw_list.txt -o libc_full.profdata
    +          echo "[LOG] Successfully merged profile data into libc_full.profdata."
    +        else
    +          echo "[LOG] Warning: No profraw files found."
    +        fi
    +
    +    - name: Extract Executables and Generate Summary
    +      if: env.TARGETS != ''
    +      run: |
    +        echo "=== [STAGE 4/4] Generating Coverage Report at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +        EXECUTABLES=($(find build-cov -type f -executable -name "*__build__"))
    +        OBJECTS=("${EXECUTABLES[@]:1}")
    +        OBJECTS=("${OBJECTS[@]/#/-object=}")
    +        
    +        echo "[LOG] Discovered ${#EXECUTABLES[@]} instrumented binaries for llvm-cov export."
    +
    +        if [ ! -f libc_full.profdata ]; then
    +          echo "[LOG] Notice: libc_full.profdata not found. Generating non-coverage summary."
    +          echo "## LLVM-libc Patch Coverage Report" > coverage_report.md
    +          echo "" >> coverage_report.md
    +          echo "- **Base Branch:** [\`${BASE_REF}\` (${BASE_SHA:0:7})](https://github.com/${BASE_REPO}/commit/${BASE_SHA})" >> coverage_report.md
    +          echo "- **Head Commit:** [\`${HEAD_REF}\` (${HEAD_SHA:0:7})](https://github.com/${HEAD_REPO}/commit/${HEAD_SHA})" >> coverage_report.md
    +          echo "---" >> coverage_report.md
    +          echo "" >> coverage_report.md
    +          echo "**Coverage Validated**" >> coverage_report.md
    +          echo "No executable statement profile data was collected for the modified lines in this patch." >> coverage_report.md
    +          cat coverage_report.md >> $GITHUB_STEP_SUMMARY
    +          exit 0
    +        fi
    +
    +        # 1. Generate JSON report for Python script
    +        llvm-cov-23 export -format=text -instr-profile=libc_full.profdata "${EXECUTABLES[0]}" "${OBJECTS[@]}" > coverage.json
    +
    +        # 2. Generate git diff for modified libc source files
    +        git diff "$DIFF_BASE" HEAD -- libc/src/ > patch.diff
    +
    +        # 3. Run Diff Coverage Python Script using persisted commit metadata
    +        PYTHONPATH="libc/utils/coverage" python3 libc/utils/coverage/diff_coverage.py patch.diff coverage.json "$BASE_SHA" "$HEAD_SHA" "$BASE_REF" "$HEAD_REF" "$TARGETS" "$BASE_REPO" "$HEAD_REPO" > coverage_report.md
    +        cat coverage_report.md >> $GITHUB_STEP_SUMMARY
    +        echo "[LOG] Coverage report successfully written to GITHUB_STEP_SUMMARY."
    +
    +    - name: Fallback Failure Summary
    +      if: failure() && !hashFiles('coverage_report.md')
    +      run: |
    +        echo "## LLVM-libc Patch Coverage Report" > coverage_report.md
    +        echo "" >> coverage_report.md
    +        echo "- **Base Branch:** [\`${BASE_REF:-main}\` (${BASE_SHA:0:7})](https://github.com/${BASE_REPO:-llvm/llvm-project}/commit/${BASE_SHA:-main})" >> coverage_report.md
    +        echo "- **Head Commit:** [\`${HEAD_REF:-HEAD}\` (${HEAD_SHA:0:7})](https://github.com/${HEAD_REPO:-llvm/llvm-project}/commit/${HEAD_SHA:-HEAD})" >> coverage_report.md
    +        echo "---" >> coverage_report.md
    +        echo "" >> coverage_report.md
    +        echo "**Coverage Validated**" >> coverage_report.md
    +        echo "The targeted build or test execution encountered an error before coverage data could be finalized. Inspect the job logs for details." >> coverage_report.md
    +
    +        cat coverage_report.md >> $GITHUB_STEP_SUMMARY
    +
    +    - name: Post or Update Sticky PR Comment
    +      if: always() && github.event_name == 'pull_request'
    +      uses: actions/github-script@v7

    zizmor /

    unpinned action reference: action is not pinned to a hash (required by blanket policy)

    Show more details

    github-advanced-security[bot] github-advanced-security[bot] commented on code on Sep 03, 2026 10:11 UTC
    Code Review
    .github/workflows/libc-patch-mcdc.yml:1
    @@ -0,0 +1,370 @@
    +name: Libc Patch MC/DC Coverage
    +
    +permissions:
    +  contents: read
    +  pull-requests: write # Required to post/update patch coverage comments
    +
    +env:
    +  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
    +
    +on:
    +  workflow_dispatch:
    +  push:
    +    branches:
    +      - 'test-*'
    +      - 'libc-mcdc-*'
    +      - main
    +    paths:
    +      - 'libc/src/**'
    +      - 'libc/include/**'
    +      - 'libc/test/**'
    +      - 'libc/CMakeLists.txt'
    +      - '.github/workflows/libc-patch-mcdc.yml'
    +      - '!libc/docs/**'
    +      - '!libc/benchmarks/**'
    +      - '!libc/fuzzing/**'
    +      - '!libc/utils/**'
    +      - '!**.md'
    +  pull_request:
    +    paths:
    +      - 'libc/src/**'
    +      - 'libc/include/**'
    +      - 'libc/test/**'
    +      - 'libc/CMakeLists.txt'
    +      - '.github/workflows/libc-patch-mcdc.yml'
    +      - '!libc/docs/**'
    +      - '!libc/benchmarks/**'
    +      - '!libc/fuzzing/**'
    +      - '!libc/utils/**'
    +      - '!**.md'
    +
    +concurrency:
    +  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
    +  cancel-in-progress: true
    +
    +jobs:
    +  pre-commit-mcdc-coverage:
    +    timeout-minutes: 60
    +    name: libc-pre-commit-mcdc-coverage
    +    runs-on: ubuntu-24.04
    +    container:
    +      image: ghcr.io/llvm/libc-ubuntu-24.04:latest@sha256:8fee4c9ce5a1fd095686593cd36e032c48a31b6ae575378c82accd1d86a08d59
    +      options: >-
    +        --privileged
    +    defaults:
    +      run:
    +        shell: bash
    +    steps:
    +    - name: Checkout Code
    +      uses: actions/checkout@v4

    zizmor /

    unpinned action reference: action is not pinned to a hash (required by blanket policy)

    Show more details

    github-advanced-security[bot] github-advanced-security[bot] commented on code on Sep 03, 2026 10:11 UTC
    Code Review
    .github/workflows/libc-patch-mcdc.yml:1
    @@ -0,0 +1,370 @@
    +name: Libc Patch MC/DC Coverage
    +
    +permissions:
    +  contents: read
    +  pull-requests: write # Required to post/update patch coverage comments
    +
    +env:
    +  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
    +
    +on:
    +  workflow_dispatch:
    +  push:
    +    branches:
    +      - 'test-*'
    +      - 'libc-mcdc-*'
    +      - main
    +    paths:
    +      - 'libc/src/**'
    +      - 'libc/include/**'
    +      - 'libc/test/**'
    +      - 'libc/CMakeLists.txt'
    +      - '.github/workflows/libc-patch-mcdc.yml'
    +      - '!libc/docs/**'
    +      - '!libc/benchmarks/**'
    +      - '!libc/fuzzing/**'
    +      - '!libc/utils/**'
    +      - '!**.md'
    +  pull_request:
    +    paths:
    +      - 'libc/src/**'
    +      - 'libc/include/**'
    +      - 'libc/test/**'
    +      - 'libc/CMakeLists.txt'
    +      - '.github/workflows/libc-patch-mcdc.yml'
    +      - '!libc/docs/**'
    +      - '!libc/benchmarks/**'
    +      - '!libc/fuzzing/**'
    +      - '!libc/utils/**'
    +      - '!**.md'
    +
    +concurrency:
    +  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
    +  cancel-in-progress: true
    +
    +jobs:
    +  pre-commit-mcdc-coverage:
    +    timeout-minutes: 60
    +    name: libc-pre-commit-mcdc-coverage
    +    runs-on: ubuntu-24.04
    +    container:
    +      image: ghcr.io/llvm/libc-ubuntu-24.04:latest@sha256:8fee4c9ce5a1fd095686593cd36e032c48a31b6ae575378c82accd1d86a08d59
    +      options: >-
    +        --privileged
    +    defaults:
    +      run:
    +        shell: bash
    +    steps:
    +    - name: Checkout Code
    +      uses: actions/checkout@v4
    +      with:
    +        ref: ${{ github.event.pull_request.head.sha || github.sha }}
    +        fetch-depth: 2
    +        persist-credentials: false
    +
    +    - name: Setup Compiler Cache (sccache)
    +      uses: hendrikmuhs/ccache-action@v1.2.23

    zizmor /

    unpinned action reference: action is not pinned to a hash (required by blanket policy)

    Show more details

    github-advanced-security[bot] github-advanced-security[bot] commented on code on Sep 03, 2026 10:11 UTC
    Code Review
    .github/workflows/libc-patch-mcdc.yml:1
    @@ -0,0 +1,370 @@
    +name: Libc Patch MC/DC Coverage
    +
    +permissions:
    +  contents: read
    +  pull-requests: write # Required to post/update patch coverage comments
    +
    +env:
    +  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
    +
    +on:
    +  workflow_dispatch:
    +  push:
    +    branches:
    +      - 'test-*'
    +      - 'libc-mcdc-*'
    +      - main
    +    paths:
    +      - 'libc/src/**'
    +      - 'libc/include/**'
    +      - 'libc/test/**'
    +      - 'libc/CMakeLists.txt'
    +      - '.github/workflows/libc-patch-mcdc.yml'
    +      - '!libc/docs/**'
    +      - '!libc/benchmarks/**'
    +      - '!libc/fuzzing/**'
    +      - '!libc/utils/**'
    +      - '!**.md'
    +  pull_request:
    +    paths:
    +      - 'libc/src/**'
    +      - 'libc/include/**'
    +      - 'libc/test/**'
    +      - 'libc/CMakeLists.txt'
    +      - '.github/workflows/libc-patch-mcdc.yml'
    +      - '!libc/docs/**'
    +      - '!libc/benchmarks/**'
    +      - '!libc/fuzzing/**'
    +      - '!libc/utils/**'
    +      - '!**.md'
    +
    +concurrency:
    +  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
    +  cancel-in-progress: true
    +
    +jobs:
    +  pre-commit-mcdc-coverage:
    +    timeout-minutes: 60
    +    name: libc-pre-commit-mcdc-coverage
    +    runs-on: ubuntu-24.04
    +    container:
    +      image: ghcr.io/llvm/libc-ubuntu-24.04:latest@sha256:8fee4c9ce5a1fd095686593cd36e032c48a31b6ae575378c82accd1d86a08d59
    +      options: >-
    +        --privileged
    +    defaults:
    +      run:
    +        shell: bash
    +    steps:
    +    - name: Checkout Code
    +      uses: actions/checkout@v4
    +      with:
    +        ref: ${{ github.event.pull_request.head.sha || github.sha }}
    +        fetch-depth: 2
    +        persist-credentials: false
    +
    +    - name: Setup Compiler Cache (sccache)
    +      uses: hendrikmuhs/ccache-action@v1.2.23
    +      with:
    +        max-size: 1G
    +        key: libc_coverage_unified_v2_x86_64
    +        variant: sccache
    +
    +    - name: Configure CMake
    +      run: |
    +        echo "=== [STAGE 1/4] Starting CMake Configuration at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +        START_TIME=$(date +%s)
    +
    +        export CMAKE_FLAGS="
    +          -G Ninja
    +          -S runtimes
    +          -B build-cov
    +          -DCMAKE_C_COMPILER=clang-23
    +          -DCMAKE_CXX_COMPILER=clang++-23
    +          -DCMAKE_BUILD_TYPE=Debug
    +          -DCMAKE_C_COMPILER_LAUNCHER=sccache
    +          -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
    +          -DLLVM_USE_LINKER=lld-23
    +          -DLLVM_ENABLE_RUNTIMES=libc
    +          -DLLVM_LIBC_FULL_BUILD=ON
    +          -DLIBC_ENABLE_COVERAGE=ON
    +          -DLIBC_ENABLE_MCDC=ON
    +          -DLIBC_TEST_UNIT_TEST_ONLY=ON
    +          -DLIBC_TEST_SKIP_DEATH_TESTS=ON
    +          -DLIBC_TEST_SKIP_SHARED_TESTS=ON
    +        "
    +        cmake $CMAKE_FLAGS
    +
    +        END_TIME=$(date +%s)
    +        echo "=== [STAGE 1/4] CMake Configuration Completed in $((END_TIME - START_TIME))s ==="
    +
    +    - name: Build and Run Targeted Tests
    +      env:
    +        EVENT_NAME: ${{ github.event_name }}
    +        PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
    +        PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
    +        PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
    +        PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
    +        PR_BASE_REPO: ${{ github.event.pull_request.base.repo.full_name }}
    +        PR_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
    +        COMMIT_SHA: ${{ github.sha }}
    +        BRANCH_REF: ${{ github.ref_name }}
    +        REPO_NAME: ${{ github.repository }}
    +      run: |
    +        echo "=== [STAGE 2/4] Starting Targeted Test Discovery at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +        START_TIME=$(date +%s)
    +
    +        # Ensure upstream llvm-project remote is configured
    +        git remote add upstream https://github.com/llvm/llvm-project.git 2>/dev/null || true
    +
    +        # 1. Deterministically resolve Base and Head references against upstream llvm-project
    +        if [ "$EVENT_NAME" == "pull_request" ]; then
    +          BASE_SHA="$PR_BASE_SHA"
    +          HEAD_SHA="$PR_HEAD_SHA"
    +          BASE_REF="$PR_BASE_REF"
    +          HEAD_REF="$PR_HEAD_REF"
    +          BASE_REPO="${PR_BASE_REPO:-llvm/llvm-project}"
    +          HEAD_REPO="${PR_HEAD_REPO:-$REPO_NAME}"
    +          git fetch upstream "$BASE_SHA" --depth=1 2>/dev/null || git fetch origin "$BASE_SHA" --depth=1 2>/dev/null || git fetch origin "$BASE_REF" --depth=1 2>/dev/null || true
    +          DIFF_BASE="$BASE_SHA"
    +        elif [ "$BRANCH_REF" != "main" ]; then
    +          # For feature branches, compare against main merge-base
    +          git fetch origin main --depth=100 2>/dev/null || true
    +          BASE_SHA=$(git merge-base origin/main HEAD 2>/dev/null || git rev-parse HEAD~1 2>/dev/null || echo "HEAD~1")
    +          HEAD_SHA="$COMMIT_SHA"
    +          BASE_REF="main"
    +          HEAD_REF="$BRANCH_REF"
    +          BASE_REPO="llvm/llvm-project"
    +          HEAD_REPO="$REPO_NAME"
    +          DIFF_BASE="$BASE_SHA"
    +        else
    +          BASE_SHA=$(git rev-parse HEAD~1 2>/dev/null || echo "HEAD~1")
    +          HEAD_SHA="$COMMIT_SHA"
    +          BASE_REF="main"
    +          HEAD_REF="$BRANCH_REF"
    +          BASE_REPO="llvm/llvm-project"
    +          HEAD_REPO="$REPO_NAME"
    +          DIFF_BASE="HEAD~1"
    +        fi
    +
    +        # Persist resolved commit references for all downstream steps
    +        echo "DIFF_BASE=$DIFF_BASE" >> $GITHUB_ENV
    +        echo "BASE_SHA=$BASE_SHA" >> $GITHUB_ENV
    +        echo "HEAD_SHA=$HEAD_SHA" >> $GITHUB_ENV
    +        echo "BASE_REF=$BASE_REF" >> $GITHUB_ENV
    +        echo "HEAD_REF=$HEAD_REF" >> $GITHUB_ENV
    +        echo "BASE_REPO=$BASE_REPO" >> $GITHUB_ENV
    +        echo "HEAD_REPO=$HEAD_REPO" >> $GITHUB_ENV
    +
    +        echo "[LOG] Resolved Base: ${BASE_REF} (${BASE_SHA:0:7}) in ${BASE_REPO}"
    +        echo "[LOG] Resolved Head: ${HEAD_REF} (${HEAD_SHA:0:7}) in ${HEAD_REPO}"
    +
    +        MODIFIED_FILES=$(git diff --name-only "$DIFF_BASE" HEAD -- libc/src/ || true)
    +        echo "[LOG] Modified files in libc/src/:"
    +        echo "$MODIFIED_FILES"
    +
    +        if [ -z "$MODIFIED_FILES" ]; then
    +          echo "[LOG] No source files modified in libc/src/. Exiting successfully."
    +          echo "TARGETS=" >> $GITHUB_ENV
    +
    +          echo "## LLVM-libc Patch Coverage Report" > coverage_report.md
    +          echo "" >> coverage_report.md
    +          echo "- **Base Branch:** [\`${BASE_REF}\` (${BASE_SHA:0:7})](https://github.com/${BASE_REPO}/commit/${BASE_SHA})" >> coverage_report.md
    +          echo "- **Head Commit:** [\`${HEAD_REF}\` (${HEAD_SHA:0:7})](https://github.com/${HEAD_REPO}/commit/${HEAD_SHA})" >> coverage_report.md
    +          echo "---" >> coverage_report.md
    +          echo "" >> coverage_report.md
    +          echo "**Coverage Validated**" >> coverage_report.md
    +          echo "No \`.cpp\` source files in \`libc/src/\` were modified in this patch." >> coverage_report.md
    +
    +          cat coverage_report.md >> $GITHUB_STEP_SUMMARY
    +          exit 0
    +        fi
    +
    +        # Get all valid ninja targets
    +        ninja -C build-cov -t targets > all_targets.txt
    +
    +        TARGETS=""
    +
    +        for FILE in $MODIFIED_FILES; do
    +          # Skip core support files from direct target mapping (tested transitively)
    +          if [[ "$FILE" == *"__support/"* ]]; then
    +            echo "[LOG] -> Support file ($FILE) will be tested transitively."
    +            continue
    +          fi
    +
    +          if [[ "$FILE" =~ ^libc/src/([^/]+)/(.*/)?([^/]+)\.cpp$ ]]; then
    +            DIR="${BASH_REMATCH[1]}"
    +            FUNC="${BASH_REMATCH[3]}"
    +            ALL_MATCHES=$(grep -oE "^libc\.test\.src\.${DIR}\.([a-zA-Z0-9_]+\.)*${FUNC}_test\.__unit__" all_targets.txt || true)
    +            FOUND_TARGET=$(echo "$ALL_MATCHES" | head -n 1 | tr -d '\r\n ' || true)
    +            if [ -n "$FOUND_TARGET" ]; then
    +              echo "[LOG] -> Matched $FILE -> $FOUND_TARGET"
    +              TARGETS="$TARGETS $FOUND_TARGET"
    +            else
    +              echo "[LOG] -> Notice: No direct unit test target found for $FILE."
    +            fi
    +          fi
    +        done
    +
    +        # Remove duplicate targets
    +        TARGETS=$(echo "$TARGETS" | xargs -n1 | sort -u | xargs || true)
    +        echo "[LOG] Executing Ninja targets: $TARGETS"
    +
    +        if [ -n "$TARGETS" ]; then
    +          export LLVM_PROFILE_FILE="libc_cov_%p.profraw"
    +          ninja -C build-cov $TARGETS
    +          echo "TARGETS=$TARGETS" >> $GITHUB_ENV
    +        else
    +          echo "[LOG] No standalone unit test targets to run."
    +          echo "TARGETS=" >> $GITHUB_ENV
    +
    +          echo "## LLVM-libc Patch Coverage Report" > coverage_report.md
    +          echo "" >> coverage_report.md
    +          echo "- **Base Branch:** [\`${BASE_REF}\` (${BASE_SHA:0:7})](https://github.com/${BASE_REPO}/commit/${BASE_SHA})" >> coverage_report.md
    +          echo "- **Head Commit:** [\`${HEAD_REF}\` (${HEAD_SHA:0:7})](https://github.com/${HEAD_REPO}/commit/${HEAD_SHA})" >> coverage_report.md
    +          echo "---" >> coverage_report.md
    +          echo "" >> coverage_report.md
    +          echo "**Coverage Validated**" >> coverage_report.md
    +          echo "Modified files do not have standalone unit test targets." >> coverage_report.md
    +
    +          cat coverage_report.md >> $GITHUB_STEP_SUMMARY
    +        fi
    +
    +        END_TIME=$(date +%s)
    +        echo "=== [STAGE 2/4] Targeted Tests Completed in $((END_TIME - START_TIME))s ==="
    +
    +    - name: Merge Profiles
    +      if: env.TARGETS != ''
    +      run: |
    +        echo "=== [STAGE 3/4] Merging Raw Profiles at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +        find . -name "libc_cov_*.profraw" > profraw_list.txt
    +        NUM_PROFS=$(wc -l < profraw_list.txt || echo 0)
    +        echo "[LOG] Discovered $NUM_PROFS raw profile data files."
    +        if [ -s profraw_list.txt ]; then
    +          llvm-profdata-23 merge -sparse --input-files=profraw_list.txt -o libc_full.profdata
    +          echo "[LOG] Successfully merged profile data into libc_full.profdata."
    +        else
    +          echo "[LOG] Warning: No profraw files found."
    +        fi
    +
    +    - name: Extract Executables and Generate Summary
    +      if: env.TARGETS != ''
    +      run: |
    +        echo "=== [STAGE 4/4] Generating Coverage Report at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +        EXECUTABLES=($(find build-cov -type f -executable -name "*__build__"))
    +        OBJECTS=("${EXECUTABLES[@]:1}")
    +        OBJECTS=("${OBJECTS[@]/#/-object=}")
    +        
    +        echo "[LOG] Discovered ${#EXECUTABLES[@]} instrumented binaries for llvm-cov export."
    +
    +        if [ ! -f libc_full.profdata ]; then
    +          echo "[LOG] Notice: libc_full.profdata not found. Generating non-coverage summary."
    +          echo "## LLVM-libc Patch Coverage Report" > coverage_report.md
    +          echo "" >> coverage_report.md
    +          echo "- **Base Branch:** [\`${BASE_REF}\` (${BASE_SHA:0:7})](https://github.com/${BASE_REPO}/commit/${BASE_SHA})" >> coverage_report.md
    +          echo "- **Head Commit:** [\`${HEAD_REF}\` (${HEAD_SHA:0:7})](https://github.com/${HEAD_REPO}/commit/${HEAD_SHA})" >> coverage_report.md
    +          echo "---" >> coverage_report.md
    +          echo "" >> coverage_report.md
    +          echo "**Coverage Validated**" >> coverage_report.md
    +          echo "No executable statement profile data was collected for the modified lines in this patch." >> coverage_report.md
    +          cat coverage_report.md >> $GITHUB_STEP_SUMMARY
    +          exit 0
    +        fi
    +
    +        # 1. Generate JSON report for Python script
    +        llvm-cov-23 export -format=text -instr-profile=libc_full.profdata "${EXECUTABLES[0]}" "${OBJECTS[@]}" > coverage.json
    +
    +        # 2. Generate git diff for modified libc source files
    +        git diff "$DIFF_BASE" HEAD -- libc/src/ > patch.diff
    +
    +        # 3. Run Diff Coverage Python Script using persisted commit metadata
    +        PYTHONPATH="libc/utils/coverage" python3 libc/utils/coverage/diff_coverage.py patch.diff coverage.json "$BASE_SHA" "$HEAD_SHA" "$BASE_REF" "$HEAD_REF" "$TARGETS" "$BASE_REPO" "$HEAD_REPO" > coverage_report.md
    +        cat coverage_report.md >> $GITHUB_STEP_SUMMARY
    +        echo "[LOG] Coverage report successfully written to GITHUB_STEP_SUMMARY."
    +
    +    - name: Fallback Failure Summary
    +      if: failure() && !hashFiles('coverage_report.md')
    +      run: |
    +        echo "## LLVM-libc Patch Coverage Report" > coverage_report.md
    +        echo "" >> coverage_report.md
    +        echo "- **Base Branch:** [\`${BASE_REF:-main}\` (${BASE_SHA:0:7})](https://github.com/${BASE_REPO:-llvm/llvm-project}/commit/${BASE_SHA:-main})" >> coverage_report.md
    +        echo "- **Head Commit:** [\`${HEAD_REF:-HEAD}\` (${HEAD_SHA:0:7})](https://github.com/${HEAD_REPO:-llvm/llvm-project}/commit/${HEAD_SHA:-HEAD})" >> coverage_report.md
    +        echo "---" >> coverage_report.md
    +        echo "" >> coverage_report.md
    +        echo "**Coverage Validated**" >> coverage_report.md
    +        echo "The targeted build or test execution encountered an error before coverage data could be finalized. Inspect the job logs for details." >> coverage_report.md
    +
    +        cat coverage_report.md >> $GITHUB_STEP_SUMMARY
    +
    +    - name: Post or Update Sticky PR Comment
    +      if: always() && github.event_name == 'pull_request'
    +      uses: actions/github-script@v7

    zizmor /

    unpinned action reference: action is not pinned to a hash (required by blanket policy)

    Show more details

    github-actions[bot] github-actions[bot] commented on Sep 03, 2026 10:11 UTC
    Bot

    <!--LLVM CODE FORMAT COMMENT: {darker}-->

    :white_check_mark: With the latest revision this PR passed the Python code formatter.

    tstellar tstellar commented on code on Sep 03, 2026 16:23 UTC
    Code Review
    .github/workflows/libc-full-coverage.yml:1
    @@ -0,0 +1,149 @@
    +name: Libc Full Codebase Coverage
    +
    +permissions:
    +  contents: read
    +
    +env:
    +  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
    +
    +on:
    +  # Daily overnight run at 02:00 UTC
    +  schedule:
    +    - cron: '0 2 * * *'
    +
    +  # Allow manual on-demand execution from GitHub Actions UI
    +  workflow_dispatch:
    +
    +  # Trigger on pushes to main / libc-coverage-ci-bots / post-commit-bot
    +  push:
    +    branches:
    +      - main
    +      - libc-coverage-ci-bots
    +      - post-commit-bot
    +    paths:
    +      - 'libc/**'
    +      - '.github/workflows/libc-full-coverage.yml'
    +
    +concurrency:
    +  group: ${{ github.workflow }}-${{ github.ref }}
    +  cancel-in-progress: true
    +
    +jobs:
    +  full-coverage:
    +    timeout-minutes: 60
    +    name: libc-full-coverage
    +    runs-on: ubuntu-24.04
    +    container:
    +      image: ghcr.io/llvm/libc-ubuntu-24.04:latest@sha256:8fee4c9ce5a1fd095686593cd36e032c48a31b6ae575378c82accd1d86a08d59
    +      options: --privileged

    Why do you need this --privileged flags?

    tstellar tstellar commented on code on Sep 03, 2026 16:24 UTC
    Code Review
    .github/workflows/libc-full-coverage.yml:1
    @@ -0,0 +1,149 @@
    +name: Libc Full Codebase Coverage
    +
    +permissions:
    +  contents: read
    +
    +env:
    +  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
    +
    +on:
    +  # Daily overnight run at 02:00 UTC
    +  schedule:
    +    - cron: '0 2 * * *'
    +
    +  # Allow manual on-demand execution from GitHub Actions UI
    +  workflow_dispatch:
    +
    +  # Trigger on pushes to main / libc-coverage-ci-bots / post-commit-bot
    +  push:
    +    branches:
    +      - main
    +      - libc-coverage-ci-bots
    +      - post-commit-bot
    +    paths:
    +      - 'libc/**'
    +      - '.github/workflows/libc-full-coverage.yml'
    +
    +concurrency:
    +  group: ${{ github.workflow }}-${{ github.ref }}
    +  cancel-in-progress: true
    +
    +jobs:
    +  full-coverage:
    +    timeout-minutes: 60
    +    name: libc-full-coverage
    +    runs-on: ubuntu-24.04
    +    container:
    +      image: ghcr.io/llvm/libc-ubuntu-24.04:latest@sha256:8fee4c9ce5a1fd095686593cd36e032c48a31b6ae575378c82accd1d86a08d59
    +      options: --privileged
    +    defaults:
    +      run:
    +        shell: bash
    +    steps:
    +    - name: Checkout Code
    +      uses: actions/checkout@v4
    +      with:
    +        fetch-depth: 1
    +        persist-credentials: false
    +
    +    - name: Setup Compiler Cache (sccache)
    +      uses: hendrikmuhs/ccache-action@v1.2.23
    +      with:
    +        max-size: 1G
    +        key: libc_coverage_unified_v2_x86_64
    +        variant: sccache
    +
    +    - name: Configure CMake
    +      run: |
    +        echo "=== [STAGE 1/4] Starting CMake Configuration at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +        START_TIME=$(date +%s)
    +
    +        export CMAKE_FLAGS="
    +          -G Ninja
    +          -S runtimes
    +          -B build-cov
    +          -DCMAKE_C_COMPILER=clang-23
    +          -DCMAKE_CXX_COMPILER=clang++-23
    +          -DCMAKE_BUILD_TYPE=Debug
    +          -DCMAKE_C_COMPILER_LAUNCHER=sccache
    +          -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
    +          -DLLVM_USE_LINKER=lld-23
    +          -DLLVM_ENABLE_RUNTIMES=libc
    +          -DLLVM_LIBC_FULL_BUILD=ON
    +          -DLIBC_ENABLE_COVERAGE=ON
    +          -DLIBC_TEST_UNIT_TEST_ONLY=ON
    +          -DLIBC_TEST_SKIP_DEATH_TESTS=ON
    +          -DLIBC_TEST_SKIP_SHARED_TESTS=ON
    +        "
    +        cmake $CMAKE_FLAGS
    +
    +        END_TIME=$(date +%s)
    +        echo "=== [STAGE 1/4] CMake Configuration Completed in $((END_TIME - START_TIME))s ==="

    Why do you need to track how long this step takes? GtiHub already tracks this.

    tstellar tstellar commented on code on Sep 03, 2026 17:14 UTC
    Code Review
    .github/workflows/libc-full-mcdc.yml:1
    @@ -0,0 +1,145 @@
    +name: Libc Full Codebase MC/DC Coverage
    +
    +permissions:
    +  contents: read
    +
    +env:
    +  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
    +
    +on:
    +  # Daily overnight run at 02:30 UTC (staggered by 30 mins from baseline sweep)
    +  schedule:
    +    - cron: '30 2 * * *'
    +
    +  # Allow manual on-demand execution from GitHub Actions UI ("Run workflow" button)
    +  workflow_dispatch:
    +
    +  # Trigger on pushes to main / libc-mcdc-coverage / post-commit-bot
    +  push:
    +    branches:
    +      - main
    +      - libc-mcdc-coverage
    +      - post-commit-bot

    What are these branches for?

    tstellar tstellar requested changes on Sep 03, 2026 17:14 UTC
    Changes Requested Reviewer

    Requested changes.

    tstellar tstellar commented on Sep 03, 2026 17:17 UTC
    Contributor

    @tapiwagonga Was this patch originally generated using AI or have you only been using AI for the updates?

    tapiwagonga tapiwagonga commented on Sep 03, 2026 17:27 UTC
    Author

    @tapiwagonga Was this patch originally generated using AI or have you only been using AI for the updates?

    The original patch wasn't generated by AI, I wrote the initial implementation myself. I've mainly been using AI as an assistant to help turn around review comments and formatting updates faster, but I review, test, and verify all the changes myself before committing and pushing.

    boomanaiden154 boomanaiden154 commented on Sep 03, 2026 17:35 UTC
    Contributor

    Understood, for a detailed description of the approach, please associate a issue with this pull request. The merged commit message will be associated with the pull request number.

    This is not necessary. There was already an RFC. Please stop writing low-quality comments on PRs and only post when you're confident what you're saying is correct/helpful.

    tapiwagonga tapiwagonga commented on code on Sep 03, 2026 17:43 UTC
    Code Review
    .github/workflows/libc-full-coverage.yml:1
    @@ -0,0 +1,143 @@
    +name: Libc Full Codebase Coverage
    +
    +permissions:
    +  contents: write # Required to publish live HTML dashboard to gh-pages branch
    +
    +env:
    +  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
    +
    +on:
    +  # Daily overnight run at 02:00 UTC
    +  schedule:
    +    - cron: '0 2 * * *'
    +
    +  # Allow manual on-demand execution from GitHub Actions UI
    +  workflow_dispatch:
    +
    +  # Trigger on pushes to main / libc-coverage-ci-bots / post-commit-bot
    +  push:
    +    branches:
    +      - main
    +      - libc-coverage-ci-bots
    +      - post-commit-bot
    +    paths:
    +      - 'libc/**'
    +      - '.github/workflows/libc-full-coverage.yml'
    +
    +concurrency:
    +  group: ${{ github.workflow }}-${{ github.ref }}
    +  cancel-in-progress: true
    +
    +jobs:
    +  full-coverage:
    +    timeout-minutes: 60
    +    name: libc-full-coverage
    +    runs-on: ubuntu-24.04
    +    container:
    +      image: ghcr.io/llvm/libc-ubuntu-24.04:latest@sha256:8fee4c9ce5a1fd095686593cd36e032c48a31b6ae575378c82accd1d86a08d59
    +      options: --privileged
    +    defaults:
    +      run:
    +        shell: bash
    +    steps:
    +    - name: Checkout Code
    +      uses: actions/checkout@v4
    +      with:
    +        fetch-depth: 1
    +        persist-credentials: false
    +
    +    - name: Setup Compiler Cache (sccache)
    +      uses: hendrikmuhs/ccache-action@v1.2.23
    +      with:
    +        max-size: 1G
    +        key: libc_coverage_unified_v2_x86_64
    +        variant: sccache
    +
    +    - name: Configure CMake
    +      run: |
    +        echo "=== [STAGE 1/4] Starting CMake Configuration at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +        START_TIME=$(date +%s)
    +
    +        export CMAKE_FLAGS="
    +          -G Ninja
    +          -S runtimes
    +          -B build-cov
    +          -DCMAKE_C_COMPILER=clang-23
    +          -DCMAKE_CXX_COMPILER=clang++-23
    +          -DCMAKE_BUILD_TYPE=Debug
    +          -DCMAKE_C_COMPILER_LAUNCHER=sccache
    +          -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
    +          -DLLVM_USE_LINKER=lld-23
    +          -DLLVM_ENABLE_RUNTIMES=libc
    +          -DLLVM_LIBC_FULL_BUILD=ON
    +          -DLIBC_ENABLE_COVERAGE=ON
    +          -DLIBC_TEST_UNIT_TEST_ONLY=ON
    +          -DLIBC_TEST_SKIP_DEATH_TESTS=ON
    +          -DLIBC_TEST_SKIP_SHARED_TESTS=ON
    +        "
    +        cmake $CMAKE_FLAGS
    +
    +        END_TIME=$(date +%s)
    +        echo "=== [STAGE 1/4] CMake Configuration Completed in $((END_TIME - START_TIME))s ==="
    +
    +    - name: Run Full Codebase Unit Tests
    +      run: |
    +        echo "=== [STAGE 2/4] Running Full Unit Test Suite at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +        START_TIME=$(date +%s)
    +
    +        export LLVM_PROFILE_FILE="libc_cov_%p.profraw"
    +        ninja -k 0 -C build-cov libc-unit-tests || true
    +
    +        END_TIME=$(date +%s)
    +        echo "=== [STAGE 2/4] libc-unit-tests Completed in $((END_TIME - START_TIME))s ==="
    +
    +    - name: Merge Profiles
    +      run: |
    +        echo "=== [STAGE 3/4] Merging Raw Profiles at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +        find . build-cov -name "libc_cov_*.profraw" > profraw_list.txt
    +        NUM_PROFS=$(wc -l < profraw_list.txt || echo 0)
    +        echo "[LOG] Discovered $NUM_PROFS raw profile data files."
    +        llvm-profdata-23 merge -sparse --input-files=profraw_list.txt -o libc_full.profdata
    +        echo "[LOG] Merged full codebase profile into libc_full.profdata."
    +
    +    - name: Generate Reports and Summary
    +      env:
    +        COMMIT_SHA: ${{ github.sha }}
    +        BRANCH_REF: ${{ github.ref_name }}
    +      run: |
    +        echo "=== [STAGE 4/4] Generating Full Codebase Coverage Reports at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +        EXECUTABLES=($(find build-cov -type f -executable -name "*__build__"))
    +        OBJECTS=("${EXECUTABLES[@]:1}")
    +        OBJECTS=("${OBJECTS[@]/#/-object=}")
    +
    +        echo "[LOG] Exporting coverage data across ${#EXECUTABLES[@]} test binaries."
    +
    +        # 1. Generate JSON export for Full Coverage Analyzer
    +        llvm-cov-23 export -format=text -instr-profile=libc_full.profdata "${EXECUTABLES[0]}" "${OBJECTS[@]}" > coverage.json
    +
    +        # 2. Generate HTML Coverage Report with directory hierarchy and branch tracking
    +        llvm-cov-23 show -format=html \
    +          -output-dir=coverage_html \
    +          -instr-profile=libc_full.profdata \
    +          "${EXECUTABLES[0]}" "${OBJECTS[@]}" \
    +          --show-directory-coverage \
    +          --show-branches=count \
    +          --compilation-dir=. \
    +          --path-equivalence="$GITHUB_WORKSPACE,." \
    +          -ignore-filename-regex=".*(test|utils).*"
    +        touch coverage_html/.nojekyll
    +
    +        # 3. Run Codebase Coverage Analyzer
    +        PYTHONPATH="libc/utils/coverage" python3 libc/utils/coverage/codebase_coverage.py coverage.json "$COMMIT_SHA" "$BRANCH_REF" >> $GITHUB_STEP_SUMMARY
    +        echo "[LOG] Post-commit summary report written to GITHUB_STEP_SUMMARY."
    +
    +    - name: Deploy Coverage Dashboard to GitHub Pages
    +      if: github.repository != 'llvm/llvm-project'

    Hi Aiden, I've removed the GitHub Pages deployment step entirely and replaced it with actions/upload-artifact to upload the report.

    tapiwagonga tapiwagonga commented on code on Sep 03, 2026 17:52 UTC
    Code Review
    .github/workflows/libc-full-coverage.yml:1
    @@ -0,0 +1,149 @@
    +name: Libc Full Codebase Coverage
    +
    +permissions:
    +  contents: read
    +
    +env:
    +  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
    +
    +on:
    +  # Daily overnight run at 02:00 UTC
    +  schedule:
    +    - cron: '0 2 * * *'
    +
    +  # Allow manual on-demand execution from GitHub Actions UI
    +  workflow_dispatch:
    +
    +  # Trigger on pushes to main / libc-coverage-ci-bots / post-commit-bot
    +  push:
    +    branches:
    +      - main
    +      - libc-coverage-ci-bots
    +      - post-commit-bot
    +    paths:
    +      - 'libc/**'
    +      - '.github/workflows/libc-full-coverage.yml'
    +
    +concurrency:
    +  group: ${{ github.workflow }}-${{ github.ref }}
    +  cancel-in-progress: true
    +
    +jobs:
    +  full-coverage:
    +    timeout-minutes: 60
    +    name: libc-full-coverage
    +    runs-on: ubuntu-24.04
    +    container:
    +      image: ghcr.io/llvm/libc-ubuntu-24.04:latest@sha256:8fee4c9ce5a1fd095686593cd36e032c48a31b6ae575378c82accd1d86a08d59
    +      options: --privileged

    The --privileged flag was a leftover from earlier container experiments and wasn't actually needed for these tests. I've removed it.

    tapiwagonga tapiwagonga commented on code on Sep 03, 2026 17:57 UTC
    Code Review
    .github/workflows/libc-full-coverage.yml:1
    @@ -0,0 +1,149 @@
    +name: Libc Full Codebase Coverage
    +
    +permissions:
    +  contents: read
    +
    +env:
    +  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
    +
    +on:
    +  # Daily overnight run at 02:00 UTC
    +  schedule:
    +    - cron: '0 2 * * *'
    +
    +  # Allow manual on-demand execution from GitHub Actions UI
    +  workflow_dispatch:
    +
    +  # Trigger on pushes to main / libc-coverage-ci-bots / post-commit-bot
    +  push:
    +    branches:
    +      - main
    +      - libc-coverage-ci-bots
    +      - post-commit-bot
    +    paths:
    +      - 'libc/**'
    +      - '.github/workflows/libc-full-coverage.yml'
    +
    +concurrency:
    +  group: ${{ github.workflow }}-${{ github.ref }}
    +  cancel-in-progress: true
    +
    +jobs:
    +  full-coverage:
    +    timeout-minutes: 60
    +    name: libc-full-coverage
    +    runs-on: ubuntu-24.04
    +    container:
    +      image: ghcr.io/llvm/libc-ubuntu-24.04:latest@sha256:8fee4c9ce5a1fd095686593cd36e032c48a31b6ae575378c82accd1d86a08d59
    +      options: --privileged
    +    defaults:
    +      run:
    +        shell: bash
    +    steps:
    +    - name: Checkout Code
    +      uses: actions/checkout@v4
    +      with:
    +        fetch-depth: 1
    +        persist-credentials: false
    +
    +    - name: Setup Compiler Cache (sccache)
    +      uses: hendrikmuhs/ccache-action@v1.2.23
    +      with:
    +        max-size: 1G
    +        key: libc_coverage_unified_v2_x86_64
    +        variant: sccache
    +
    +    - name: Configure CMake
    +      run: |
    +        echo "=== [STAGE 1/4] Starting CMake Configuration at $(date -u '+%Y-%m-%d %H:%M:%S UTC') ==="
    +        START_TIME=$(date +%s)
    +
    +        export CMAKE_FLAGS="
    +          -G Ninja
    +          -S runtimes
    +          -B build-cov
    +          -DCMAKE_C_COMPILER=clang-23
    +          -DCMAKE_CXX_COMPILER=clang++-23
    +          -DCMAKE_BUILD_TYPE=Debug
    +          -DCMAKE_C_COMPILER_LAUNCHER=sccache
    +          -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
    +          -DLLVM_USE_LINKER=lld-23
    +          -DLLVM_ENABLE_RUNTIMES=libc
    +          -DLLVM_LIBC_FULL_BUILD=ON
    +          -DLIBC_ENABLE_COVERAGE=ON
    +          -DLIBC_TEST_UNIT_TEST_ONLY=ON
    +          -DLIBC_TEST_SKIP_DEATH_TESTS=ON
    +          -DLIBC_TEST_SKIP_SHARED_TESTS=ON
    +        "
    +        cmake $CMAKE_FLAGS
    +
    +        END_TIME=$(date +%s)
    +        echo "=== [STAGE 1/4] CMake Configuration Completed in $((END_TIME - START_TIME))s ==="

    I originally added that to measure stage timings while benchmarking build performance and caching in local container runs. I've removed it now.

    tapiwagonga tapiwagonga commented on code on Sep 03, 2026 18:01 UTC
    Code Review
    .github/workflows/libc-full-mcdc.yml:1
    @@ -0,0 +1,145 @@
    +name: Libc Full Codebase MC/DC Coverage
    +
    +permissions:
    +  contents: read
    +
    +env:
    +  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
    +
    +on:
    +  # Daily overnight run at 02:30 UTC (staggered by 30 mins from baseline sweep)
    +  schedule:
    +    - cron: '30 2 * * *'
    +
    +  # Allow manual on-demand execution from GitHub Actions UI ("Run workflow" button)
    +  workflow_dispatch:
    +
    +  # Trigger on pushes to main / libc-mcdc-coverage / post-commit-bot
    +  push:
    +    branches:
    +      - main
    +      - libc-mcdc-coverage
    +      - post-commit-bot

    Those were leftover branches used for testing the workflows during development on my fork. I've removed them so the push triggers only target main.

    tstellar tstellar commented on Sep 03, 2026 18:24 UTC
    Reviewer

    Can you explain why this is split into 4 separate workflows instead of just 1 or 2?

    tapiwagonga tapiwagonga commented on Sep 03, 2026 19:06 UTC
    Author

    Can you explain why this is split into 4 separate workflows instead of just 1 or 2?

    The overall idea was to track both standard statement/branch coverage and MC/DC (Modified Condition / Decision Coverage), and to do so across two distinct levels of scope: incrementally on every pull request commit so developers and contributors get immediate visibility into the coverage of their commits directly on their pull requests, and globally across the entire codebase as a recurring baseline.

    To support this, I set up a dedicated bot for each of the four configurations:

  • On-Commit Bots (libc-patch-coverage & libc-patch-mcdc)

  • The first two bots evaluate incoming pull requests on each commit, but they measure fundamentally different levels of verification: libc-patch-coverage tracks whether modified lines and branches were executed, while libc-patch-mcdc evaluates Modified Condition / Decision Coverage to verify that each boolean sub-condition in compound logic independently affects the decision outcome. I separated these into standalone workflows because MC/DC requires dedicated compiler instrumentation (-fcoverage-mcdc), meaning the two analyses cannot share the same instrumented test binaries. Running them independently guarantees failure isolation: if an intricate boolean expression or macro encounters an issue during MC/DC analysis, it will not fail the entire check or prevent the contributor from receiving standard line coverage feedback.

  • Full Codebase Bots (libc-full-coverage & libc-full-mcdc)

  • The remaining two bots measure total coverage across the entire codebase on a recurring schedule rather than evaluating individual pull requests. libc-full-coverage builds the full unit test suite to measure statement and branch coverage across all library entrypoints, while libc-full-mcdc builds the full test suite with -fcoverage-mcdc to measure boolean condition coverage across all decision statements. I separated these into standalone workflows because compiling with and without -fcoverage-mcdc produces different binaries that cannot be combined into a single build. Running them independently keeps the builds separate and allows each workflow to publish its own summary table and HTML artifact without interfering with the other.

    tstellar tstellar commented on code on Sep 04, 2026 23:48 UTC
    Code Review
    .github/workflows/libc-patch-coverage.yml:1
    @@ -0,0 +1,298 @@
    +name: Libc Patch Code Coverage
    +
    +permissions:
    +  contents: read
    +
    +env:
    +  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
    +
    +on:
    +  workflow_dispatch:
    +  push:
    +    branches:
    +      - main
    +    paths:
    +      - 'libc/src/**'
    +      - 'libc/include/**'
    +      - 'libc/test/**'
    +      - 'libc/CMakeLists.txt'
    +      - '.github/workflows/libc-patch-coverage.yml'
    +      - '!libc/docs/**'
    +      - '!libc/benchmarks/**'
    +      - '!libc/fuzzing/**'
    +      - '!libc/utils/**'
    +      - '!**.md'
    +  pull_request:
    +    branches:
    +      - main
    +    paths:
    +      - 'libc/src/**'
    +      - 'libc/include/**'
    +      - 'libc/test/**'
    +      - 'libc/CMakeLists.txt'
    +      - '.github/workflows/libc-patch-coverage.yml'
    +      - '!libc/docs/**'
    +      - '!libc/benchmarks/**'
    +      - '!libc/fuzzing/**'
    +      - '!libc/utils/**'
    +      - '!**.md'
    +
    +concurrency:
    +  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
    +  cancel-in-progress: true
    +
    +jobs:
    +  pre-commit-coverage:
    +    timeout-minutes: 60
    +    name: libc-pre-commit-coverage
    +    runs-on: ubuntu-24.04
    +    container:
    +      image: ghcr.io/llvm/libc-ubuntu-24.04:latest@sha256:8fee4c9ce5a1fd095686593cd36e032c48a31b6ae575378c82accd1d86a08d59
    +    defaults:
    +      run:
    +        shell: bash
    +    steps:
    +    - name: Checkout Code
    +      uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
    +      with:
    +        ref: ${{ github.event.pull_request.head.sha || github.sha }}
    +        fetch-depth: 100
    +        persist-credentials: false
    +
    +    - name: Setup Compiler Cache (sccache)
    +      uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23
    +      with:
    +        max-size: 1G
    +        key: libc_coverage_unified_v2_x86_64
    +        variant: sccache
    +
    +    - name: Configure CMake
    +      run: |
    +        export CMAKE_FLAGS="
    +          -G Ninja
    +          -S runtimes
    +          -B build-cov
    +          -DCMAKE_C_COMPILER=clang-23
    +          -DCMAKE_CXX_COMPILER=clang++-23
    +          -DCMAKE_BUILD_TYPE=Debug
    +          -DCMAKE_C_COMPILER_LAUNCHER=sccache
    +          -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
    +          -DLLVM_USE_LINKER=lld-23
    +          -DLLVM_ENABLE_RUNTIMES=libc
    +          -DLLVM_LIBC_FULL_BUILD=ON
    +          -DLIBC_ENABLE_COVERAGE=ON
    +          -DLIBC_TEST_UNIT_TEST_ONLY=ON
    +          -DLIBC_TEST_SKIP_DEATH_TESTS=ON
    +          -DLIBC_TEST_SKIP_SHARED_TESTS=ON
    +        "
    +        cmake $CMAKE_FLAGS
    +
    +    - name: Build and Run Targeted Tests
    +      env:
    +        EVENT_NAME: ${{ github.event_name }}
    +        PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
    +        PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
    +        PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
    +        PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
    +        PR_BASE_REPO: ${{ github.event.pull_request.base.repo.full_name }}
    +        PR_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
    +        COMMIT_SHA: ${{ github.sha }}
    +        BRANCH_REF: ${{ github.ref_name }}
    +        REPO_NAME: ${{ github.repository }}
    +      run: |
    +        # Ensure upstream llvm-project remote is configured
    +        git remote add upstream https://github.com/llvm/llvm-project.git 2>/dev/null || true
    +
    +        # 1. Deterministically resolve Base and Head references against upstream llvm-project
    +        if [ "$EVENT_NAME" == "pull_request" ]; then
    +          BASE_SHA="$PR_BASE_SHA"
    +          HEAD_SHA="$PR_HEAD_SHA"
    +          BASE_REF="$PR_BASE_REF"
    +          HEAD_REF="$PR_HEAD_REF"
    +          BASE_REPO="${PR_BASE_REPO:-llvm/llvm-project}"
    +          HEAD_REPO="${PR_HEAD_REPO:-$REPO_NAME}"
    +          # Fetch base branch history to resolve merge base
    +          git fetch upstream "$BASE_REF" --depth=100 2>/dev/null || git fetch origin "$BASE_REF" --depth=100 2>/dev/null || git fetch upstream "$BASE_SHA" --depth=1 2>/dev/null || git fetch origin "$BASE_SHA" --depth=1 2>/dev/null || true
    +          DIFF_BASE=$(git merge-base "$BASE_SHA" HEAD 2>/dev/null || true)
    +          if [ -z "$DIFF_BASE" ]; then
    +            git fetch --no-tags --deepen=200 2>/dev/null || true
    +            DIFF_BASE=$(git merge-base "$BASE_SHA" HEAD 2>/dev/null || echo "$BASE_SHA")
    +          fi
    +        elif [ "$BRANCH_REF" != "main" ]; then
    +          # For feature branches, compare against main merge-base
    +          git fetch origin main --depth=100 2>/dev/null || true
    +          BASE_SHA=$(git merge-base origin/main HEAD 2>/dev/null || git rev-parse HEAD~1 2>/dev/null || echo "HEAD~1")
    +          HEAD_SHA="$COMMIT_SHA"
    +          BASE_REF="main"
    +          HEAD_REF="$BRANCH_REF"
    +          BASE_REPO="llvm/llvm-project"
    +          HEAD_REPO="$REPO_NAME"
    +          DIFF_BASE="$BASE_SHA"
    +        else
    +          # For direct pushes, compare the pushed commit against its parent (HEAD~1)
    +          BASE_SHA=$(git rev-parse HEAD~1 2>/dev/null || echo "HEAD~1")
    +          HEAD_SHA="$COMMIT_SHA"
    +          BASE_REF="main"
    +          HEAD_REF="$BRANCH_REF"
    +          BASE_REPO="llvm/llvm-project"
    +          HEAD_REPO="$REPO_NAME"
    +          DIFF_BASE="HEAD~1"
    +        fi
    +
    +        # Persist resolved commit references for all downstream steps
    +        echo "DIFF_BASE=$DIFF_BASE" >> $GITHUB_ENV
    +        echo "BASE_SHA=$BASE_SHA" >> $GITHUB_ENV
    +        echo "HEAD_SHA=$HEAD_SHA" >> $GITHUB_ENV
    +        echo "BASE_REF=$BASE_REF" >> $GITHUB_ENV
    +        echo "HEAD_REF=$HEAD_REF" >> $GITHUB_ENV
    +        echo "BASE_REPO=$BASE_REPO" >> $GITHUB_ENV
    +        echo "HEAD_REPO=$HEAD_REPO" >> $GITHUB_ENV
    +
    +        echo "[LOG] Resolved Base: ${BASE_REF} (${BASE_SHA:0:7}) in ${BASE_REPO}"
    +        echo "[LOG] Resolved Head: ${HEAD_REF} (${HEAD_SHA:0:7}) in ${HEAD_REPO}"
    +
    +        MODIFIED_FILES=$(git diff --name-only "$DIFF_BASE" HEAD -- libc/src/ || true)
    +        echo "[LOG] Modified files in libc/src/:"
    +        echo "$MODIFIED_FILES"
    +
    +        if [ -z "$MODIFIED_FILES" ]; then
    +          echo "[LOG] No source files modified in libc/src/. Exiting successfully."
    +          echo "TARGETS=" >> $GITHUB_ENV
    +
    +          echo "## LLVM-libc Patch Coverage Report" > coverage_report.md
    +          echo "" >> coverage_report.md
    +          echo "- **Base Branch:** [\`${BASE_REF}\` (${BASE_SHA:0:7})](https://github.com/${BASE_REPO}/commit/${BASE_SHA})" >> coverage_report.md
    +          echo "- **Head Commit:** [\`${HEAD_REF}\` (${HEAD_SHA:0:7})](https://github.com/${HEAD_REPO}/commit/${HEAD_SHA})" >> coverage_report.md
    +          echo "---" >> coverage_report.md
    +          echo "" >> coverage_report.md
    +          echo "**Coverage Validated**" >> coverage_report.md
    +          echo "No \`.cpp\` source files in \`libc/src/\` were modified in this patch." >> coverage_report.md
    +
    +          cat coverage_report.md >> $GITHUB_STEP_SUMMARY
    +          exit 0
    +        fi
    +
    +        # Get all valid ninja targets
    +        ninja -C build-cov -t targets > all_targets.txt
    +
    +        TARGETS=""
    +
    +        for FILE in $MODIFIED_FILES; do
    +          # Skip core support files from direct target mapping (tested transitively)
    +          if [[ "$FILE" == *"__support/"* ]]; then
    +            echo "[LOG] -> Support file ($FILE) will be tested transitively."
    +            continue
    +          fi
    +
    +          if [[ "$FILE" =~ ^libc/src/([^/]+)/(.*/)?([^/]+)\.cpp$ ]]; then
    +            DIR="${BASH_REMATCH[1]}"
    +            FUNC="${BASH_REMATCH[3]}"
    +            ALL_MATCHES=$(grep -oE "^libc\.test\.src\.${DIR}\.([a-zA-Z0-9_]+\.)*${FUNC}_test\.__unit__" all_targets.txt || true)
    +            FOUND_TARGET=$(echo "$ALL_MATCHES" | head -n 1 | tr -d '\r\n ' || true)
    +            if [ -n "$FOUND_TARGET" ]; then
    +              echo "[LOG] -> Matched $FILE -> $FOUND_TARGET"
    +              TARGETS="$TARGETS $FOUND_TARGET"
    +            else
    +              echo "[LOG] -> Notice: No direct unit test target found for $FILE."
    +            fi
    +          fi
    +        done
    +
    +        # Remove duplicate targets
    +        TARGETS=$(echo "$TARGETS" | xargs -n1 | sort -u | xargs || true)
    +        echo "[LOG] Executing Ninja targets: $TARGETS"
    +
    +        if [ -n "$TARGETS" ]; then
    +          export LLVM_PROFILE_FILE="libc_cov_%p.profraw"
    +          ninja -C build-cov $TARGETS
    +          echo "TARGETS=$TARGETS" >> $GITHUB_ENV
    +        else
    +          echo "[LOG] No standalone unit test targets to run."
    +          echo "TARGETS=" >> $GITHUB_ENV
    +
    +          echo "## LLVM-libc Patch Coverage Report" > coverage_report.md
    +          echo "" >> coverage_report.md
    +          echo "- **Base Branch:** [\`${BASE_REF}\` (${BASE_SHA:0:7})](https://github.com/${BASE_REPO}/commit/${BASE_SHA})" >> coverage_report.md
    +          echo "- **Head Commit:** [\`${HEAD_REF}\` (${HEAD_SHA:0:7})](https://github.com/${HEAD_REPO}/commit/${HEAD_SHA})" >> coverage_report.md
    +          echo "---" >> coverage_report.md
    +          echo "" >> coverage_report.md
    +          echo "**Coverage Validated**" >> coverage_report.md
    +          echo "Modified files do not have standalone unit test targets." >> coverage_report.md
    +
    +          cat coverage_report.md >> $GITHUB_STEP_SUMMARY
    +        fi
    +
    +    - name: Merge Profiles
    +      if: env.TARGETS != ''
    +      run: |
    +        find . -name "libc_cov_*.profraw" > profraw_list.txt
    +        NUM_PROFS=$(wc -l < profraw_list.txt || echo 0)
    +        echo "[LOG] Discovered $NUM_PROFS raw profile data files."
    +        if [ -s profraw_list.txt ]; then
    +          llvm-profdata-23 merge -sparse --input-files=profraw_list.txt -o libc_full.profdata
    +          echo "[LOG] Successfully merged profile data into libc_full.profdata."
    +        else
    +          echo "[LOG] Warning: No profraw files found."
    +        fi
    +
    +    - name: Extract Executables and Generate Summary
    +      if: env.TARGETS != ''
    +      run: |
    +        EXECUTABLES=($(find build-cov -type f -executable -name "*__build__"))
    +        OBJECTS=("${EXECUTABLES[@]:1}")
    +        OBJECTS=("${OBJECTS[@]/#/-object=}")
    +
    +        echo "[LOG] Discovered ${#EXECUTABLES[@]} instrumented binaries for llvm-cov export."
    +
    +        if [ ! -f libc_full.profdata ] || [ ${#EXECUTABLES[@]} -eq 0 ]; then
    +          echo "[LOG] Notice: Profile data or instrumented executables not found. Generating non-coverage summary."
    +          echo "## LLVM-libc Patch Coverage Report" > coverage_report.md
    +          echo "" >> coverage_report.md
    +          echo "- **Base Branch:** [\`${BASE_REF}\` (${BASE_SHA:0:7})](https://github.com/${BASE_REPO}/commit/${BASE_SHA})" >> coverage_report.md
    +          echo "- **Head Commit:** [\`${HEAD_REF}\` (${HEAD_SHA:0:7})](https://github.com/${HEAD_REPO}/commit/${HEAD_SHA})" >> coverage_report.md
    +          echo "---" >> coverage_report.md
    +          echo "" >> coverage_report.md
    +          echo "**Coverage Validated**" >> coverage_report.md
    +          echo "No executable statement profile data was collected for the modified lines in this patch." >> coverage_report.md
    +          cat coverage_report.md >> $GITHUB_STEP_SUMMARY
    +          exit 0
    +        fi
    +
    +        # 1. Generate JSON report for Python script
    +        llvm-cov-23 export -format=text -instr-profile=libc_full.profdata "${EXECUTABLES[0]}" "${OBJECTS[@]}" > coverage.json
    +
    +        # 2. Generate git diff for modified libc source files
    +        git diff "$DIFF_BASE" HEAD -- libc/src/ > patch.diff
    +
    +        # 3. Run Diff Coverage Python Script using persisted commit metadata
    +        PYTHONPATH="libc/utils/coverage" python3 libc/utils/coverage/diff_coverage.py patch.diff coverage.json "$BASE_SHA" "$HEAD_SHA" "$BASE_REF" "$HEAD_REF" "$TARGETS" "$BASE_REPO" "$HEAD_REPO" > coverage_report.md
    +        cat coverage_report.md >> $GITHUB_STEP_SUMMARY
    +        echo "[LOG] Coverage report successfully written to GITHUB_STEP_SUMMARY."
    +
    +    - name: Fallback Failure Summary
    +      if: failure() && !hashFiles('coverage_report.md')
    +      run: |
    +        echo "## LLVM-libc Patch Coverage Report" > coverage_report.md
    +        echo "" >> coverage_report.md
    +        echo "- **Base Branch:** [\`${BASE_REF:-main}\` (${BASE_SHA:0:7})](https://github.com/${BASE_REPO:-llvm/llvm-project}/commit/${BASE_SHA:-main})" >> coverage_report.md
    +        echo "- **Head Commit:** [\`${HEAD_REF:-HEAD}\` (${HEAD_SHA:0:7})](https://github.com/${HEAD_REPO:-llvm/llvm-project}/commit/${HEAD_SHA:-HEAD})" >> coverage_report.md
    +        echo "---" >> coverage_report.md
    +        echo "" >> coverage_report.md
    +        echo "**Coverage Validated**" >> coverage_report.md
    +        echo "The targeted build or test execution encountered an error before coverage data could be finalized. Inspect the job logs for details." >> coverage_report.md
    +
    +        cat coverage_report.md >> $GITHUB_STEP_SUMMARY
    +
    +
    +    - name: Upload Patch Coverage Artifacts
    +      if: always() && hashFiles('coverage_report.md')
    tstellar tstellar commented on Sep 04, 2026 23:52 UTC
    Contributor

    @tapiwagonga libc-full- files look almost identical. Would it be possible to merged those into one workflow and use a matrix? Same thing for the libc-patch- files. It looks like there is a lot of cut and paste duplication.

    tapiwagonga tapiwagonga commented on Sep 07, 2026 10:35 UTC
    Author

    @tapiwagonga libc-full- files look almost identical. Would it be possible to merged those into one workflow and use a matrix? Same thing for the libc-patch- files. It looks like there is a lot of cut and paste duplication.

    @tstellar I have consolidated both sets of workflows into single matrix pipelines. The libc-full- workflows are now merged into libc-full-coverage.yml, and the libc-patch- workflows into libc-patch-coverage.yml. I used a matrix to parameterise standard branch coverage versus MC/DC. Each workflow uses strategy.matrix.include to define two parallel jobs, one standard and one MC/DC. All the common steps are shared in a single pipeline, while the matrix swaps in the specific CMake options, compiler flags, and llvm-cov report options for each run.

    michaelrj-google michaelrj-google commented on Sep 17, 2026 21:52 UTC
    Contributor

    @tstellar PTAL

    tstellar tstellar commented on code on Sep 17, 2026 23:36 UTC
    Code Review
    .github/workflows/libc-full-coverage.yml:1
    @@ -0,0 +1,175 @@
    +name: Libc Full Codebase Coverage
    +
    +permissions:
    +  contents: read
    +
    +on:
    +  # Daily overnight run at 02:00 UTC
    +  schedule:
    +    - cron: '0 2 * * *'
    +
    +  # Allow manual on-demand execution from GitHub Actions UI
    +  workflow_dispatch:
    +
    +  # Trigger on pushes to main
    +  push:
    +    branches:
    +      - main
    +    paths:
    +      - 'libc/**'
    +      - '.github/workflows/libc-full-coverage.yml'
    +      - '!libc/docs/**'
    +      - '!libc/benchmarks/**'
    +      - '!libc/fuzzing/**'
    +      - '!**.md'
    +
    +concurrency:
    +  group: ${{ github.workflow }}-${{ github.ref }}
    +  cancel-in-progress: true
    +
    +jobs:
    +  full-coverage:
    +    if: github.repository_owner == 'llvm'
    +    timeout-minutes: 60
    +    name: libc-full-coverage (${{ matrix.name }})
    +    runs-on: ubuntu-24.04
    +    container:
    +      image: ghcr.io/llvm/libc-ubuntu-24.04:latest@sha256:8fee4c9ce5a1fd095686593cd36e032c48a31b6ae575378c82accd1d86a08d59
    +    defaults:
    +      run:
    +        shell: bash
    +    strategy:
    +      fail-fast: false
    +      matrix:
    +        include:
    +          - name: Line Coverage
    +            enable_mcdc: "OFF"
    +            llvm_cov_show_flags: ""
    +            sccache_key: libc_full_coverage_x86_64
    +            summary_artifact: libc-coverage-summary
    +            html_artifact: libc-coverage-html
    +            report_title: "LLVM-libc Coverage Report"
    +          - name: MC/DC Coverage
    +            enable_mcdc: "ON"
    +            llvm_cov_show_flags: "--show-mcdc --show-mcdc-summary"
    +            sccache_key: libc_full_mcdc_coverage_x86_64
    +            summary_artifact: libc-mcdc-coverage-summary
    +            html_artifact: libc-mcdc-coverage-html
    +            report_title: "LLVM-libc MC/DC Coverage Report"
    +    steps:
    +    - name: Checkout Code
    +      uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
    +      with:
    +        fetch-depth: 1
    +        persist-credentials: false
    +
    +    - name: Setup Compiler Cache (sccache)
    +      uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23
    +      with:
    +        max-size: 1G
    +        key: ${{ matrix.sccache_key }}
    +        variant: sccache
    +
    +    - name: Configure CMake
    +      run: |
    +        export CMAKE_FLAGS="
    +          -G Ninja
    +          -S runtimes
    +          -B build-cov
    +          -DCMAKE_C_COMPILER=clang-23
    +          -DCMAKE_CXX_COMPILER=clang++-23
    +          -DCMAKE_BUILD_TYPE=Debug
    +          -DCMAKE_C_COMPILER_LAUNCHER=sccache
    +          -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
    +          -DLLVM_USE_LINKER=lld-23
    +          -DLLVM_ENABLE_RUNTIMES=libc
    +          -DLLVM_LIBC_FULL_BUILD=ON
    +          -DLIBC_ENABLE_COVERAGE=ON
    +          -DLIBC_ENABLE_COVERAGE_MCDC=${{ matrix.enable_mcdc }}
    +          -DLIBC_TEST_SKIP_DEATH_TESTS=ON
    +          -DLIBC_TEST_SKIP_SHARED_TESTS=ON
    +        "

    Why use an environment variable here? Can't you just pass this directly to cmake?

    tstellar tstellar commented on code on Sep 17, 2026 23:38 UTC
    Code Review
    .github/workflows/libc-patch-coverage.yml:1
    @@ -0,0 +1,345 @@
    +name: Libc Patch Coverage
    +
    +permissions:
    +  contents: read
    +
    +on:
    +  workflow_dispatch:
    +  push:
    +    branches:
    +      - main
    +    paths:
    +      - 'libc/**'
    +      - '.github/workflows/libc-patch-coverage.yml'
    +      - '!libc/docs/**'
    +      - '!libc/benchmarks/**'
    +      - '!libc/fuzzing/**'
    +      - '!**.md'
    +  pull_request:
    +    branches:
    +      - main
    +    paths:
    +      - 'libc/**'
    +      - '.github/workflows/libc-patch-coverage.yml'
    +      - '!libc/docs/**'
    +      - '!libc/benchmarks/**'
    +      - '!libc/fuzzing/**'
    +      - '!**.md'
    +
    +concurrency:
    +  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
    +  cancel-in-progress: true
    +
    +jobs:
    +  pre-commit-coverage:
    +    if: github.repository_owner == 'llvm'
    +    timeout-minutes: 60
    +    name: libc-patch-coverage (${{ matrix.name }})
    +    runs-on: ubuntu-24.04
    +    container:
    +      image: ghcr.io/llvm/libc-ubuntu-24.04:latest@sha256:8fee4c9ce5a1fd095686593cd36e032c48a31b6ae575378c82accd1d86a08d59
    +    defaults:
    +      run:
    +        shell: bash
    +    strategy:
    +      fail-fast: false
    +      matrix:
    +        include:
    +          - name: Line Coverage
    +            enable_mcdc: "OFF"
    +            sccache_key: libc_patch_coverage_x86_64
    +            artifact_name: libc-patch-coverage-report
    +            report_title: "LLVM-libc Patch Coverage Report"
    +          - name: MC/DC Coverage
    +            enable_mcdc: "ON"
    +            sccache_key: libc_patch_mcdc_coverage_x86_64
    +            artifact_name: libc-patch-mcdc-coverage-report
    +            report_title: "LLVM-libc Patch MC/DC Coverage Report"
    +    steps:
    +    - name: Checkout Code
    +      uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
    +      with:
    +        ref: ${{ github.event.pull_request.head.sha || github.sha }}
    +        fetch-depth: 100
    +        persist-credentials: false
    +
    +    - name: Setup Compiler Cache (sccache)
    +      uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23
    +      with:
    +        max-size: 1G
    +        key: ${{ matrix.sccache_key }}
    +        variant: sccache
    +
    +    - name: Configure CMake
    +      run: |
    +        export CMAKE_FLAGS="
    +          -G Ninja
    +          -S runtimes
    +          -B build-cov
    +          -DCMAKE_C_COMPILER=clang-23
    +          -DCMAKE_CXX_COMPILER=clang++-23
    +          -DCMAKE_BUILD_TYPE=Debug
    +          -DCMAKE_C_COMPILER_LAUNCHER=sccache
    +          -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
    +          -DLLVM_USE_LINKER=lld-23
    +          -DLLVM_ENABLE_RUNTIMES=libc
    +          -DLLVM_LIBC_FULL_BUILD=ON
    +          -DLIBC_ENABLE_COVERAGE=ON
    +          -DLIBC_ENABLE_COVERAGE_MCDC=${{ matrix.enable_mcdc }}
    +          -DLIBC_TEST_SKIP_DEATH_TESTS=ON
    +          -DLIBC_TEST_SKIP_SHARED_TESTS=ON
    +        "
    +        cmake $CMAKE_FLAGS

    Same question here.

    tstellar tstellar commented on code on Sep 17, 2026 23:46 UTC
    Code Review
    .github/workflows/libc-patch-coverage.yml:1
    @@ -0,0 +1,345 @@
    +name: Libc Patch Coverage
    +
    +permissions:
    +  contents: read
    +
    +on:
    +  workflow_dispatch:
    +  push:
    +    branches:
    +      - main
    +    paths:
    +      - 'libc/**'
    +      - '.github/workflows/libc-patch-coverage.yml'
    +      - '!libc/docs/**'
    +      - '!libc/benchmarks/**'
    +      - '!libc/fuzzing/**'
    +      - '!**.md'
    +  pull_request:
    +    branches:
    +      - main
    +    paths:
    +      - 'libc/**'
    +      - '.github/workflows/libc-patch-coverage.yml'
    +      - '!libc/docs/**'
    +      - '!libc/benchmarks/**'
    +      - '!libc/fuzzing/**'
    +      - '!**.md'
    +
    +concurrency:
    +  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
    +  cancel-in-progress: true
    +
    +jobs:
    +  pre-commit-coverage:
    +    if: github.repository_owner == 'llvm'
    +    timeout-minutes: 60
    +    name: libc-patch-coverage (${{ matrix.name }})
    +    runs-on: ubuntu-24.04
    +    container:
    +      image: ghcr.io/llvm/libc-ubuntu-24.04:latest@sha256:8fee4c9ce5a1fd095686593cd36e032c48a31b6ae575378c82accd1d86a08d59
    +    defaults:
    +      run:
    +        shell: bash
    +    strategy:
    +      fail-fast: false
    +      matrix:
    +        include:
    +          - name: Line Coverage
    +            enable_mcdc: "OFF"
    +            sccache_key: libc_patch_coverage_x86_64
    +            artifact_name: libc-patch-coverage-report
    +            report_title: "LLVM-libc Patch Coverage Report"
    +          - name: MC/DC Coverage
    +            enable_mcdc: "ON"
    +            sccache_key: libc_patch_mcdc_coverage_x86_64
    +            artifact_name: libc-patch-mcdc-coverage-report
    +            report_title: "LLVM-libc Patch MC/DC Coverage Report"
    +    steps:
    +    - name: Checkout Code
    +      uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
    +      with:
    +        ref: ${{ github.event.pull_request.head.sha || github.sha }}
    +        fetch-depth: 100
    +        persist-credentials: false
    +
    +    - name: Setup Compiler Cache (sccache)
    +      uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23
    +      with:
    +        max-size: 1G
    +        key: ${{ matrix.sccache_key }}
    +        variant: sccache
    +
    +    - name: Configure CMake
    +      run: |
    +        export CMAKE_FLAGS="
    +          -G Ninja
    +          -S runtimes
    +          -B build-cov
    +          -DCMAKE_C_COMPILER=clang-23
    +          -DCMAKE_CXX_COMPILER=clang++-23
    +          -DCMAKE_BUILD_TYPE=Debug
    +          -DCMAKE_C_COMPILER_LAUNCHER=sccache
    +          -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
    +          -DLLVM_USE_LINKER=lld-23
    +          -DLLVM_ENABLE_RUNTIMES=libc
    +          -DLLVM_LIBC_FULL_BUILD=ON
    +          -DLIBC_ENABLE_COVERAGE=ON
    +          -DLIBC_ENABLE_COVERAGE_MCDC=${{ matrix.enable_mcdc }}
    +          -DLIBC_TEST_SKIP_DEATH_TESTS=ON
    +          -DLIBC_TEST_SKIP_SHARED_TESTS=ON
    +        "
    +        cmake $CMAKE_FLAGS
    +
    +    - name: Build and Run Targeted Tests
    +      env:
    +        EVENT_NAME: ${{ github.event_name }}
    +        PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
    +        PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
    +        PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
    +        PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
    +        PR_BASE_REPO: ${{ github.event.pull_request.base.repo.full_name }}
    +        PR_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
    +        COMMIT_SHA: ${{ github.sha }}
    +        BRANCH_REF: ${{ github.ref_name }}
    +        REPO_NAME: ${{ github.repository }}
    +      run: |
    +        # Ensure upstream llvm-project remote is configured
    +        git remote add upstream https://github.com/llvm/llvm-project.git 2>/dev/null || true

    Why is this needed?

    tstellar tstellar commented on Sep 17, 2026 23:47 UTC
    Reviewer

    I've tried to review the workflow structure as best as I can. I don't really understand what this is doing and the code is hard for me to follow. You should have someone more familiar with libc take a look at this too.

    Assignees
    tapiwagonga tapiwagonga
    Labels
    risk: low confidence: 89.2% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 58.8% (MEDIUM) · Higher = larger blast radius
    58.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 89.2% · Lower = rushed or shallow review
    89.2%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 6.3% · Safe to merge
    6.3%