-
Notifications
You must be signed in to change notification settings - Fork 24
feat: traceability metrics #484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 25 commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
15743fc
feat(traceability): add coverage checker and reporting docs
FScholPer 58ae80d
add coverage check
FScholPer 4e9c60e
fix lint
FScholPer 0ec5217
refactoring the coverage, metrics and dashboard
FScholPer 764da8d
add generic filters
FScholPer ec2e994
Update src/extensions/score_metamodel/traceability_metrics.py
FScholPer a364257
Apply suggestions from code review
FScholPer ecd1caf
readd genai headers
FScholPer 313ff9b
Merge branch 'main' into score-2774-traceability
FScholPer 6287c69
changed to new json structure
FScholPer 5876e16
Merge branch 'main' into score-2774-traceability
FScholPer b4ec35b
removed md and refactored gate
FScholPer 7ce6835
Added the uml from the comment
FScholPer a6029b7
refactoring to the new json approach and refactoring of dashboards fo…
FScholPer a93233b
lint fix
FScholPer 6e1e0aa
fixed liniting issues
FScholPer 0d8d75c
Merge branch 'main' into score-2774-traceability
FScholPer c8e4058
improved description
FScholPer 4437580
fix warnings
FScholPer 243aa21
fix docs build
FScholPer cf19ba8
fixed review comments(removed coverage py to utilize extension)
FScholPer 2b8aace
review comment fixes
FScholPer f137f03
replaced for loop by list
FScholPer e927339
fix linting
FScholPer a81e4ff
Merge branch 'main' into score-2774-traceability
FScholPer ef1f5ca
review fixes
FScholPer 7745cce
added example
FScholPer 0a1a885
Update docs/reference/commands.md
FScholPer 15d8e91
fix: address PR #484 review comments (dashboards, implementation_stat…
FScholPer 5e49964
Merge origin/main into score-2774-traceability (resolve docs.bzl conf…
FScholPer 56779d3
fix: remove undocumented --fail-on-broken-test-refs flag from docs
FScholPer 5403782
format fix
FScholPer fcde178
Merge branch 'main' into score-2774-traceability
FScholPer 0d9195c
fix: expose traceability_gate target to consumer repos via docs() macro
AlexanderLanin 44dcc74
fix: remove unnecessary pip deps from traceability_gate target
AlexanderLanin cba4fa8
fix: remove fake placeholder URL from plain_links code rendering
AlexanderLanin ec150c8
fix: remove AI disclaimer from .gitignore
AlexanderLanin 85a9d26
fix: remove AI disclaimer from scripts_bazel/BUILD
AlexanderLanin be08bfc
fix: correct debug log guard in _log_existing_links
AlexanderLanin 69254cf
fix: clarify CI quality gate docs — metrics.json comes from any docs …
AlexanderLanin 89d2ff0
fix: correct nonexistent docs_verify reference and clean up wording
AlexanderLanin 18d2c0d
fix: simplify docs command description — hide internal extension name
AlexanderLanin fb202b4
fix: clarify "fully linked" requires implementation in implementation…
AlexanderLanin 2b4e5c4
fix: add missing include_external field to metrics JSON schema
AlexanderLanin 2f65d26
fix: add include_external to gate test fixtures for schema compliance
AlexanderLanin 74ddf9b
fix: add missing known_good parameter to docs() macro table
AlexanderLanin fa04eda
fix: remove AI disclaimer from scripts_bazel/tests/BUILD
AlexanderLanin 389675d
fix: restore placeholder URL in plain_links mode for metamodel valida…
AlexanderLanin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,183 @@ | ||
| .. | ||
| # ******************************************************************************* | ||
| # 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 | ||
| # ******************************************************************************* | ||
|
|
||
| Build Dashboards and Quality Gates | ||
| ================================== | ||
|
|
||
| This guide is for repositories that *consume* docs-as-code as a Bazel | ||
|
FScholPer marked this conversation as resolved.
Outdated
|
||
| dependency. Examples are module repositories and integration repositories that | ||
| want to: | ||
|
|
||
| 1. publish their own traceability dashboards, | ||
| 2. export ``metrics.json`` during documentation builds, and | ||
| 3. enforce quality gates in CI. | ||
|
|
||
| The docs-as-code repository itself documents tooling coverage. Consumer | ||
| repositories use the same extensions to document *their own* requirements, | ||
| architecture, source-code links, and verification evidence. | ||
|
|
||
| What You Get | ||
| ------------ | ||
|
|
||
| When a consumer repository integrates docs-as-code correctly, it can: | ||
|
|
||
| - build an HTML dashboard from its own Sphinx needs, | ||
| - include external needs from other repositories when desired, | ||
| - export ``needs.json`` and ``metrics.json`` for machine-readable reporting, | ||
| - gate CI on traceability thresholds via ``traceability_gate``. | ||
|
|
||
| Typical Setup | ||
|
FScholPer marked this conversation as resolved.
|
||
| ------------- | ||
|
|
||
| 1. Add docs-as-code as a Bazel dependency as described in :ref:`setup`. | ||
| 2. Define the documentation target via the ``docs(...)`` macro. | ||
| 3. Provide process or upstream needs via the ``data`` argument when cross-repo | ||
| traceability is required. | ||
| 4. Provide implementation sources via ``scan_code`` so ``source_code_link`` can | ||
| be generated. | ||
| 5. Add test metadata so ``testlink`` and testcase needs can be generated. | ||
|
|
||
| Minimal Consumer Example | ||
| ------------------------ | ||
|
|
||
| In ``BUILD``: | ||
|
|
||
| .. code-block:: starlark | ||
|
|
||
| load("@score_docs_as_code//:docs.bzl", "docs") | ||
|
|
||
| filegroup( | ||
| name = "module_sources", | ||
| srcs = glob([ | ||
| "src/**/*.py", | ||
| "src/**/*.cpp", | ||
| "src/**/*.h", | ||
| "src/**/*.rs", | ||
| ]), | ||
| ) | ||
|
|
||
| docs( | ||
| source_dir = "docs", | ||
| data = [ | ||
| "@score_process//:needs_json", | ||
| ], | ||
| scan_code = [":module_sources"], | ||
| ) | ||
|
|
||
| In ``docs/conf.py``: | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| score_metamodel_requirement_types = "feat_req,comp_req,aou_req" | ||
|
FScholPer marked this conversation as resolved.
|
||
| score_metamodel_include_external_needs = False | ||
|
FScholPer marked this conversation as resolved.
|
||
|
|
||
| Use ``score_metamodel_include_external_needs = True`` only in repositories that | ||
|
FScholPer marked this conversation as resolved.
|
||
| intentionally aggregate traceability across dependencies, such as integration | ||
| repositories. | ||
|
|
||
| Building the Dashboard | ||
| ---------------------- | ||
|
|
||
| Run: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| bazel run //:docs | ||
|
|
||
| This generates HTML output under ``_build/``. | ||
|
|
||
| Run: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| bazel build //:needs_json | ||
|
|
||
| This generates machine-readable output under: | ||
|
|
||
| - ``bazel-bin/needs_json/_build/needs/needs.json`` | ||
| - ``bazel-bin/needs_json/_build/needs/metrics.json`` | ||
|
FScholPer marked this conversation as resolved.
|
||
|
|
||
| The HTML dashboard and the exported ``metrics.json`` are backed by the same | ||
| traceability metric implementation, so the charts and the CI gate evaluate the | ||
| same data. | ||
|
|
||
| Inputs for Linkage Metrics | ||
| -------------------------- | ||
|
|
||
| To get meaningful dashboard and gate values, consumer repositories typically | ||
| need three inputs: | ||
|
|
||
| 1. Requirement and architecture needs in the documentation itself. | ||
| 2. Source code references via :doc:`source_to_doc_links`. | ||
| 3. Test metadata via :doc:`test_to_doc_links`. | ||
|
|
||
| If one of those inputs is missing, the related chart or gate metric will remain | ||
| empty or low. | ||
|
|
||
| Choosing Local vs Aggregated Views | ||
| ---------------------------------- | ||
|
|
||
| There are two common modes: | ||
|
|
||
| **Module repository** | ||
|
|
||
| - Set ``score_metamodel_include_external_needs = False``. | ||
| - Gate only on the needs owned by the repository itself. | ||
| - Use this for per-module implementation progress and traceability. | ||
|
|
||
| **Integration repository** | ||
|
|
||
| - Set ``score_metamodel_include_external_needs = True``. | ||
| - Aggregate requirements across module dependencies when that is the intended | ||
| repository purpose. | ||
| - Use this for system or integration-level dashboards. | ||
|
|
||
| CI Quality Gate | ||
| --------------- | ||
|
|
||
| After building ``//:needs_json``, run the gate on the exported metrics: | ||
|
FScholPer marked this conversation as resolved.
Outdated
|
||
|
|
||
| .. code-block:: bash | ||
|
|
||
| bazel run @score_docs_as_code//scripts_bazel:traceability_gate -- \ | ||
|
FScholPer marked this conversation as resolved.
Outdated
|
||
| --metrics-json bazel-bin/needs_json/_build/needs/metrics.json \ | ||
|
FScholPer marked this conversation as resolved.
|
||
| --min-req-code 70 \ | ||
| --min-req-test 70 \ | ||
| --min-req-fully-linked 60 \ | ||
| --min-tests-linked 70 | ||
|
|
||
| Useful flags: | ||
|
|
||
| - ``--require-all-links`` for strict 100 percent gating | ||
| - ``--fail-on-broken-test-refs`` to fail when testcase references point to | ||
|
FScholPer marked this conversation as resolved.
Outdated
|
||
| unknown requirement IDs | ||
|
|
||
| Recommended Rollout | ||
| ------------------- | ||
|
|
||
| For a new consumer repository: | ||
|
|
||
| 1. Start with local-only metrics. | ||
| 2. Enable ``scan_code`` and verify ``source_code_link`` coverage first. | ||
| 3. Add test metadata and verify ``testlink`` coverage. | ||
| 4. Introduce modest thresholds in CI. | ||
| 5. Raise thresholds over time as the repository matures. | ||
|
|
||
| Related Guides | ||
| -------------- | ||
|
|
||
| - :ref:`setup` | ||
| - :doc:`other_modules` | ||
| - :doc:`source_to_doc_links` | ||
| - :doc:`test_to_doc_links` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.