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

Added lint check for duplicate test ids #3017

Merged
merged 4 commits into from
Aug 2, 2024

Conversation

engelmi
Copy link
Contributor

@engelmi engelmi commented Jun 14, 2024

Fixes: #2939

In order to be able detect duplicate ids of tests for a given tmt.Tree, a new lintable class Tests has been introduced. It doesn't reflect a specific node in the tree, but rather a collection of test nodes. On this collection, the duplicate lint check is being executed.

The lintable Tests implements the lint function for the duplicate test id check - this can be further extended in the future with additional lint checks.

Example usage triggering the new lint check:

$ tmt lint <path>
$ tmt tests lint <path>
$ tmt stories lint <path>
$ tmt plans lint <path>

# example output - detected no duplicate
Lint checks on all tests
pass G001 no duplicate test id detected

# example output - detected duplicate
Lint checks on all
fail G001 duplicate id "6886e7c8-7548-4cf7-8dd4-d2d46b125fd3" in test "/tests/clean/chain"
fail G001 duplicate id "6886e7c8-7548-4cf7-8dd4-d2d46b125fd3" in test "/tests/clean/runs"

Lint checks on all
fail G001 duplicate id "5cf92c54-e073-475c-970f-b8e090ec4da2" in "/duplicates/tests/duplicateid"
fail G001 duplicate id "5cf92c54-e073-475c-970f-b8e090ec4da2" in "/duplicates/tests/duplicateid"
fail G001 duplicate id "5cf92c54-e073-475c-970f-b8e090ec4da2" in "/duplicates/tests/duplicateid"

Pull Request Checklist

  • implement the feature
  • write the documentation
  • extend the test coverage

@engelmi engelmi force-pushed the rfe-tmt-lint-duplicate-test-ids branch from 2a5f886 to c6b9994 Compare June 14, 2024 13:18
@engelmi
Copy link
Contributor Author

engelmi commented Jun 14, 2024

@happz I wanted to ask if this is going into the right direction as we discussed in the RFE #2939? (only a draft PR for now that implements the rough functionality)

@happz
Copy link
Collaborator

happz commented Jun 14, 2024

@happz I wanted to ask if this is going into the right direction as we discussed in the RFE #2939? (only a draft PR for now that implements the rough functionality)

In general, it looks good, it is indeed along the lines of some collection-wide linter. I'll add just a couple of minor minor comments.

Edit: BTW plans and stories also have IDs :)
Edit2: hm, can story have same id as a test? Maybe we should write this from the perspective of a collection of tmt objects, not just the collection of tmt tests. A container of not only tests, but any objects loaded by lint subcommand - tmt test lint would fill it with tests, while tmt lint would fill it with everything. tmt.base.Core instead of tmt.base.Test.

@happz happz added command | tests tmt tests command command | lint tmt lint command labels Jun 14, 2024
tmt/base.py Outdated Show resolved Hide resolved
tmt/base.py Show resolved Hide resolved
tmt/cli.py Outdated Show resolved Hide resolved
tmt/base.py Outdated Show resolved Hide resolved
@engelmi engelmi force-pushed the rfe-tmt-lint-duplicate-test-ids branch from c6b9994 to b41b1fd Compare June 18, 2024 12:36
@engelmi
Copy link
Contributor Author

engelmi commented Jun 18, 2024

In general, it looks good, it is indeed along the lines of some collection-wide linter. I'll add just a couple of minor minor comments.

Edit: BTW plans and stories also have IDs :) Edit2: hm, can story have same id as a test? Maybe we should write this from the perspective of a collection of tmt objects, not just the collection of tmt tests. A container of not only tests, but any objects loaded by lint subcommand - tmt test lint would fill it with tests, while tmt lint would fill it with everything. tmt.base.Core instead of tmt.base.Test.

Thanks for your feedback! I tried to apply the changes. PTAL @happz

I was also looking into updating the (unit) tests and it seems like when adding test files with the duplicate ids, the other tests will break because of this. What do you think about adding a flag to enable/disable such linters on collections?

@happz
Copy link
Collaborator

happz commented Jun 18, 2024

I was also looking into updating the (unit) tests and it seems like when adding test files with the duplicate ids, the other tests will break because of this. What do you think about adding a flag to enable/disable such linters on collections?

Did you try putting them into a dedicated, separate fmf root? We already have https://github.com/teemtee/tmt/tree/main/tests/lint/test/data, we could add something like data-duplicate-id or something, just for files to test this linter. Then tests for other linters would not consider these at all.

@engelmi engelmi force-pushed the rfe-tmt-lint-duplicate-test-ids branch 2 times, most recently from 60e1a1a to f1ce7a7 Compare June 19, 2024 15:14
@engelmi
Copy link
Contributor Author

engelmi commented Jun 19, 2024

Did you try putting them into a dedicated, separate fmf root? We already have https://github.com/teemtee/tmt/tree/main/tests/lint/test/data, we could add something like data-duplicate-id or something, just for files to test this linter. Then tests for other linters would not consider these at all.

Thanks for the hint! I think I was able to create a few new tests based on this.

@engelmi engelmi marked this pull request as ready for review June 19, 2024 15:21
@engelmi engelmi force-pushed the rfe-tmt-lint-duplicate-test-ids branch from f1ce7a7 to 4b5780b Compare June 21, 2024 07:22
@engelmi engelmi requested a review from happz June 21, 2024 07:33
@engelmi engelmi force-pushed the rfe-tmt-lint-duplicate-test-ids branch from 4b5780b to eaccdda Compare June 24, 2024 13:56
@engelmi
Copy link
Contributor Author

engelmi commented Jun 24, 2024

@happz Could you have another look at this PR? I've added tests now as well and think it should be complete.

@engelmi engelmi force-pushed the rfe-tmt-lint-duplicate-test-ids branch 4 times, most recently from 3aa12f1 to 41b16c3 Compare June 28, 2024 13:47
@engelmi
Copy link
Contributor Author

engelmi commented Jul 1, 2024

@happz Ping :)

@happz happz added this to the 1.35 milestone Jul 1, 2024
@happz
Copy link
Collaborator

happz commented Jul 25, 2024

Tests are failing on testing-farm. I'll try to figure out what I broke and how to fix it. Do you have maybe any hints? @happz

Hmm, all seems unrelated to your changes, it seems there's some problem with debuginfo in rawhide, so, ruining all results.

@engelmi engelmi force-pushed the rfe-tmt-lint-duplicate-test-ids branch 3 times, most recently from 930d745 to e1c370b Compare July 29, 2024 18:35
@engelmi
Copy link
Contributor Author

engelmi commented Jul 29, 2024

Tests are failing on testing-farm. I'll try to figure out what I broke and how to fix it. Do you have maybe any hints? @happz

Hmm, all seems unrelated to your changes, it seems there's some problem with debuginfo in rawhide, so, ruining all results.

Ah ok. In that case, can we re-run the pipeline again since a few days have passed?

@martinhoyer
Copy link
Collaborator

/packit build

Copy link
Collaborator

@martinhoyer martinhoyer left a comment

Choose a reason for hiding this comment

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

Nice. Maybe worth adding a release note.

@engelmi
Copy link
Contributor Author

engelmi commented Aug 1, 2024

Nice. Maybe worth adding a release note.

Thanks! Should I add a release note to docs/releases.rst or is this done by the tmt maintainers on release? @martinhoyer

@martinhoyer
Copy link
Collaborator

Thanks! Should I add a release note to docs/releases.rst or is this done by the tmt maintainers on release? @martinhoyer

If you'll have time, feel free to add it there, thanks!
Oh, and if you're not yet in docs/overview.rst list of contributors, feel free to add yourself there, especially if you have any special name preference, otherwise we can add your name (from github account) during the release. :)

@engelmi engelmi force-pushed the rfe-tmt-lint-duplicate-test-ids branch 2 times, most recently from ecbcc65 to d06fd8e Compare August 1, 2024 10:33
@engelmi
Copy link
Contributor Author

engelmi commented Aug 1, 2024

Thanks! Should I add a release note to docs/releases.rst or is this done by the tmt maintainers on release? @martinhoyer

If you'll have time, feel free to add it there, thanks! Oh, and if you're not yet in docs/overview.rst list of contributors, feel free to add yourself there, especially if you have any special name preference, otherwise we can add your name (from github account) during the release. :)

Updated ✔️
@martinhoyer PTAL

@martinhoyer
Copy link
Collaborator

Updated ✔️ @martinhoyer PTAL

Thanks @engelmi, looks like you missed the release note in d06fd8e

@engelmi engelmi force-pushed the rfe-tmt-lint-duplicate-test-ids branch from d06fd8e to 009be51 Compare August 1, 2024 11:26
@engelmi
Copy link
Contributor Author

engelmi commented Aug 1, 2024

Updated ✔️ @martinhoyer PTAL

Thanks @engelmi, looks like you missed the release note in d06fd8e

Ups, good catch! Added it.

@martinhoyer
Copy link
Collaborator

/packit build

@engelmi engelmi force-pushed the rfe-tmt-lint-duplicate-test-ids branch from 009be51 to 9b4d78a Compare August 2, 2024 08:10
@martinhoyer
Copy link
Collaborator

/packit build

engelmi and others added 4 commits August 2, 2024 19:39
Fixes: teemtee#2939

In order to be able detect duplicate ids of tests, plans and
stories, a new lintable class for such collections has been
introduced. It doesn't reflect a specific node in the tree
and is specific to lint operations.
On this collection, the duplicate lint check is implemented
and can be easily extended in the future by additional checks.

Signed-off-by: Michael Engel <mengel@redhat.com>
Relates to: teemtee#2939

Extending current tests to verify the new lint feature for
checking duplicate ids on tests, plans, stories and across
those.

Signed-off-by: Michael Engel <mengel@redhat.com>
@happz happz force-pushed the rfe-tmt-lint-duplicate-test-ids branch from 9b4d78a to 9b75f55 Compare August 2, 2024 17:41
@happz happz added the status | ready for merge The only missing piece is to do the rebase the current 'main' and let the CI finish. label Aug 2, 2024
@happz
Copy link
Collaborator

happz commented Aug 2, 2024

/packit build

@happz happz merged commit 8b0c508 into teemtee:main Aug 2, 2024
19 of 20 checks passed
The-Mule pushed a commit to The-Mule/tmt that referenced this pull request Oct 14, 2024
Fixes: teemtee#2939

In order to be able detect duplicate ids of tests, plans and
stories, a new lintable class for such collections has been
introduced. It doesn't reflect a specific node in the tree
and is specific to lint operations.
On this collection, the duplicate lint check is implemented
and can be easily extended in the future by additional checks.

Signed-off-by: Michael Engel <mengel@redhat.com>
Co-authored-by: Miloš Prchlík <mprchlik@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci | full test Pull request is ready for the full test execution command | lint tmt lint command command | tests tmt tests command status | ready for merge The only missing piece is to do the rebase the current 'main' and let the CI finish.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFE: tmt test id option to check for duplicate IDs
5 participants