Skip to content
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

Implement the new core key author #3406

Merged
merged 5 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/releases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ for tmt. It is used by plugins that use Ansible under the hood,
:ref:`finish/ansible</plugins/finish/ansible>`,
and :ref:`prepare/feature</plugins/prepare/feature>`.

A new core attribute :ref:`/spec/core/author` has been implemented
for tracking the original author of the test, plan or story. In
contrast to the :ref:`/spec/core/contact` key, this field is not
supposed to be updated and can be useful when trying to track down
the original author for consultation.


tmt-1.41.0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
32 changes: 32 additions & 0 deletions spec/core/author.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
summary: Author contact

story:
As a user I would like to contact the original author of the
test, plan or story without having to dig through the git
history or check various random files.

description: |
This dedicated field provides a standard location for
the original author's information, as it can be scattered
across various places and may be difficult to locate.
Additionally, when a test is moved to a different Git
repository, the original author's information can be lost.
psss marked this conversation as resolved.
Show resolved Hide resolved

.. versionadded:: 1.42

example:
- |
# Single author
author: Name Surname <[email protected]>

- |
# Multiple authors
author:
- First Person <[email protected]>
- Second Person <[email protected]>

link:
- implemented-by: /tmt/base.py
- verified-by: /tests/plan/show
- verified-by: /tests/story/show
- verified-by: /tests/test/show
1 change: 1 addition & 0 deletions tests/plan/show/data/plans/full.fmf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Core
summary: Plan keys are correctly displayed
description: Some description
author: Original Author <[email protected]>
contact: Some Body <[email protected]>
id: e3a9a8ed-4585-4e86-80e8-1d99eb5345a9
enabled: true
Expand Down
1 change: 1 addition & 0 deletions tests/plan/show/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ rlJournalStart
rlAssertGrep "summary Plan keys are correctly displayed" $rlRun_LOG
rlAssertGrep "description Some description" $rlRun_LOG
rlAssertGrep "contact Some Body <[email protected]>" $rlRun_LOG
rlAssertGrep "author Original Author <[email protected]>" $rlRun_LOG
rlAssertGrep "id e3a9a8ed-4585-4e86-80e8-1d99eb5345a9" $rlRun_LOG
rlAssertGrep "enabled true" $rlRun_LOG
rlAssertGrep "order 70" $rlRun_LOG
Expand Down
1 change: 1 addition & 0 deletions tests/story/show/data/stories/full.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ summary: Story keys are correctly displayed
title: Concise title
story: As a user I want this and that
description: Some description
author: Original Author <[email protected]>
contact: Some Body <[email protected]>
priority: must have
example: Inspiring example
Expand Down
1 change: 1 addition & 0 deletions tests/story/show/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ rlJournalStart
rlAssertGrep "title Concise title" $rlRun_LOG
rlAssertGrep "story As a user I want this and that" $rlRun_LOG
rlAssertGrep "description Some description" $rlRun_LOG
rlAssertGrep "author Original Author <[email protected]>" $rlRun_LOG
rlAssertGrep "contact Some Body <[email protected]>" $rlRun_LOG
rlAssertGrep "priority must have" $rlRun_LOG
rlAssertGrep "example Inspiring example" $rlRun_LOG
Expand Down
1 change: 1 addition & 0 deletions tests/test/show/data/tests/full.fmf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
summary: Check the test keys are correctly displayed
description: Some description
author: Original Author <[email protected]>
contact: Some Body <[email protected]>
component: package
id: e3a9a8ed-4585-4e86-80e8-1d99eb5345a9
Expand Down
1 change: 1 addition & 0 deletions tests/test/show/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ rlJournalStart
rlRun -s "tmt tests show full"
rlAssertGrep "summary Check the test keys are correctly displayed" $rlRun_LOG
rlAssertGrep "description Some description" $rlRun_LOG
rlAssertGrep "author Original Author <[email protected]>" $rlRun_LOG
rlAssertGrep "contact Some Body <[email protected]>" $rlRun_LOG
rlAssertGrep "component package" $rlRun_LOG
rlAssertGrep "id e3a9a8ed-4585-4e86-80e8-1d99eb5345a9" $rlRun_LOG
Expand Down
12 changes: 10 additions & 2 deletions tmt/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,10 @@ class Core(
# Core attributes (supported across all levels)
summary: Optional[str] = None
description: Optional[str] = None
author: list[str] = field(
default_factory=list,
normalize=tmt.utils.normalize_string_list
)
contact: list[str] = field(
default_factory=list,
normalize=tmt.utils.normalize_string_list
Expand Down Expand Up @@ -697,6 +701,7 @@ class Core(
# Basic stuff
'summary',
'description',
'author',
'contact',
'enabled',
'order',
Expand Down Expand Up @@ -1117,6 +1122,7 @@ class Test(
# Basic test information
'summary',
'description',
'author',
'contact',
'component',
'id',
Expand Down Expand Up @@ -2136,9 +2142,10 @@ def show(self) -> None:
if self.description:
echo(tmt.utils.format(
'description', self.description, key_color='green'))
if self.author:
echo(tmt.utils.format('author', self.author, key_color='green'))
if self.contact:
echo(tmt.utils.format(
'contact', self.contact, key_color='green'))
echo(tmt.utils.format('contact', self.contact, key_color='green'))

# Individual step details
for step in self.steps(enabled_only=False):
Expand Down Expand Up @@ -2676,6 +2683,7 @@ class Story(
'id',
'priority',
'description',
'author',
'contact',
'example',
'enabled',
Expand Down
4 changes: 4 additions & 0 deletions tmt/schemas/core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ definitions:
- type: array
- type: object

# https://tmt.readthedocs.io/en/stable/spec/core.html#author
author:
$ref: "/schemas/common#/definitions/one_or_more_strings"

# https://tmt.readthedocs.io/en/stable/spec/core.html#contact
contact:
$ref: "/schemas/common#/definitions/one_or_more_strings"
Expand Down
4 changes: 4 additions & 0 deletions tmt/schemas/discover/shell.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ properties:
adjust:
$ref: "/schemas/core#/definitions/adjust"

# https://tmt.readthedocs.io/en/stable/spec/core.html#author
author:
$ref: "/schemas/core#/definitions/author"

# https://tmt.readthedocs.io/en/stable/spec/tests.html#component
component:
$ref: "/schemas/test#/properties/component"
Expand Down
4 changes: 4 additions & 0 deletions tmt/schemas/plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ properties:
adjust:
$ref: "/schemas/core#/definitions/adjust"

# https://tmt.readthedocs.io/en/stable/spec/core.html#author
author:
$ref: "/schemas/core#/definitions/author"

# https://tmt.readthedocs.io/en/stable/spec/core.html#contact
contact:
$ref: "/schemas/core#/definitions/contact"
Expand Down
4 changes: 4 additions & 0 deletions tmt/schemas/story.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ properties:
adjust:
$ref: "/schemas/core#/definitions/adjust"

# https://tmt.readthedocs.io/en/stable/spec/core.html#author
author:
$ref: "/schemas/core#/definitions/author"

# https://tmt.readthedocs.io/en/stable/spec/core.html#contact
contact:
$ref: "/schemas/core#/definitions/contact"
Expand Down
4 changes: 4 additions & 0 deletions tmt/schemas/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ properties:
adjust:
$ref: "/schemas/core#/definitions/adjust"

# https://tmt.readthedocs.io/en/stable/spec/core.html#author
author:
$ref: "/schemas/core#/definitions/author"

# https://tmt.readthedocs.io/en/stable/spec/tests.html#component
component:
$ref: "/schemas/common#/definitions/one_or_more_strings"
Expand Down
4 changes: 4 additions & 0 deletions tmt/steps/discover/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ class TestDescription(
)

# Basic test information
author: list[str] = field(
default_factory=list,
normalize=tmt.utils.normalize_string_list
)
contact: list[str] = field(
default_factory=list,
normalize=tmt.utils.normalize_string_list
Expand Down
3 changes: 3 additions & 0 deletions tmt/steps/report/reportportal.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,9 @@ def execute_rp_import(self) -> None:
serial_number = test.serial_number
if not test_name:
test_name = test.name
if test.author:
item_attributes += [
{'key': 'author', 'value': author} for author in test.author]
if test.contact:
item_attributes += [
{'key': 'contact', 'value': contact} for contact in test.contact]
Expand Down