Skip to content

Fix checking of PR status #10085

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
May 1, 2023
Merged

Fix checking of PR status #10085

merged 6 commits into from
May 1, 2023

Conversation

ericholscher
Copy link
Member

@ericholscher ericholscher commented Feb 28, 2023

This was previously checking the status of the build object,
but I think we want to check the status that is passed in,
and only link to the built docs when the build was successful.

Fixes #10018

This was previously checking the status of the build object,
but I think we want to check the status that is passed in,
and only link to the built docs when the build was successful.

if build.state in BUILD_FINAL_STATES and build.success:
if status == BUILD_STATUS_SUCCESS:
Copy link
Member Author

Choose a reason for hiding this comment

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

@humitos I think this is actually what we want? Basically just check if the status was success, then link to the built docs?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think so 😅

Copy link
Contributor

@benjaoming benjaoming left a comment

Choose a reason for hiding this comment

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

Makes sense, BUILD_STATUS_SUCCESS != BUILD_STATE_FINISHED - the previous implementation wouldn't find its way to get_absolute_url() on "success" because it compared it with a build state "finished" 👍

I like the attempt to differentiate between "state" and "status", but I'm not advanced enough in the English language to know what the difference would be.. but I get that it has different definitions in the code base 👍

@benjaoming
Copy link
Contributor

test failures seem legit

@humitos
Copy link
Member

humitos commented Mar 7, 2023

I like the attempt to differentiate between "state" and "status", but I'm not advanced enough in the English language to know what the difference would be

He, we had have some talks about this and I dislike these words because for me they are synonymous 😅 . Besides, they also look pretty similar at first sight and I never know what each of them mean without context. In any case, this topic is un-related from this PR, but just wanted to make my own note about this 😄

@ericholscher
Copy link
Member Author

I like the attempt to differentiate between "state" and "status", but I'm not advanced enough in the English language to know what the difference would be

He, we had have some talks about this and I dislike these words because for me they are synonymous 😅 . Besides, they also look pretty similar at first sight and I never know what each of them mean without context. In any case, this topic is un-related from this PR, but just wanted to make my own note about this 😄

I was mostly just cleaning up the usage, since the code was using them interchangably, as well 🙃

@ericholscher
Copy link
Member Author

I'm not 100% sure whats happening on tests, will have to dive into that a bit deeper.

@ericholscher
Copy link
Member Author

I'm holding off on this, because it's not a huge priority, and my sprint is getting slammed. If anyone is excited to finish this up, feel free to get the tests passing.

@benjaoming
Copy link
Contributor

Testing this on a local setup with GitHub OAuth and webhook delivery to local development environment... but getting TypeError: send_build_status() got an unexpected keyword argument 'build'

web_1          | Internal Server Error: /api/v2/webhook/tutorial-template/1/
web_1          | Traceback (most recent call last):
web_1          |   File "/usr/local/lib/python3.10/dist-packages/django/core/handlers/exception.py", line 47, in inner
web_1          |     response = get_response(request)
web_1          |   File "/usr/local/lib/python3.10/dist-packages/django/core/handlers/base.py", line 181, in _get_response
web_1          |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
web_1          |   File "/usr/local/lib/python3.10/dist-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
web_1          |     return view_func(*args, **kwargs)
web_1          |   File "/usr/local/lib/python3.10/dist-packages/django/views/generic/base.py", line 70, in view
web_1          |     return self.dispatch(request, *args, **kwargs)
web_1          |   File "/usr/local/lib/python3.10/dist-packages/rest_framework/views.py", line 509, in dispatch
web_1          |     response = self.handle_exception(exc)
web_1          |   File "/usr/local/lib/python3.10/dist-packages/rest_framework/views.py", line 469, in handle_exception
web_1          |     self.raise_uncaught_exception(exc)
web_1          |   File "/usr/local/lib/python3.10/dist-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
web_1          |     raise exc
web_1          |   File "/usr/local/lib/python3.10/dist-packages/rest_framework/views.py", line 506, in dispatch
web_1          |     response = handler(request, *args, **kwargs)
web_1          |   File "/usr/src/app/checkouts/readthedocs.org/readthedocs/api/v2/views/integrations.py", line 873, in post
web_1          |     return view(request._request, project_slug)
web_1          |   File "/usr/local/lib/python3.10/dist-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
web_1          |     return view_func(*args, **kwargs)
web_1          |   File "/usr/local/lib/python3.10/dist-packages/django/views/generic/base.py", line 70, in view
web_1          |     return self.dispatch(request, *args, **kwargs)
web_1          |   File "/usr/local/lib/python3.10/dist-packages/rest_framework/views.py", line 509, in dispatch
web_1          |     response = self.handle_exception(exc)
web_1          |   File "/usr/local/lib/python3.10/dist-packages/rest_framework/views.py", line 469, in handle_exception
web_1          |     self.raise_uncaught_exception(exc)
web_1          |   File "/usr/local/lib/python3.10/dist-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
web_1          |     raise exc
web_1          |   File "/usr/local/lib/python3.10/dist-packages/rest_framework/views.py", line 506, in dispatch
web_1          |     response = handler(request, *args, **kwargs)
web_1          |   File "/usr/src/app/checkouts/readthedocs.org/readthedocs/api/v2/views/integrations.py", line 108, in post
web_1          |     resp = self.handle_webhook()
web_1          |   File "/usr/src/app/checkouts/readthedocs.org/readthedocs/api/v2/views/integrations.py", line 470, in handle_webhook
web_1          |     return self.get_external_version_response(self.project)
web_1          |   File "/usr/src/app/checkouts/readthedocs.org/readthedocs/api/v2/views/integrations.py", line 247, in get_external_version_response
web_1          |     to_build = build_external_version(
web_1          |   File "/usr/src/app/checkouts/readthedocs.org/readthedocs/core/views/hooks.py", line 215, in build_external_version
web_1          |     trigger_build(project=project, version=version, commit=version.identifier)
web_1          |   File "/usr/src/app/checkouts/readthedocs.org/readthedocs/core/utils/__init__.py", line 196, in trigger_build
web_1          |     update_docs_task, build = prepare_build(
web_1          |   File "/usr/src/app/checkouts/readthedocs.org/readthedocs/core/utils/__init__.py", line 105, in prepare_build
web_1          |     send_external_build_status(
web_1          |   File "/usr/src/app/checkouts/readthedocs.org/readthedocs/projects/tasks/utils.py", line 154, in send_external_build_status
web_1          |     send_build_status.delay(build=build_pk, commit=commit, status=status)
web_1          |   File "/usr/local/lib/python3.10/dist-packages/celery/app/task.py", line 425, in delay
web_1          |     return self.apply_async(args, kwargs)
web_1          |   File "/usr/local/lib/python3.10/dist-packages/celery/app/task.py", line 540, in apply_async
web_1          |     check_arguments(*(args or ()), **(kwargs or {}))
web_1          | TypeError: send_build_status() got an unexpected keyword argument 'build'

benjaoming added a commit to benjaoming/tutorial-template that referenced this pull request Apr 22, 2023
@benjaoming
Copy link
Contributor

Tested that using positional arguments for send_build_status works now ✔️

I'm suspecting that Celery validates arguments differently from how Python can use positional arguments by name.

Copy link
Contributor

@benjaoming benjaoming left a comment

Choose a reason for hiding this comment

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

Judging from local testing, we need to use positional arguments because of Celery.

I fixed the tests to match this.

If there's anything else you'd like to add, LMK.. I can test locally.

@benjaoming
Copy link
Contributor

Just verified the last thing that came cross my mind: All other services with a send_build_status use positional arguments as well 👍 ✔️

@ericholscher ericholscher enabled auto-merge (squash) May 1, 2023 21:40
@benjaoming
Copy link
Contributor

Auto-merge vs. merge vs. linting 🙃

@ericholscher ericholscher merged commit 5f153d9 into main May 1, 2023
@ericholscher ericholscher deleted the unify-status-checking branch May 1, 2023 22:07
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.

PR build link points to build page instead of artifact
3 participants