-
Notifications
You must be signed in to change notification settings - Fork 33
docs: describe testing #846
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
+159
β0
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,158 @@ | ||
| .. | ||
| # ******************************************************************************* | ||
| # 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 | ||
| # ******************************************************************************* | ||
|
|
||
| .. _docs_internals_testing: | ||
|
|
||
| Testing | ||
| ======= | ||
|
|
||
| docs-as-code verifies itself on several layers. | ||
| The following sections describe each testing method, | ||
| what it is used for, | ||
| and how to run it. | ||
|
|
||
| Development checks (pre-commit) | ||
| ------------------------------- | ||
|
|
||
| To be executed before ``git-commit``. | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| uvx pre-commit run --all-files | ||
|
|
||
| The hooks cover: | ||
|
|
||
| - Generic file hygiene: | ||
| YAML/TOML/JSON validity, trailing whitespace, end-of-file newlines, | ||
| merge-conflict markers, case conflicts, and private keys. | ||
| - Python style and linting with Ruff (fix in place). | ||
| - Python type checking with BasedPyright. | ||
| - GitHub Actions workflow linting with actionlint. | ||
| - Bazel module hygiene, including ``bazel mod tidy`` and a lockfile consistency check. | ||
| - Eclipse copyright header presence. | ||
|
|
||
|
|
||
| Python unit tests (score_pytest) | ||
| -------------------------------- | ||
|
|
||
| The unit tests exercise individual Python functions and extensions | ||
| in isolation, without a Sphinx build. | ||
|
|
||
| They are defined with the custom ``score_pytest`` Bazel rule, | ||
| which wraps pytest and pins a single pytest version for the whole repository. | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| bazel test --lockfile_mode=error //... --build_tests_only | ||
|
|
||
| Use this layer for logic inside the extensions, | ||
| the helper library, | ||
| and the command-line tools. | ||
|
|
||
| File-based RST rule checks (metamodel) | ||
| -------------------------------------- | ||
|
|
||
| The file-based tests verify the Sphinx build rules and metamodel checks | ||
| including our whole S-CORE-specific Sphinx setup with extensions. | ||
| Each RST file under ``src/extensions/score_metamodel/tests/rst/`` is a small, | ||
| self-contained Sphinx document. | ||
| A SphinxTestApp builds it and the framework asserts on the resulting warnings, | ||
| using the ``:expect:`` / ``:expect_not:`` options on the needs. | ||
|
|
||
| You need one target per check category: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| bazel test //src/extensions/score_metamodel:file_based_tests_<category> | ||
|
|
||
| The categories are ``architecture``, ``attributes``, ``graph``, | ||
| ``id_contains_feature``, ``options``, ``safety``, and ``security``. | ||
|
|
||
| Use this layer whenever you change the metamodel (``metamodel.yaml``) | ||
| or one of its checks. | ||
| How to write such a test file is described in | ||
| :doc:`extensions/rst_filebased_testing`. | ||
|
|
||
| End-to-end docs.bzl tests (docs_bzl) | ||
| ------------------------------------ | ||
|
|
||
| The end-to-end tests exercise the public ``docs()`` and ``docs_bundle()`` | ||
| macros through real Bazel builds and ``bazel run`` invocations, | ||
| exactly like a consumer would use them. | ||
| They live under ``src/tests/docs_bzl`` and cover composition, | ||
| invalid configurations, external Bzlmod bundles, | ||
| and golden HTML/JSON output comparison. | ||
|
|
||
| They are not Bazel test targets, | ||
| but plain pytest tests that issue Bazel underneath | ||
| because these tests also verify our Bazel/Starlark code. | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| .venv_docs/bin/python -m pytest -vv src/tests/docs_bzl | ||
|
|
||
| The suite must be run sequentially. | ||
| CI splits it with custom markers: | ||
| ``bazel_cached`` (build-only, fast) and ``bazel_slow`` | ||
| (Sphinx runs and expected-failure tests). | ||
|
|
||
| Use this layer for changes to the Bazel macros, | ||
| the bundle composition, | ||
| or the generated output format. | ||
| It is the "docs-bzl scope" in the diagram above. | ||
|
|
||
| Downstream compatibility tests | ||
| ------------------------------ | ||
|
|
||
| The downstream compatibility tests check that changes to docs-as-code | ||
| do not break real consumer repositories. | ||
| They build selected consumers both from a local checkout and from a Git remote, | ||
| using the changed docs-as-code as a dependency. | ||
|
|
||
| They live under ``src/tests/downstream_compatibility``: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| .venv_docs/bin/python -m pytest -s src/tests/downstream_compatibility | ||
|
|
||
| You can restrict the run to selected consumers | ||
| with a pytest ``-k`` expression, | ||
| for example ``-k "score"`` or ``-k "baselibs and remote"``. | ||
| In CI they run automatically. | ||
|
|
||
|
|
||
| Which test for what | ||
| ------------------- | ||
|
|
||
| Use the first suitable one in the table below. | ||
| The later tests are slower. | ||
|
|
||
| .. list-table:: | ||
| :widths: 45 55 | ||
| :header-rows: 1 | ||
|
|
||
| * - Change | ||
| - Relevant layer | ||
| * - Any change | ||
| - Development checks (pre-commit) | ||
| * - Python logic in extensions / helper library / CLI | ||
| - Unit tests (``bazel test //...``) | ||
| * - Metamodel or its checks | ||
| - File-based RST rule checks | ||
| * - Bazel macros, bundles, or output format | ||
| - End-to-end docs_bzl tests | ||
| * - Public API, layouts, or version requirements | ||
| - Downstream compatibility tests | ||
| * - Links or external references in the docs | ||
| - Documentation link checks | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably good to describe this, idk if this should be in
testingbut I also do not know a better place of the top of my head.