Skip to content

GitHub App: fix PR builds and import #12126

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

Merged
merged 6 commits into from
Apr 23, 2025
Merged

GitHub App: fix PR builds and import #12126

merged 6 commits into from
Apr 23, 2025

Conversation

stsewd
Copy link
Member

@stsewd stsewd commented Apr 22, 2025

  • Update admin to make it more usable for remote repos/orgs
  • When implementing the signature of the base service class I forgot to return a tuple, the tuple contains a boolean and the response, which is weird, because all other method return only a boolean, and we never use the response. So I went ahead and removed the need to return a tuple from all services.
  • Allow activating PR previews for projects connected to a GH app from the form.
  • Build from PRs for projects that explicitly have the option enabled, since now with the GH app we always listen to all events.
  • Tests tests tests

@stsewd stsewd marked this pull request as ready for review April 22, 2025 22:29
@stsewd stsewd requested a review from a team as a code owner April 22, 2025 22:29
@stsewd stsewd requested a review from ericholscher April 22, 2025 22:29
@stsewd stsewd requested a review from Copilot April 22, 2025 22:29
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR streamlines webhook service methods by eliminating tuple returns in favor of simple boolean values, while also introducing GitHub App integration support and updating related tests and admin configurations.

  • Remove tuple returns from webhook service methods.
  • Introduce GitHub App integration tests and update existing tests accordingly.
  • Update admin and view logic to conditionally enable external builds based on integration type.

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
readthedocs/rtd_tests/tests/test_oauth.py Updated tests to consume a boolean return from webhook setup and update methods.
readthedocs/rtd_tests/tests/test_celery.py Added tests for GitHub App service build status callback handling.
readthedocs/projects/tests/test_views.py Introduced tests for GitHub App integration and external build option behavior.
readthedocs/projects/forms.py Modified form validation logic for external builds when using a GitHub App integration.
readthedocs/oauth/views.py Filtered projects by external_builds_enabled in webhook event handling.
readthedocs/oauth/utils.py Adjusted webhook update logic to reflect new boolean return type.
readthedocs/oauth/tests/test_githubapp_webhook.py Expanded GitHub App webhook tests for various PR event scenarios.
readthedocs/oauth/tasks.py Updated webhook setup tasks to expect boolean returns.
readthedocs/oauth/services/gitlab.py Refactored webhook methods with type hints and simplified boolean returns.
readthedocs/oauth/services/githubapp.py Updated webhook service methods with GitHub App integration to return a boolean.
readthedocs/oauth/services/github.py Modified webhook methods to remove tuple returns and include type hints.
readthedocs/oauth/services/bitbucket.py Adapted webhook methods to use simple boolean returns and updated docstrings.
readthedocs/oauth/services/base.py Documented base service methods to reflect the new return type signature.
readthedocs/oauth/admin.py Enhanced admin configuration to support GitHub App installations.

Copy link
Member

@humitos humitos left a comment

Choose a reason for hiding this comment

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

Good work! 🧑‍🏭

"remote_repository",
"user",
"account",
"vcs_provider",
Copy link
Member

Choose a reason for hiding this comment

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

Isn't it possible to use the following and avoid having to define the method below?

Suggested change
"vcs_provider",
"remote_repository__vcs_provider",

Copy link
Member Author

Choose a reason for hiding this comment

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

nope :/ django doesn't like it, or at least in 4.2, I see that 5.2 has that case as a valid example https://docs.djangoproject.com/en/5.2/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_display

"remote_organization",
"user",
"account",
"vcs_provider",
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

@stsewd stsewd merged commit b4bdd3d into main Apr 23, 2025
8 checks passed
@stsewd stsewd deleted the several-fixes-for-gh-app branch April 23, 2025 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants