Skip to content

Implement triggering TF with build from other PR#1658

Merged
softwarefactory-project-zuul[bot] merged 4 commits intopackit:mainfrom
lbarcziova:tf-more-builds
Sep 29, 2022
Merged

Implement triggering TF with build from other PR#1658
softwarefactory-project-zuul[bot] merged 4 commits intopackit:mainfrom
lbarcziova:tf-more-builds

Conversation

@lbarcziova
Copy link
Copy Markdown
Member

@lbarcziova lbarcziova commented Sep 15, 2022

TODO:

Fixes #1544

Since this is a bigger change, maybe we can try the pair-review if anyone would be interested :D


RELEASE NOTES BEGIN
We have added support for running the tests with Copr builds built by Packit in another pull request (in a different repository). You can read more about this feature in our documentation.
RELEASE NOTES END

@softwarefactory-project-zuul

This comment was marked as outdated.

@softwarefactory-project-zuul

This comment was marked as outdated.

@softwarefactory-project-zuul

This comment was marked as outdated.

@softwarefactory-project-zuul
Copy link
Copy Markdown
Contributor

Build succeeded.

✔️ pre-commit SUCCESS in 2m 50s
✔️ packit-service-tests SUCCESS in 2m 03s
✔️ packit-service-tests-openshift SUCCESS in 11m 51s

@lbarcziova lbarcziova marked this pull request as ready for review September 19, 2022 07:54
Copy link
Copy Markdown
Member

@TomasTomecek TomasTomecek left a comment

Choose a reason for hiding this comment

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

Very nice work with the refactoring!

I also like how straightforward this is.

@softwarefactory-project-zuul
Copy link
Copy Markdown
Contributor

Build succeeded.

✔️ pre-commit SUCCESS in 2m 00s
✔️ packit-service-tests SUCCESS in 2m 06s
✔️ packit-service-tests-openshift SUCCESS in 11m 01s

Copy link
Copy Markdown
Member

@mfocko mfocko left a comment

Choose a reason for hiding this comment

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

pls tell me I didn't spend 30 minutes on that second commit /o\

Iterable["TFTTestRunTargetModel"],
],
statuses_to_filter_with: List[str],
) -> Optional[Set[Union["CoprBuildTargetModel", "TFTTestRunTargetModel"]]]:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Given the input, I guess you meant

Suggested change
) -> Optional[Set[Union["CoprBuildTargetModel", "TFTTestRunTargetModel"]]]:
) -> Optional[Union[Set["CoprBuildTargetModel"], Set["TFTTestRunTargetModel"]]]:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I haven't written this code, but yes, the types were wrong and not only here...I tried to correct it (1. commit), but I don't know how to explain some things to mypy (line 226 in models.py :D)..I would be glad for any advice

@softwarefactory-project-zuul
Copy link
Copy Markdown
Contributor

Build succeeded.

✔️ pre-commit SUCCESS in 1m 57s
✔️ packit-service-tests SUCCESS in 1m 58s
✔️ packit-service-tests-openshift SUCCESS in 11m 25s

Move methods of AbstractForgeIndependentEvent for filtering most recent
copr build and testing farm target models by status to models.py as functions
so that they can be used on other places.
@softwarefactory-project-zuul
Copy link
Copy Markdown
Contributor

Build succeeded.

✔️ pre-commit SUCCESS in 2m 16s
✔️ packit-service-tests SUCCESS in 2m 08s
✔️ packit-service-tests-openshift SUCCESS in 11m 58s

Implement getting of additional Copr build target models that can be specified
by test comment command PR argument, e.g. '/packit test repo/namespace#123'.
In TestingFarmJobHandler pre-check check whether there are any successful recent Copr builds
for that PR in the database and report to user.

If TF is triggered by a comment with PR argument, include the artifact
for the build from that PR, the packages from that build in the payload
and add the TF run to the pipeline for that PR build in the database as well.
Change the API for getting the TF runs to be able to get
the additional build from the TF run.

Also split the long methods in the TestingFarmJobHelper.
Create tests for the new usecase and update the existing tests
to reflect the changes.
They both are quite independent, so they don't need to be in the abstract.py.
This should avoid circular imports.

Fixes packit#1618
@softwarefactory-project-zuul
Copy link
Copy Markdown
Contributor

Build succeeded.

✔️ pre-commit SUCCESS in 2m 33s
✔️ packit-service-tests SUCCESS in 2m 35s
✔️ packit-service-tests-openshift SUCCESS in 13m 24s

@lbarcziova lbarcziova added the mergeit Merge via Zuul label Sep 29, 2022
@softwarefactory-project-zuul
Copy link
Copy Markdown
Contributor

Build succeeded (gate pipeline).

✔️ pre-commit SUCCESS in 2m 04s

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit 31b879e into packit:main Sep 29, 2022
lbarcziova added a commit to lbarcziova/dashboard that referenced this pull request Sep 29, 2022
In packit/packit-service#1658 there was implemented that a TF run can be triggered with multiple
Copr builds and API for TF runs changed (copr_build_id -> copr_build_ids) as well.
This PR implements displaying those builds correctly in the TF result view.
@lbarcziova
Copy link
Copy Markdown
Member Author

I have just tested it in lbarcziova/hello-world#1 and the ideal use case works just fine.

@lbarcziova lbarcziova deleted the tf-more-builds branch September 29, 2022 12:54
lbarcziova added a commit to lbarcziova/dashboard that referenced this pull request Sep 29, 2022
In packit/packit-service#1658 there was implemented that a TF run can be triggered with multiple
Copr builds and API for TF runs changed (copr_build_id -> copr_build_ids) as well.
This PR implements displaying those builds correctly in the TF result view.
softwarefactory-project-zuul bot added a commit to packit/dashboard that referenced this pull request Sep 29, 2022
Display multiple Copr builds for TF results if present

In packit/packit-service#1658 there was implemented that a TF run can be triggered with multiple Copr builds and API for TF runs changed (copr_build_id -> copr_build_ids) as well. This PR implements displaying those builds correctly in the TF result view.
Related to packit/packit-service#1658
The view for the TF runs with only one build stays the same and this is how it looks like for TF runs with more builds:


RELEASE NOTES BEGIN
N/A
RELEASE NOTES END

Reviewed-by: Matej Focko <None>
softwarefactory-project-zuul bot added a commit to packit/packit.dev that referenced this pull request Oct 4, 2022
Add docs about running TF with builds from other PR

Related to packit/packit-service#1658

Reviewed-by: Tomas Tomecek <tomas@tomecek.net>
Reviewed-by: Laura Barcziová <None>
Comment on lines +190 to +197
if not self._comment_command_parts and (
comment := self.metadata.event_dict.get("comment")
):
self._comment_command_parts = get_packit_commands_from_comment(
comment,
packit_comment_command_prefix=self.service_config.comment_command_prefix,
)
return self._comment_command_parts
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.

I know it's a bite late for this comment (and probably I'm not the most qualified person to suggest this), but this method looks a bit strange, specially if because there is a mutation happening to the self._comment_command_parts class-property, and we are returning the value we just assigned to a class-property that can be accessed later.

Ideally, I think it would be more readable and concise if this method doesn't return any result in it, but instead, override the value if necessary of the class-property and that's it.

My suggestion for this one would be removing the return statement at the end of the method and leaving the mutation where it is right now, especially because the class initializes the property as None.

Suggested change
if not self._comment_command_parts and (
comment := self.metadata.event_dict.get("comment")
):
self._comment_command_parts = get_packit_commands_from_comment(
comment,
packit_comment_command_prefix=self.service_config.comment_command_prefix,
)
return self._comment_command_parts
def comment_command_parts(self) -> Optional[List[str]]:
"""
List of packit comment command parts if the testing farm was triggered by a comment.
Note:
If the `self._comment_command_parts is not None, we will let the value as it is for now.
This method will only override the contents of the class-property if the same is `None`, and
we detect a comment from the `self.metadata`
Example:
'/packit test' -> ["test"]
'/packit test namespace/repo#pr' -> ["test", "namespace/repo#pr"]
"""
if not self._comment_command_parts and (
comment := self.metadata.event_dict.get("comment")
):
self._comment_command_parts = get_packit_commands_from_comment(
comment,
packit_comment_command_prefix=self.service_config.comment_command_prefix,
)

If you choose that, then you necessarily don't need to transform this method into a property, but rather, leave it as a method.

If you would still prefer to have it as a property because that would trigger a lot of changes in other parts of the code, then, I think something like this could also be good:

Suggested change
if not self._comment_command_parts and (
comment := self.metadata.event_dict.get("comment")
):
self._comment_command_parts = get_packit_commands_from_comment(
comment,
packit_comment_command_prefix=self.service_config.comment_command_prefix,
)
return self._comment_command_parts
def comment_command_parts(self) -> Optional[List[str]]:
"""
List of packit comment command parts if the testing farm was triggered by a comment.
Note:
If the `self._comment_command_parts is not None, we will let the value as it is for now.
This method will only override the contents of the class-property if the same is `None`, and
we detect a comment from the `self.metadata`
Example:
'/packit test' -> ["test"]
'/packit test namespace/repo#pr' -> ["test", "namespace/repo#pr"]
"""
if comment := self.metadata.event_dict.get("comment"):
return get_packit_commands_from_comment(
comment,
packit_comment_command_prefix=self.service_config.comment_command_prefix,
)
else:
return None

I'm recommending this especially because I can see that self._comment_command_parts: Optional[List[str]] = None is not used anywhere else other than here, so, probably, it would be easier to not have this class-property and have it either the method or the method-property instead.

But of course, again, I may not be the best person to be proposing this right now, especially because the PR is already merged. Feel free to just close this comment if you think it's not worth it.

P.S: In my opinion, I lean towards the second suggestion.

r0x0d added a commit to r0x0d/packit-service that referenced this pull request Nov 18, 2022
A typo was introduced in packit#1658 where the `namespace` and `repo` were in the wrong order. 

Also removed the parameter `url` as the default value for `url` in `report_status_to_tests` is already an empty string.
jpopelka pushed a commit to r0x0d/packit-service that referenced this pull request Nov 21, 2022
A typo was introduced in packit#1658 where the `namespace` and `repo` were in the wrong order. 

Also removed the parameter `url` as the default value for `url` in `report_status_to_tests` is already an empty string.
softwarefactory-project-zuul bot added a commit that referenced this pull request Nov 21, 2022
Fix a typo in the failure message

A typo was introduced in #1658 where the namespace and repo were in the wrong order.
Also removed the parameter url as the default value for url in report_status_to_tests is already an empty string.

Reviewed-by: Laura Barcziová <None>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mergeit Merge via Zuul

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Triggering testing farm tests with artifacts from another project

4 participants