forked from teemtee/tmt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add HW requirement support matrix to docs (teemtee#3025)
Generated from HW requriement stories and their links, it should be the most up-to-date picture of what's supported by plugins shipped with tmt.
- Loading branch information
Showing
9 changed files
with
153 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 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
Empty file.
This file contains 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,5 @@ | ||
@import 'css/theme.css'; | ||
|
||
/* Used for HW requirement support matrix */ | ||
.supported { color: green; } | ||
.unsupported { color: red; } |
This file contains 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 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 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,84 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import sys | ||
import textwrap | ||
|
||
import tmt.plugins | ||
import tmt.steps.provision | ||
from tmt.utils import Path, render_template_file | ||
|
||
HELP = textwrap.dedent(""" | ||
Usage: generate-hardware-matrix.py <TEMPLATE-PATH> <OUTPUT-PATH> | ||
Generate page with HW requirement support matrix from stories. | ||
""").strip() | ||
|
||
|
||
def main() -> None: | ||
if len(sys.argv) != 3: | ||
print(HELP) | ||
|
||
sys.exit(1) | ||
|
||
template_filepath = Path(sys.argv[1]) | ||
output_filepath = Path(sys.argv[2]) | ||
|
||
# We will need a logger... | ||
logger = tmt.Logger.create() | ||
logger.add_console_handler() | ||
|
||
# Explore available *export* plugins - do not import other plugins, we don't need them. | ||
tmt.plugins._explore_packages(logger) | ||
|
||
known_methods = sorted( | ||
tmt.steps.provision.ProvisionPlugin._supported_methods.iter_plugin_ids()) | ||
|
||
tree = tmt.Tree(logger=logger, path=Path.cwd()) | ||
|
||
logger.info('Generating reST file for HW requirement support matrix') | ||
|
||
matrix: dict[str, dict[str, tuple[bool, str]]] = {} | ||
notes: list[str] = [] | ||
|
||
for story in tree.stories(logger=logger, names=['^/spec/hardware/.*'], whole=True): | ||
hw_requirement = story.name.replace('/spec/hardware/', '') | ||
|
||
if hw_requirement == 'arch': | ||
continue | ||
|
||
matrix[hw_requirement] = { | ||
method: (False, int) for method in known_methods | ||
} | ||
|
||
if not story.link: | ||
pass | ||
|
||
for link in story.link.get(relation='implemented-by'): | ||
implemented_by_method = Path(link.target).stem | ||
|
||
if implemented_by_method == 'mrack': | ||
implemented_by_method = 'beaker' | ||
|
||
elif implemented_by_method == 'testcloud': | ||
implemented_by_method = 'virtual.testcloud' | ||
|
||
if implemented_by_method not in matrix[hw_requirement]: | ||
raise Exception(f'{implemented_by_method} unknown') | ||
|
||
if link.note: | ||
notes.append(f'``{hw_requirement}`` with ``{implemented_by_method}``: {link.note}') | ||
|
||
matrix[hw_requirement][implemented_by_method] = (True, len(notes)) | ||
|
||
else: | ||
matrix[hw_requirement][implemented_by_method] = (True, None) | ||
|
||
output_filepath.write_text(render_template_file( | ||
template_filepath, | ||
LOGGER=logger, | ||
MATRIX=matrix, | ||
NOTES=notes)) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains 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,44 @@ | ||
{# | ||
A Jinja2 template for rendering HW requirement support matrix in tmt's own docs. | ||
#} | ||
|
||
.. _/plugins/provision/hardware-requirement-support-matrix: | ||
|
||
Hardware requirement support | ||
---------------------------- | ||
|
||
Below you can find a matrix documenting which hardware requirement are | ||
supported by plugins bundled with tmt. | ||
|
||
.. role:: supported | ||
|
||
.. role:: unsupported | ||
|
||
.. list-table:: | ||
:header-rows: 1 | ||
|
||
* - Requirement | ||
{% for plugin in MATRIX['memory'].keys() %} | ||
{% if plugin == 'virtual.testcloud' %} | ||
- ``virtual`` | ||
{% else %} | ||
- ``{{ plugin }}`` | ||
{% endif %} | ||
{% endfor %} | ||
|
||
{% for requirement, plugins in MATRIX.items() %} | ||
* - :ref:`{{ requirement }}{# djlint:off #}</spec/hardware/{# djlint:on H025 #}{{ requirement }}>` | ||
{% for plugin, (enabled, note_id) in plugins.items() %} | ||
{% if enabled %} | ||
- :supported:`yes`{% if note_id %} [{{ note_id }}]_{% endif %} | ||
|
||
{% else %} | ||
- :unsupported:`no` | ||
|
||
{% endif %} | ||
{% endfor %} | ||
{% endfor %} | ||
|
||
{% for note in NOTES %} | ||
.. [{{ loop.index }}] {{ note }} | ||
{% endfor %} |
This file contains 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