From 0f7ee6ff355dfaf26004946bc4416e34187f5787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0pl=C3=ADchal?= Date: Thu, 5 Dec 2024 11:47:18 +0100 Subject: [PATCH 1/5] Implement the new core key `author` To be used for tracking the information about the original author of the test, plan or story. --- spec/core/author.fmf | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 spec/core/author.fmf diff --git a/spec/core/author.fmf b/spec/core/author.fmf new file mode 100644 index 0000000000..1e40b56000 --- /dev/null +++ b/spec/core/author.fmf @@ -0,0 +1,30 @@ +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 the standard place for the + the original author as this information can be present in + various places so it's not always easy to find it. Also when + the test changes it's location to a different git repository + the information about the original author can be lost. + +example: + - | + # Single author + author: Name Surname + + - | + # Multiple authors + author: + - First Person + - Second Person + +link: + - implemented-by: /tmt/base.py + - verified-by: /tests/plan/show + - verified-by: /tests/story/show + - verified-by: /tests/test/show From 285867d8ce0147dd1d30206ab374aada1c0331d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0pl=C3=ADchal?= Date: Tue, 21 Jan 2025 15:59:13 +0100 Subject: [PATCH 2/5] Update spec/core/author.fmf Co-authored-by: Miroslav Vadkerti --- spec/core/author.fmf | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/core/author.fmf b/spec/core/author.fmf index 1e40b56000..8320659409 100644 --- a/spec/core/author.fmf +++ b/spec/core/author.fmf @@ -6,11 +6,11 @@ story: history or check various random files. description: | - This dedicated field provides the standard place for the - the original author as this information can be present in - various places so it's not always easy to find it. Also when - the test changes it's location to a different git repository - the information about the original author can be lost. + 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. example: - | From 8a428bfa883f6ebdac5b2b15e931c663db22d1bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0pl=C3=ADchal?= Date: Tue, 21 Jan 2025 16:30:41 +0100 Subject: [PATCH 3/5] The `author` key implementation, test and schema --- docs/releases.rst | 7 +++++++ tests/test/show/data/tests/full.fmf | 1 + tests/test/show/test.sh | 1 + tmt/base.py | 12 ++++++++++-- tmt/schemas/core.yaml | 4 ++++ tmt/schemas/plan.yaml | 4 ++++ tmt/schemas/story.yaml | 4 ++++ tmt/schemas/test.yaml | 4 ++++ tmt/steps/discover/shell.py | 4 ++++ tmt/steps/report/reportportal.py | 3 +++ 10 files changed, 42 insertions(+), 2 deletions(-) diff --git a/docs/releases.rst b/docs/releases.rst index 6481362464..3959441704 100644 --- a/docs/releases.rst +++ b/docs/releases.rst @@ -17,6 +17,13 @@ for tmt. It is used by plugins that use Ansible under the hood, :ref:`finish/ansible`, and :ref:`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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/test/show/data/tests/full.fmf b/tests/test/show/data/tests/full.fmf index 3c0beffd12..a216ce6a16 100644 --- a/tests/test/show/data/tests/full.fmf +++ b/tests/test/show/data/tests/full.fmf @@ -1,5 +1,6 @@ summary: Check the test keys are correctly displayed description: Some description +author: Original Author contact: Some Body component: package id: e3a9a8ed-4585-4e86-80e8-1d99eb5345a9 diff --git a/tests/test/show/test.sh b/tests/test/show/test.sh index 23647568b4..2ae9ebf302 100755 --- a/tests/test/show/test.sh +++ b/tests/test/show/test.sh @@ -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 " $rlRun_LOG rlAssertGrep "contact Some Body " $rlRun_LOG rlAssertGrep "component package" $rlRun_LOG rlAssertGrep "id e3a9a8ed-4585-4e86-80e8-1d99eb5345a9" $rlRun_LOG diff --git a/tmt/base.py b/tmt/base.py index fd2fe6e5ea..c6cd9df468 100644 --- a/tmt/base.py +++ b/tmt/base.py @@ -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 @@ -697,6 +701,7 @@ class Core( # Basic stuff 'summary', 'description', + 'author', 'contact', 'enabled', 'order', @@ -1117,6 +1122,7 @@ class Test( # Basic test information 'summary', 'description', + 'author', 'contact', 'component', 'id', @@ -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): @@ -2676,6 +2683,7 @@ class Story( 'id', 'priority', 'description', + 'author', 'contact', 'example', 'enabled', diff --git a/tmt/schemas/core.yaml b/tmt/schemas/core.yaml index 61d5cd24eb..c291ed1c7b 100644 --- a/tmt/schemas/core.yaml +++ b/tmt/schemas/core.yaml @@ -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" diff --git a/tmt/schemas/plan.yaml b/tmt/schemas/plan.yaml index 52d11f695b..2199f66bc0 100644 --- a/tmt/schemas/plan.yaml +++ b/tmt/schemas/plan.yaml @@ -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" diff --git a/tmt/schemas/story.yaml b/tmt/schemas/story.yaml index ae2214a6cb..83c0cf08a7 100644 --- a/tmt/schemas/story.yaml +++ b/tmt/schemas/story.yaml @@ -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" diff --git a/tmt/schemas/test.yaml b/tmt/schemas/test.yaml index 1e265bbded..e481c374a8 100644 --- a/tmt/schemas/test.yaml +++ b/tmt/schemas/test.yaml @@ -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" diff --git a/tmt/steps/discover/shell.py b/tmt/steps/discover/shell.py index af45968a36..46bee650db 100644 --- a/tmt/steps/discover/shell.py +++ b/tmt/steps/discover/shell.py @@ -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 diff --git a/tmt/steps/report/reportportal.py b/tmt/steps/report/reportportal.py index f80d7f62c9..b77eb6c320 100644 --- a/tmt/steps/report/reportportal.py +++ b/tmt/steps/report/reportportal.py @@ -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] From 45e673e5678645d41fae59fa0819b5d4f24d10f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0pl=C3=ADchal?= Date: Wed, 22 Jan 2025 09:49:59 +0100 Subject: [PATCH 4/5] Mention the version where the key was added --- spec/core/author.fmf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/core/author.fmf b/spec/core/author.fmf index 8320659409..740907289e 100644 --- a/spec/core/author.fmf +++ b/spec/core/author.fmf @@ -12,6 +12,8 @@ description: | Additionally, when a test is moved to a different Git repository, the original author's information can be lost. + .. versionadded:: 1.42 + example: - | # Single author From 72e9f5842ecc85a4dc281c148bd2d82f872d1b47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0pl=C3=ADchal?= Date: Fri, 24 Jan 2025 11:35:05 +0100 Subject: [PATCH 5/5] Extend story/plan tests, add discover/shell schema --- tests/plan/show/data/plans/full.fmf | 1 + tests/plan/show/test.sh | 1 + tests/story/show/data/stories/full.fmf | 1 + tests/story/show/test.sh | 1 + tmt/schemas/discover/shell.yaml | 4 ++++ 5 files changed, 8 insertions(+) diff --git a/tests/plan/show/data/plans/full.fmf b/tests/plan/show/data/plans/full.fmf index 55cb0a36cf..25c69a3e79 100644 --- a/tests/plan/show/data/plans/full.fmf +++ b/tests/plan/show/data/plans/full.fmf @@ -1,6 +1,7 @@ # Core summary: Plan keys are correctly displayed description: Some description +author: Original Author contact: Some Body id: e3a9a8ed-4585-4e86-80e8-1d99eb5345a9 enabled: true diff --git a/tests/plan/show/test.sh b/tests/plan/show/test.sh index ff829ca651..665fd945e3 100755 --- a/tests/plan/show/test.sh +++ b/tests/plan/show/test.sh @@ -128,6 +128,7 @@ rlJournalStart rlAssertGrep "summary Plan keys are correctly displayed" $rlRun_LOG rlAssertGrep "description Some description" $rlRun_LOG rlAssertGrep "contact Some Body " $rlRun_LOG + rlAssertGrep "author Original Author " $rlRun_LOG rlAssertGrep "id e3a9a8ed-4585-4e86-80e8-1d99eb5345a9" $rlRun_LOG rlAssertGrep "enabled true" $rlRun_LOG rlAssertGrep "order 70" $rlRun_LOG diff --git a/tests/story/show/data/stories/full.fmf b/tests/story/show/data/stories/full.fmf index 328652af30..66bd917a2f 100644 --- a/tests/story/show/data/stories/full.fmf +++ b/tests/story/show/data/stories/full.fmf @@ -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 contact: Some Body priority: must have example: Inspiring example diff --git a/tests/story/show/test.sh b/tests/story/show/test.sh index ec75bcf9f7..1edfc00073 100755 --- a/tests/story/show/test.sh +++ b/tests/story/show/test.sh @@ -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 " $rlRun_LOG rlAssertGrep "contact Some Body " $rlRun_LOG rlAssertGrep "priority must have" $rlRun_LOG rlAssertGrep "example Inspiring example" $rlRun_LOG diff --git a/tmt/schemas/discover/shell.yaml b/tmt/schemas/discover/shell.yaml index a7baca4496..87a5778fef 100644 --- a/tmt/schemas/discover/shell.yaml +++ b/tmt/schemas/discover/shell.yaml @@ -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"