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

Make relevancy/coverage linters to not re-read fmf files #2065

Merged
merged 1 commit into from
Jun 29, 2023

Conversation

happz
Copy link
Collaborator

@happz happz commented May 9, 2023

Two test linters checking for legacy constructs were re-reading the original fmf sources, to focus on leaf node only. Patch changes the linters:

  • both now focus on loaded fmf data, i.e. self.node is inspected.
  • this may report keys defined by parents in the node fmf tree, but that is expected - the key is defined, somewhere, and it's inherited by the test metadata, user should be aware. The current implementation might miss this case, although it should be said, relevancycoverage inheritance is probably pretty rare.
  • optional relevancy key fix is applied only when relevancy is defined in the leaf node, i.e. in the test's direct metadata. It relevancy's inherited, the fix would be impractical as it would fix the wrong node.

To get the right tools for this, two functions from tmt.identifier were moved into tmt.utils and generalized a bit.

With this change, two extra reads of fmf files for each test visited by tmt lint are gone, dropping tmt test lint of tmt repo from 3.7 down to 2.6 seconds (on my laptop, YMMV).

@happz happz added the lint label May 9, 2023
@happz happz added this to the 1.24 milestone May 9, 2023
@happz happz changed the title lintMake relevancy/coverage linters to not re-read fmf files Make relevancy/coverage linters to not re-read fmf files May 9, 2023
@happz happz added the blocked The merging of PR is blocked on some other issue label May 11, 2023
@happz happz force-pushed the metadata-linters-dont-reread-source-fmf branch from af2d7b6 to 0b84ad8 Compare May 25, 2023 12:41
@happz happz modified the milestones: 1.24, 1.25 Jun 5, 2023
Base automatically changed from lint-prepare-linters to main June 7, 2023 10:02
@happz happz force-pushed the metadata-linters-dont-reread-source-fmf branch 2 times, most recently from 50bb346 to 0155d3f Compare June 16, 2023 11:12
@happz happz removed the blocked The merging of PR is blocked on some other issue label Jun 16, 2023
@happz happz force-pushed the metadata-linters-dont-reread-source-fmf branch from 0155d3f to bf957db Compare June 22, 2023 10:54
Copy link
Collaborator

@psss psss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple problems spotted.

tmt/utils.py Outdated Show resolved Hide resolved
tmt/base.py Outdated Show resolved Hide resolved
tmt/base.py Outdated Show resolved Hide resolved
@happz happz force-pushed the metadata-linters-dont-reread-source-fmf branch from bf957db to 1ebdbdc Compare June 29, 2023 18:20
@psss psss self-assigned this Jun 29, 2023
Two test linters checking for legacy constructs were re-reading the
original fmf sources, to focus on leaf node only. Patch changes the
linters:

* both now focus on loaded fmf data, i.e. `self.node` is inspected.
* this may report keys defined by parents in the node fmf tree, but that
is expected - the key is defined, somewhere, and it's inherited by the
test metadata, user should be aware. The current implementation might
miss this case, although it should be said, relevancycoverage
inheritance is probably pretty rare.
* optional `relevancy` key fix is applied only when relevancy is defined
in the leaf node, i.e. in the test's direct metadata. It relevancy's
inherited, the fix would be impractical as it would fix the wrong node.

To get the right tools for this, two functions from `tmt.identifier`
were moved into `tmt.utils` and generalized a bit.

With this change, two extra reads of fmf files for each test visited by
`tmt lint` are gone, dropping `tmt test lint` of tmt repo from 3.7 down
to 2.6 seconds (on my laptop, YMMV).
@psss psss force-pushed the metadata-linters-dont-reread-source-fmf branch from 9337712 to 0d2b05d Compare June 29, 2023 19:22
@psss psss merged commit 0d2b05d into main Jun 29, 2023
16 checks passed
@psss psss deleted the metadata-linters-dont-reread-source-fmf branch June 29, 2023 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants