From adb7b227f82266a285b6445d81ffccaba0199cbe Mon Sep 17 00:00:00 2001 From: komal mahale Date: Wed, 27 May 2026 18:10:08 +0530 Subject: [PATCH 1/3] feat: include combined coverage HTML in docs build and CI --- .github/workflows/deploy_docs.yml | 10 ++++++- .github/workflows/tests.yml | 22 ++++++++++++++ bazel/rules/rules_score/docs/index.rst | 1 + .../rules/rules_score/docs/quality_report.rst | 29 +++++++++++++++++++ 4 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 bazel/rules/rules_score/docs/quality_report.rst diff --git a/.github/workflows/deploy_docs.yml b/.github/workflows/deploy_docs.yml index 0424bd8e..a86e4d2c 100644 --- a/.github/workflows/deploy_docs.yml +++ b/.github/workflows/deploy_docs.yml @@ -46,7 +46,7 @@ jobs: - name: Install system dependencies run: | sudo apt-get update - sudo apt-get install -y pkg-config libcairo2-dev + sudo apt-get install -y pkg-config libcairo2-dev lcov - name: Determine version id: version run: | @@ -63,6 +63,8 @@ jobs: fi - name: Build Sphinx documentation run: bazel build //bazel/rules/rules_score:rules_score_doc + - name: Generate combined coverage report + run: bazel run //coverage:combined_report -- --out-dir coverage-html - name: Prepare documentation output run: | BAZEL_BIN="$(bazel info bazel-bin)" @@ -77,6 +79,12 @@ jobs: cp -r "${HTML_DIR}/." docs_output/ chmod -R u+w docs_output/ + # Embed the combined coverage report at docs_output/coverage/ + if [[ -d coverage-html ]]; then + mkdir -p docs_output/coverage + cp -r coverage-html/. docs_output/coverage/ + fi + # Prevent Jekyll from ignoring _static directories touch docs_output/.nojekyll diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7f33e06a..8904e2d9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -57,3 +57,25 @@ jobs: - name: Ensure correct dependency resolution run: | bazel mod deps --lockfile_mode=update + coverage: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v6.0.2 + - name: Setup Bazel with cache + uses: bazel-contrib/setup-bazel@0.19.0 + with: + disk-cache: true + repository-cache: true + bazelisk-cache: true + - name: Install lcov + run: | + sudo apt-get update + sudo apt-get install -y lcov + - name: Generate combined coverage report + run: bazel run //coverage:combined_report -- --out-dir coverage-html + - name: Upload coverage report artifact + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: coverage-html/ diff --git a/bazel/rules/rules_score/docs/index.rst b/bazel/rules/rules_score/docs/index.rst index 46b06d7d..e460df43 100644 --- a/bazel/rules/rules_score/docs/index.rst +++ b/bazel/rules/rules_score/docs/index.rst @@ -27,3 +27,4 @@ safety analysis to the top-level SEooC assembly. integration_guide user_guide/index rule_reference + quality_report diff --git a/bazel/rules/rules_score/docs/quality_report.rst b/bazel/rules/rules_score/docs/quality_report.rst new file mode 100644 index 00000000..4041dffb --- /dev/null +++ b/bazel/rules/rules_score/docs/quality_report.rst @@ -0,0 +1,29 @@ +.. + # ******************************************************************************* + # Copyright (c) 2026 Contributors to the Eclipse Foundation + # + # See the NOTICE file(s) distributed with this work for additional + # information regarding copyright ownership. + # + # This program and the accompanying materials are made available under the + # terms of the Apache License Version 2.0 which is available at + # https://www.apache.org/licenses/LICENSE-2.0 + # + # SPDX-License-Identifier: Apache-2.0 + # ******************************************************************************* + +Quality Report +============== + +This section provides quality reports generated for the tooling repository. + +Code Coverage +------------- + +The combined Rust + Python HTML coverage report is generated using: + +.. code-block:: bash + + bazel run //coverage:combined_report + +`View Coverage Report `_ From 7f5c4d5dd359797c3fd20d1ed71623d47a9dabff Mon Sep 17 00:00:00 2001 From: komal mahale Date: Thu, 28 May 2026 13:54:55 +0530 Subject: [PATCH 2/3] fix: generate coverage once in deploy_docs, add PR comment with stats --- .github/workflows/deploy_docs.yml | 45 ++++++++++++++++++++++++++++++- .github/workflows/tests.yml | 22 --------------- 2 files changed, 44 insertions(+), 23 deletions(-) diff --git a/.github/workflows/deploy_docs.yml b/.github/workflows/deploy_docs.yml index a86e4d2c..537d85d0 100644 --- a/.github/workflows/deploy_docs.yml +++ b/.github/workflows/deploy_docs.yml @@ -20,12 +20,14 @@ on: branches: [main] paths: - 'bazel/rules/rules_score/docs/**' + - 'coverage/**' - '.github/workflows/deploy_docs.yml' workflow_dispatch: permissions: contents: write # needed for uploading release assets pages: write id-token: write + pull-requests: write # needed for posting PR comments concurrency: group: "pages" cancel-in-progress: false @@ -64,7 +66,14 @@ jobs: - name: Build Sphinx documentation run: bazel build //bazel/rules/rules_score:rules_score_doc - name: Generate combined coverage report - run: bazel run //coverage:combined_report -- --out-dir coverage-html + id: coverage + run: | + COVERAGE_OUTPUT=$(bazel run //coverage:combined_report -- --out-dir coverage-html 2>&1) + echo "${COVERAGE_OUTPUT}" + LINES=$(echo "${COVERAGE_OUTPUT}" | grep -oP 'lines\.+: \K[\d.]+%' | head -1 | tr -d '\n' || echo 'N/A') + FUNCTIONS=$(echo "${COVERAGE_OUTPUT}" | grep -oP 'functions\.+: \K[\d.]+%' | head -1 | tr -d '\n' || echo 'N/A') + echo "lines=${LINES}" >> "$GITHUB_OUTPUT" + echo "functions=${FUNCTIONS}" >> "$GITHUB_OUTPUT" - name: Prepare documentation output run: | BAZEL_BIN="$(bazel info bazel-bin)" @@ -102,6 +111,40 @@ jobs: fi echo "Documentation built successfully" find docs_output -type f | wc -l | xargs -I{} echo "Total files: {}" + - name: Upload coverage report artifact + if: always() + id: upload-coverage + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: coverage-html/ + - name: Post coverage summary to PR + if: github.event_name == 'pull_request' + uses: actions/github-script@v7 + with: + script: | + const lines = '${{ steps.coverage.outputs.lines }}'; + const functions = '${{ steps.coverage.outputs.functions }}'; + const runUrl = `${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}`; + const body = [ + '## Coverage Report', + '', + 'Coverage report was generated.', + '', + `**Full report** can be downloaded from the [CI artifacts](${runUrl}) (expand **Artifacts** at the bottom of the run).`, + '', + '**Overall coverage rate:**', + '```', + `lines......: ${lines}`, + `functions......: ${functions}`, + '```' + ].join('\n'); + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: body + }); - name: Upload docs to release if: startsWith(github.ref, 'refs/tags/v') env: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8904e2d9..7f33e06a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -57,25 +57,3 @@ jobs: - name: Ensure correct dependency resolution run: | bazel mod deps --lockfile_mode=update - coverage: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v6.0.2 - - name: Setup Bazel with cache - uses: bazel-contrib/setup-bazel@0.19.0 - with: - disk-cache: true - repository-cache: true - bazelisk-cache: true - - name: Install lcov - run: | - sudo apt-get update - sudo apt-get install -y lcov - - name: Generate combined coverage report - run: bazel run //coverage:combined_report -- --out-dir coverage-html - - name: Upload coverage report artifact - uses: actions/upload-artifact@v4 - with: - name: coverage-report - path: coverage-html/ From 0692bd34979218ba172595d1f05da1f3085cd7d1 Mon Sep 17 00:00:00 2001 From: komal mahale Date: Thu, 28 May 2026 13:54:55 +0530 Subject: [PATCH 3/3] fix: generate coverage once in deploy_docs, add PR comment with stats --- .github/workflows/deploy_docs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy_docs.yml b/.github/workflows/deploy_docs.yml index 537d85d0..671538dd 100644 --- a/.github/workflows/deploy_docs.yml +++ b/.github/workflows/deploy_docs.yml @@ -120,6 +120,7 @@ jobs: path: coverage-html/ - name: Post coverage summary to PR if: github.event_name == 'pull_request' + continue-on-error: true uses: actions/github-script@v7 with: script: |