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

Support repos without GitLab remote #3583

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

CtrlZmaster
Copy link
Contributor

@CtrlZmaster CtrlZmaster commented Mar 6, 2025

I do not set up GitLab repo as a remote for RHEL dist-git because there is no rhel-X-main branch and all of the branches are protected anyways, so I don't see the point. I didn't run tmt locally for some time and yesterday, I was hit with a No known remote ... error when I attempted to run my test plan. Because I didn't know what it means, I searched in the source code and found the issue. Before 9cad874, RHEL dist-git remotes were specified by both pkgs.devel.redhat.com and GitLab URI substrings. Therefore, I believe that this is a regression. I wanted to create an issue first but then I realized that there is a simple fix, so I took a stab at it.

Maybe the omission of pkgs.devel.redhat.com was intentional in the rewrite, so feel free to reject this PR. There is a simple workaround of just adding the GitLab dist-git repo as a remote after all.

Pull Request Checklist

  • implement the feature
  • write the documentation
  • extend the test coverage
  • update the specification
  • adjust plugin docstring
  • modify the json schema
  • mention the version
  • include a release note

@lukaszachy
Copy link
Collaborator

@CtrlZmaster Internal dist-git should be handled by RHELInternalDistGit from tmt-redhat-utils package.
With that said, as dist-git url is not a secret for some time already, this PR will make it easier for users so +1 to have it public.

@CtrlZmaster
Copy link
Contributor Author

@lukaszachy well, that's embarrassing 🤦 I knew of the plugins but I didn't see any use for them in my workflow. Thinking about it, this might be the first time I ran tmt from RHEL dist-git. I started developing tmt plans in CentOS and never touched them in RHEL z-stream, I guess.

Since the dist-git URL is not a secret, it would be nicer if this worked out-of-the-box. The additional class in the plugin is pretty much just duplicated code and if a change like this was merged, the plugin could be eliminated. I think that that could make life of packagers easier, because the plugin wouldn't be needed. Just installing tmt from RPM would be enough to start, no need to setup repos for the plugins.

I can rewrite the commit messages so that they are correct and rebase... I suppose that the internal plugin was always needed and this is not a regression? Should I take the PR out of draft? Can you please guide me on what to do next?

@lukaszachy
Copy link
Collaborator

I see we have class *DistGit defined both in tmt.utils and tmt.utils.git
@happz The right place should be tmt.utils.git ?

@CtrlZmaster Lets wait until we figure out where is the right single place to RedHatDistGit defined. After that I think this PR needs to drop the other location and it is good to go.

@happz
Copy link
Collaborator

happz commented Mar 7, 2025

I see we have class *DistGit defined both in tmt.utils and tmt.utils.git @happz The right place should be tmt.utils.git ?

Most likely, that looks like those classes were moved to tmt.utils.git but I forgot to remove the originals. Something might be still referring to them. In any case, tmt.utils.git it should be, IMO.

@CtrlZmaster
Copy link
Contributor Author

@happz I was wondering why are the classes defined twice, so I just decided to be cautious and fix both places. The only references I could find yesterday were from inside the tmt.utils.git module. I'll double check and remove the classes from tmt.utils.

@CtrlZmaster
Copy link
Contributor Author

These were the differences between the two modules (some typing and git module was calling the functions it had from init):

# diff from_utils.py from_git.py
31c31
<         ret_values = []
---
>         ret_values: list[tuple[str, str]] = []
102c102,103
<     remotes: Optional[list[str]] = None, usage_name: Optional[str] = None
---
>     remotes: Optional[list[str]] = None,
>     usage_name: Optional[str] = None,
150c151
<         handler = get_distgit_handler(remotes=remotes)
---
>         handler = tmt.utils.get_distgit_handler(remotes=remotes)
152c153
<         handler = get_distgit_handler(usage_name=handler_name)
---
>         handler = tmt.utils.get_distgit_handler(usage_name=handler_name)
156c157
<         with retry_session() as session:
---
>         with tmt.utils.retry_session() as session:

I also searched for references to code in tmt.utils and fixed all of them. It looks like the tests were only ran on the tmt.utils module before and the tmt.utils.git module wasn't always in use 😬 Hope I didn't break anything 😅

If the RHEL dist-git repo doesn't have a non-forked GitLab remote, tmt
fails with: "No known remote...". The support for internal dist-git is
present in the tmt-redhat-internal plugin but since there are no secret
URLs in that module, it can be supported upstream too. This simplifies
installation as there is no need to install plugins which are available
in non-default repositories.
@CtrlZmaster CtrlZmaster marked this pull request as ready for review March 7, 2025 15:14
@lukaszachy lukaszachy added step | discover Stuff related to the discover step code | utils Various utility functions and classes used across the code labels Mar 7, 2025
@lukaszachy
Copy link
Collaborator

/packit build

Copy link
Collaborator

@lukaszachy lukaszachy left a comment

Choose a reason for hiding this comment

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

Local testing shows it works :)

@lukaszachy
Copy link
Collaborator

lukaszachy commented Mar 7, 2025

@CtrlZmaster We have quite horrible PR->review->merge turnaround so please bear with us if this PR stays open for a long time

@lukaszachy lukaszachy added the status | backlog Defined, prioritized, we plan to work on it. label Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code | utils Various utility functions and classes used across the code status | backlog Defined, prioritized, we plan to work on it. step | discover Stuff related to the discover step
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants