Skip to content

Use test tree consistently with dist-git fmf#4973

Open
LecrisUT wants to merge 4 commits into
mainfrom
fix/dist-git
Open

Use test tree consistently with dist-git fmf#4973
LecrisUT wants to merge 4 commits into
mainfrom
fix/dist-git

Conversation

@LecrisUT

@LecrisUT LecrisUT commented Jun 9, 2026

Copy link
Copy Markdown
Member

Fixes a regression in #4915 where it would not get the appropriate ref when requested using the local git repository.

Incidentally, the non-dist-git approach already behaves as we want it with and without url, so we can (should be) using the test_dir directly. We can thus just drop the special handling of dist-git in the _fetch_local_repository also.

@LecrisUT LecrisUT added bug Something isn't working ci | full test Pull request is ready for the full test execution plugin | fmf The fmf discover plugin area | dist-git Implementation related to integration with the dist-git repositories. labels Jun 9, 2026
@LecrisUT LecrisUT added this to planning Jun 9, 2026
@github-project-automation github-project-automation Bot moved this to backlog in planning Jun 9, 2026
@LecrisUT LecrisUT added the status | blocking other work An important pull request, blocking other pull requests or issues label Jun 9, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request simplifies the local repository fetching and dist-git source processing in tmt/steps/discover/fmf.py by removing several conditional checks related to dist_git_source. Feedback suggests restoring the and not self.data.dist_git_source check when validating paths, as dist-git sources cannot be verified until extraction. Additionally, it is recommended to set requires_git to True and raise an error if no git repository is found when dist_git_source is enabled to prevent a regression where the git repository is not copied to test_dir.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread tmt/steps/discover/fmf.py
Comment on lines +607 to +620
if path and not path.is_dir():
raise tmt.utils.DiscoverError(f"Provided path '{path}' is not a directory.")
if self.data.dist_git_source:
# Ensure we're in a git repo when extracting dist-git sources
if self.step.plan.fmf_root is None:
raise tmt.utils.DiscoverError("No git repository found for DistGit.")
git_root = tmt.utils.git.git_root(
fmf_root=self.step.plan.fmf_root, logger=self._logger
)
if not git_root:
raise tmt.utils.DiscoverError(f"{self.step.plan.fmf_root} is not a git repo")
else:
if fmf_root is None:
raise tmt.utils.DiscoverError("No metadata found in the current directory.")
# Check git repository root (use fmf root if not found)
git_root = tmt.utils.git.git_root(fmf_root=fmf_root, logger=self._logger)
if not git_root:
self.debug(f"Git root not found, using '{fmf_root}.'")
git_root = fmf_root
# Set path to relative path from the git root to fmf root
path = fmf_root.resolve().relative_to(
git_root.resolve() if requires_git else fmf_root.resolve()
)

if fmf_root is None:
raise tmt.utils.DiscoverError("No metadata found in the current directory.")
# Check git repository root (use fmf root if not found)
git_root = tmt.utils.git.git_root(fmf_root=fmf_root, logger=self._logger)
if not git_root:
self.debug(f"Git root not found, using '{fmf_root}.'")
git_root = fmf_root
# Set path to relative path from the git root to fmf root
path = fmf_root.resolve().relative_to(
git_root.resolve() if requires_git else fmf_root.resolve()
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Restore the and not self.data.dist_git_source check when validating path, as the path for dist-git sources cannot be verified until they are extracted. Additionally, set requires_git to True and raise an error if no git repository is found when dist_git_source is enabled to prevent a regression where the git repository is not copied to test_dir when the fmf root is a subdirectory of the git root.

        if path and not path.is_dir() and not self.data.dist_git_source:
            raise tmt.utils.DiscoverError(f"Provided path '{path}' is not a directory.")

        if fmf_root is None:
            raise tmt.utils.DiscoverError("No metadata found in the current directory.")
        if self.data.dist_git_source:
            requires_git = True
        # Check git repository root (use fmf root if not found)
        git_root = tmt.utils.git.git_root(fmf_root=fmf_root, logger=self._logger)
        if not git_root:
            if self.data.dist_git_source:
                raise tmt.utils.DiscoverError("No git repository found for DistGit.")
            self.debug(f"Git root not found, using '{fmf_root}.'")
            git_root = fmf_root
        # Set path to relative path from the git root to fmf root
        path = fmf_root.resolve().relative_to(
            git_root.resolve() if requires_git else fmf_root.resolve()
        )
References
  1. Use direct imperatives and be concise with no fluff. (link)

@bajertom bajertom moved this from backlog to review in planning Jun 9, 2026
@vaibhavdaren

Copy link
Copy Markdown
Contributor

One Test Case is still failing.

@psss psss added this to the 1.76 milestone Jun 9, 2026
@LecrisUT

LecrisUT commented Jun 9, 2026

Copy link
Copy Markdown
Member Author

One Test Case is still failing.

Welp, this is related to one old nasty bug that I wanted to resolve #2097

@LecrisUT

LecrisUT commented Jun 9, 2026

Copy link
Copy Markdown
Member Author

Here is the run tree before

Details
$ tree -a -I .git
.
├── cleanup
│   └── step.yaml
├── data
│   ├── plan-source-script.sh
│   └── variables.env-default-0
├── discover
│   ├── default-0
│   │   ├── source
│   │   │   ├── demo-1.0-build
│   │   │   ├── demo.spec
│   │   │   ├── .fmf
│   │   │   │   └── version
│   │   │   ├── mock_sources
│   │   │   ├── outsider
│   │   │   ├── sources
│   │   │   ├── SPECPARTS
│   │   │   ├── SRPMS
│   │   │   ├── top_test.fmf
│   │   │   ├── with-tmt-1
│   │   │   │   ├── .fmf
│   │   │   │   │   └── version
│   │   │   │   ├── from-source.txt
│   │   │   │   └── tests
│   │   │   │       └── from-source.fmf
│   │   │   └── with-tmt-1.tgz
│   │   └── tests
│   │       ├── .fmf
│   │       │   └── version
│   │       ├── from-source.txt
│   │       └── tests
│   │           └── from-source.fmf
│   ├── step.yaml
│   └── tests.yaml
├── execute
│   ├── results.yaml
│   └── step.yaml
├── finish
│   └── step.yaml
├── prepare
│   ├── results.yaml
│   └── step.yaml
├── provision
│   ├── default-0
│   │   └── podman-run-environment
│   ├── guests.yaml
│   └── step.yaml
├── report
│   └── step.yaml
└── tree
    ├── demo.spec
    ├── .fmf
    │   └── version
    ├── mock_sources
    ├── sources
    ├── top_test.fmf
    └── with-tmt-1.tgz

24 directories, 33 files

after

Details
$ tree -a -I .git
.
├── cleanup
│   └── step.yaml
├── data
│   ├── plan-source-script.sh
│   └── variables.env-default-0
├── discover
│   ├── default-0
│   │   ├── source
│   │   │   ├── demo-1.0-build
│   │   │   ├── demo.spec
│   │   │   ├── .fmf
│   │   │   │   └── version
│   │   │   ├── mock_sources
│   │   │   ├── outsider
│   │   │   ├── sources
│   │   │   ├── SPECPARTS
│   │   │   ├── SRPMS
│   │   │   ├── top_test.fmf
│   │   │   ├── with-tmt-1
│   │   │   │   ├── .fmf
│   │   │   │   │   └── version
│   │   │   │   ├── from-source.txt
│   │   │   │   └── tests
│   │   │   │       └── from-source.fmf
│   │   │   └── with-tmt-1.tgz
│   │   └── tests
│   │       ├── demo.spec
│   │       ├── .fmf
│   │       │   └── version
│   │       ├── from-source.txt
│   │       ├── mock_sources
│   │       ├── sources
│   │       ├── tests
│   │       │   └── from-source.fmf
│   │       ├── top_test.fmf
│   │       └── with-tmt-1.tgz
│   ├── step.yaml
│   └── tests.yaml
├── execute
│   ├── results.yaml
│   └── step.yaml
├── finish
│   └── step.yaml
├── prepare
│   ├── results.yaml
│   └── step.yaml
├── provision
│   ├── default-0
│   │   └── podman-run-environment
│   ├── guests.yaml
│   └── step.yaml
├── report
│   └── step.yaml
└── tree
    ├── demo.spec
    ├── .fmf
    │   └── version
    ├── mock_sources
    ├── sources
    ├── top_test.fmf
    └── with-tmt-1.tgz

24 directories, 38 files

and the archive content

Details
$ tar -tf with-tmt-1.tgz 
with-tmt-1/
with-tmt-1/from-source.txt
with-tmt-1/.fmf/
with-tmt-1/.fmf/version
with-tmt-1/tests/
with-tmt-1/tests/from-source.fmf
outsider

The issue here is we have 2 paths:

  • dist-git-merge which should be the same result as the current after: it takes the inner tree and merges it in the test tree
  • without dist-git-merge use the tree under the source

The old approach basically had an empty test tree so the same copy operation that dist-git-merge was "valid", but in the current PR it behaves like dist-git-merge.

A quick fix would be in the non-dist-git-merge to copy/symlink the whole source, and change path to be prefixed by the discovered dist-git fmf tree.


Long-term I would instead want to clean this up as:

  • test_dir is always a symlink to the test tree
  • redefine source to be the git cloned (dist-git source is the same here), unarchived path
  • construct the symlink that points to the inner path under source

@therazix sounds good to you

Comment thread tests/discover/distgit.sh
@LecrisUT

LecrisUT commented Jun 9, 2026

Copy link
Copy Markdown
Member Author

/packit retest-failed

@bajertom bajertom mentioned this pull request Jun 10, 2026
LecrisUT added 4 commits June 10, 2026 18:02
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area | dist-git Implementation related to integration with the dist-git repositories. bug Something isn't working ci | full test Pull request is ready for the full test execution plugin | fmf The fmf discover plugin status | blocking other work An important pull request, blocking other pull requests or issues

Projects

Status: review

Development

Successfully merging this pull request may close these issues.

5 participants