Skip to content

Add UI element for resyncing versions from VCS #6090

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

Closed
ericholscher opened this issue Aug 21, 2019 · 7 comments · Fixed by #11484
Closed

Add UI element for resyncing versions from VCS #6090

ericholscher opened this issue Aug 21, 2019 · 7 comments · Fixed by #11484
Assignees
Labels
Accepted Accepted issue on our roadmap Good First Issue Good for new contributors

Comments

@ericholscher
Copy link
Member

Currently we have a task that resyncs Versions from VCS:

class SyncRepositoryTaskStep(SyncRepositoryMixin):

We should create a button on the Versions page (/projects//versions/) that lets users automatically trigger a resync. We usually try and resync versions whenever we get a new webhook from GitHub, but there are a few cases where this doesn't work:

  • A user doesn't have a webhook setup for their repo (eg. non-supported VCS)
  • The users webhook isn't configured to send us pings when they push a new tag/branch
  • A random failure happens either in the webhook code from the provider, or on our side to process it

Normally we tell users to just do a build of their docs to fix this, but I think we should add a UI element to resync them, so it's more obvious how to handle this situation.

@ericholscher ericholscher added the Accepted Accepted issue on our roadmap label Aug 21, 2019
@saadmk11
Copy link
Member

@ericholscher Do we want this to behave same as build list page Build Version button?

def post(self, request, project_slug):
project = get_object_or_404(Project, slug=project_slug)
if not AdminPermission.is_admin(request.user, project):
return HttpResponseForbidden()
version_slug = request.POST.get('version_slug')
version = get_object_or_404(
Version.internal.all(),
project=project,
slug=version_slug,
)
update_docs_task, build = trigger_build(
project=project,
version=version,
)
if (update_docs_task, build) == (None, None):
# Build was skipped
messages.add_message(
request,
messages.WARNING,
"This project is currently disabled and can't trigger new builds.",
)
return HttpResponseRedirect(
reverse('builds_project_list', args=[project.slug]),
)
return HttpResponseRedirect(
reverse('builds_detail', args=[project.slug, build.pk]),
)

And Will this Resync Button be available for all the version or only the active versions?

@stsewd
Copy link
Member

stsewd commented Sep 25, 2019

@saadmk11 the Resync button is only one for each project. The task only clones the repo and parse the tags and branches, so the versions are in sync.

@stsewd stsewd added the Good First Issue Good for new contributors label Sep 25, 2019
@ericholscher
Copy link
Member Author

I had a user request resyncing via API, so they could ensure branches were synced in their CI. This could be a good first step towards an implementation, which the frontend UI element could just hit.

@agjohnson
Copy link
Contributor

Yeah, an API endpoint would be perfect.

See readthedocs/ext-theme#65 for the dashboard implementation:

@ericholscher
Copy link
Member Author

@ericholscher
Copy link
Member Author

Looking into this, we already have an API endpoint for this:

@decorators.api_view(["POST"])
@decorators.permission_classes((permissions.IsAuthenticated,))
@decorators.renderer_classes((JSONRenderer,))
def sync_remote_repositories(request):
"""Trigger a re-sync of remote repositories for the user."""
result = tasks.sync_remote_repositories.delay(
user_id=request.user.id,
)
task_id = result.task_id
return Response(
{
"task_id": task_id,
"url": reverse("api_job_status", kwargs={"task_id": task_id}),
}
)

@humitos
Copy link
Member

humitos commented Jul 18, 2024

Yes, we have this button in the old dashboard. This endpoint does not work because it requires Celery storing the results and we removed that feature because of... Celery-reasons.

The current button in the old dashboard just fakes it and waits ~3s, IIRC.

ericholscher added a commit that referenced this issue Jul 18, 2024
This will be used in the frontend,
but also available as an API.

Mostly curious if this is a good approach,
and I can get some tests together for it.

Refs #6090
@ericholscher ericholscher moved this from Planned to In progress in 📍Roadmap Jul 18, 2024
@ericholscher ericholscher linked a pull request Jul 18, 2024 that will close this issue
@ericholscher ericholscher moved this from In progress to Needs review in 📍Roadmap Jul 23, 2024
ericholscher added a commit that referenced this issue Jul 29, 2024
* Add an initial resync_versions API to v3

This will be used in the frontend,
but also available as an API.

Mostly curious if this is a good approach,
and I can get some tests together for it.

Refs #6090

* Add test

* Fix test

* Add default serializer

* Add to serializer

* Update readthedocs/api/v3/views.py

Co-authored-by: Santos Gallegos <[email protected]>

* Update sync_versions endpoint

* Fix tests

* Add docs

* Add missing test

---------

Co-authored-by: Santos Gallegos <[email protected]>
@github-project-automation github-project-automation bot moved this from Needs review to Done in 📍Roadmap Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Accepted issue on our roadmap Good First Issue Good for new contributors
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants