-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Add ability to rebuild a specific build #8227
Conversation
This is most useful for PR builds, but I've enabled it for all builds currently. It might make sense to only enable it for PR builds, or other builds where we care about rebuilding a specific commit. Fixes #6524
Co-authored-by: Maksudul Haque <saad.mk112@gmail.com>
Co-authored-by: Maksudul Haque <saad.mk112@gmail.com>
Instead of re-using the `Build` object, we are creating a new one following the same process that we already have for normal builds. This reduces the complexity of the code by not adding a new special case and also keeps the history of build outputs so users can compare it and figure it out where the potential problem was.
Marked as |
Allowing to re-build all the versions and all the past build could end up on publishing outdated docs for a stable/latest version. So, we are restricting this only to External Versions and only to its latest build object. See discussion in #6995 (comment)
- check at view level (POST) - test case for the check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty simple. Only a small code structure question. 👍
Using 400 as response results in a blank page. It's better to clearly communicate what's the problem and redirect to the build listing page.
|
||
{# Show rebuild button only if the version is external and it's the latest build for this version #} | ||
{# see https://github.com/readthedocs/readthedocs.org/pull/6995#issuecomment-852918969 #} | ||
{% if request.user|is_admin:project and build.version.type == "external" and is_latest_build %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not related to this PR, but I remember is_admin: project
being expensive, we are using the check 3 times now. We can move it to the context instead.
readthedocs.org/readthedocs/projects/views/public.py
Lines 129 to 132 in 0340604
context['is_project_admin'] = AdminPermission.is_admin( | |
self.request.user, | |
project, | |
) |
{# see https://github.com/readthedocs/readthedocs.org/pull/6995#issuecomment-852918969 #} | ||
{% if request.user|is_admin:project and build.version.type == "external" and is_latest_build %} | ||
<div data-bind="visible: finished()"> | ||
<form method="post" name="rebuild_commit" action="{% url "builds_project_list" project.slug %}"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels weird having this on the same list view, I think we could have another view /builds/{pk}/trigger/
or similar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a common pattern: POST to a list view to create a new object. We are using this in the same way when triggering a build for a particular version on Build List page at
<form method="post" action="{% url "builds_project_list" project.slug %}"> |
Seems fine to me to re-use the view and just pass build_pk
to trigger a build for a particular version at a specific point in time.
I addressed all the suggestions. This can be re-reviewed and merged now. |
Looks good to me once CI passes 👍 |
Continuation of #6993. The difference with the other PR is this one creates a new
Build
object instead of re-using the old one. This reduces complexity by not adding a new special case and also allows us to keep build history giving the users the opportunity to take a look at the differences and understand why the first one failed but the re-triggered one passed.See my comment at #6995 (comment)
Closes #6524