Implement triggering TF with build from other PR#1658
Implement triggering TF with build from other PR#1658softwarefactory-project-zuul[bot] merged 4 commits intopackit:mainfrom
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
f1bff4a to
a6d64d5
Compare
This comment was marked as outdated.
This comment was marked as outdated.
a6d64d5 to
3958a09
Compare
This comment was marked as outdated.
This comment was marked as outdated.
3958a09 to
94e0565
Compare
|
Build succeeded. ✔️ pre-commit SUCCESS in 2m 50s |
TomasTomecek
left a comment
There was a problem hiding this comment.
Very nice work with the refactoring!
I also like how straightforward this is.
94e0565 to
cf1e743
Compare
|
Build succeeded. ✔️ pre-commit SUCCESS in 2m 00s |
mfocko
left a comment
There was a problem hiding this comment.
pls tell me I didn't spend 30 minutes on that second commit /o\
packit_service/models.py
Outdated
| Iterable["TFTTestRunTargetModel"], | ||
| ], | ||
| statuses_to_filter_with: List[str], | ||
| ) -> Optional[Set[Union["CoprBuildTargetModel", "TFTTestRunTargetModel"]]]: |
There was a problem hiding this comment.
Given the input, I guess you meant
| ) -> Optional[Set[Union["CoprBuildTargetModel", "TFTTestRunTargetModel"]]]: | |
| ) -> Optional[Union[Set["CoprBuildTargetModel"], Set["TFTTestRunTargetModel"]]]: |
There was a problem hiding this comment.
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
cf1e743 to
bd9d803
Compare
|
Build succeeded. ✔️ pre-commit SUCCESS in 1m 57s |
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.
bd9d803 to
5cccddb
Compare
|
Build succeeded. ✔️ pre-commit SUCCESS in 2m 16s |
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
5cccddb to
d7ddff9
Compare
|
Build succeeded. ✔️ pre-commit SUCCESS in 2m 33s |
|
Build succeeded (gate pipeline). ✔️ pre-commit SUCCESS in 2m 04s |
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.
|
I have just tested it in lbarcziova/hello-world#1 and the ideal use case works just fine. |
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.
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>
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>
| 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 |
There was a problem hiding this comment.
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.
| 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:
| 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.
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.
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.
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>
TODO:
packit/packit.dev(Add docs about running TF with builds from other PR packit.dev#528).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