diff --git a/.github/workflows/deploy_docs.yml b/.github/workflows/deploy_docs.yml index 0424bd8..671538d 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 @@ -46,7 +48,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 +65,15 @@ jobs: fi - name: Build Sphinx documentation run: bazel build //bazel/rules/rules_score:rules_score_doc + - name: Generate combined coverage report + 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)" @@ -77,6 +88,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 @@ -94,6 +111,41 @@ 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' + continue-on-error: true + 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/bazel/rules/rules_score/docs/index.rst b/bazel/rules/rules_score/docs/index.rst index 46b06d7..e460df4 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 0000000..4041dff --- /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 `_