|
| 1 | +# ******************************************************************************* |
| 2 | +# Copyright (c) 2026 Contributors to the Eclipse Foundation |
| 3 | +# |
| 4 | +# See the NOTICE file(s) distributed with this work for additional |
| 5 | +# information regarding copyright ownership. |
| 6 | +# |
| 7 | +# This program and the accompanying materials are made available under the |
| 8 | +# terms of the Apache License Version 2.0 which is available at |
| 9 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# SPDX-License-Identifier: Apache-2.0 |
| 12 | +# ******************************************************************************* |
| 13 | +name: Code Coverage |
| 14 | +on: |
| 15 | + pull_request: |
| 16 | + types: [opened, reopened, synchronize] |
| 17 | + push: |
| 18 | + branches: |
| 19 | + - main |
| 20 | + merge_group: |
| 21 | + types: [checks_requested] |
| 22 | + release: |
| 23 | + types: [created] |
| 24 | + |
| 25 | +jobs: |
| 26 | + cpp: |
| 27 | + runs-on: ubuntu-22.04 |
| 28 | + steps: |
| 29 | + - name: Checkout Repository |
| 30 | + uses: actions/checkout@v6 |
| 31 | + |
| 32 | + - name: Install lcov |
| 33 | + run: | |
| 34 | + sudo apt-get update |
| 35 | + sudo apt-get install -y lcov |
| 36 | +
|
| 37 | + - name: Setup Bazel |
| 38 | + uses: bazel-contrib/setup-bazel@0.18.0 |
| 39 | + with: |
| 40 | + bazelisk-cache: true |
| 41 | + disk-cache: ${{ github.job }} |
| 42 | + repository-cache: true |
| 43 | + cache-save: ${{ github.event_name == 'push' }} |
| 44 | + |
| 45 | + - name: Run Bazel Coverage |
| 46 | + run: | |
| 47 | + bazel coverage \ |
| 48 | + --test_output=errors \ |
| 49 | + --nocache_test_results \ |
| 50 | + --config=x86_64-linux \ |
| 51 | + //src/... |
| 52 | +
|
| 53 | + - name: Generate HTML Coverage Report |
| 54 | + shell: bash |
| 55 | + run: | |
| 56 | + genhtml "$(bazel info output_path)/_coverage/_coverage_report.dat" \ |
| 57 | + -o=cpp_coverage \ |
| 58 | + --show-details \ |
| 59 | + --legend \ |
| 60 | + --function-coverage \ |
| 61 | + --branch-coverage |
| 62 | +
|
| 63 | + - name: Upload Coverage Artifacts |
| 64 | + uses: actions/upload-artifact@v6 |
| 65 | + with: |
| 66 | + name: ${{ github.event.repository.name }}_cpp_coverage_report |
| 67 | + path: cpp_coverage/ |
| 68 | + retention-days: 10 |
| 69 | + rust: |
| 70 | + runs-on: ubuntu-latest |
| 71 | + steps: |
| 72 | + - name: Checkout Repository |
| 73 | + uses: actions/checkout@v6 |
| 74 | + |
| 75 | + - name: Setup Bazel |
| 76 | + uses: bazel-contrib/setup-bazel@0.18.0 |
| 77 | + with: |
| 78 | + bazelisk-cache: true |
| 79 | + disk-cache: ${{ github.job }} |
| 80 | + repository-cache: true |
| 81 | + cache-save: ${{ github.event_name == 'push' }} |
| 82 | + |
| 83 | + - name: Run Rust tests with coverage instrumentation |
| 84 | + run: | |
| 85 | + set -euo pipefail |
| 86 | + bazel test \ |
| 87 | + --config=x86_64-linux \ |
| 88 | + --config=ferrocene-coverage \ |
| 89 | + --nocache_test_results \ |
| 90 | + "$(bazel query 'kind(rust_test, //src/...)')" |
| 91 | +
|
| 92 | + - name: Generate Ferrocene coverage reports |
| 93 | + run: | |
| 94 | + set -euo pipefail |
| 95 | + bazel run //:rust_coverage -- --min-line-coverage 66 |
| 96 | +
|
| 97 | + - name: Locate coverage artifacts |
| 98 | + run: | |
| 99 | + echo "COVERAGE_DIR=$(bazel info bazel-bin)/coverage/rust-tests" >> "${GITHUB_ENV}" |
| 100 | +
|
| 101 | + - name: Upload coverage HTML |
| 102 | + uses: actions/upload-artifact@v4 |
| 103 | + with: |
| 104 | + name: ${{ github.event.repository.name }}_rust_coverage_report |
| 105 | + path: ${{ env.COVERAGE_DIR }} |
| 106 | + retention-days: 10 |
0 commit comments