Skip to content

Commit b1508c2

Browse files
committed
Clarifications to state vs status
1 parent 9137e90 commit b1508c2

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

readthedocs/builds/constants.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
from django.conf import settings
44
from django.utils.translation import gettext_lazy as _
55

6+
# BUILD_STATE is our *INTERNAL* representation of build states.
7+
# This is not to be confused with external representations of 'status'
8+
# that are sent back to Git providers.
69
BUILD_STATE_TRIGGERED = "triggered"
710
BUILD_STATE_CLONING = "cloning"
811
BUILD_STATE_INSTALLING = "installing"
@@ -78,7 +81,9 @@
7881
STABLE,
7982
)
8083

81-
# General Build Statuses
84+
# General build statuses, i.e. the status that is reported back to the
85+
# user on a Git Provider. This not the same as BUILD_STATE which the internal
86+
# representation.
8287
BUILD_STATUS_FAILURE = 'failed'
8388
BUILD_STATUS_PENDING = 'pending'
8489
BUILD_STATUS_SUCCESS = 'success'

readthedocs/oauth/services/github.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,8 @@ def send_build_status(self, build, commit, status):
446446
project = build.project
447447
owner, repo = build_utils.get_github_username_repo(url=project.repo)
448448

449-
# select the correct state and description.
450-
github_build_state = SELECT_BUILD_STATUS[status]["github"]
449+
# select the correct status and description.
450+
github_build_status = SELECT_BUILD_STATUS[status]["github"]
451451
description = SELECT_BUILD_STATUS[status]["description"]
452452
statuses_url = f"https://api.github.com/repos/{owner}/{repo}/statuses/{commit}"
453453

@@ -461,15 +461,15 @@ def send_build_status(self, build, commit, status):
461461
context = f'{settings.RTD_BUILD_STATUS_API_NAME}:{project.slug}'
462462

463463
data = {
464-
'state': github_build_state,
465-
'target_url': target_url,
466-
'description': description,
467-
'context': context,
464+
"state": github_build_status,
465+
"target_url": target_url,
466+
"description": description,
467+
"context": context,
468468
}
469469

470470
log.bind(
471471
project_slug=project.slug,
472-
commit_status=github_build_state,
472+
commit_status=github_build_status,
473473
user_username=self.user.username,
474474
statuses_url=statuses_url,
475475
)

readthedocs/projects/tasks/builds.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,8 @@ def on_failure(self, exc, task_id, args, kwargs, einfo):
429429
"""
430430
Celery handler to be executed when a task fails.
431431
432+
Updates build data, adds tasks to send build notifications.
433+
432434
.. note::
433435
434436
Since the task has failed, some attributes from the `self.data`
@@ -520,7 +522,10 @@ def on_failure(self, exc, task_id, args, kwargs, einfo):
520522
)
521523

522524
# Update build object
523-
self.data.build['success'] = False
525+
if isinstance(exc, BuildUserSkip):
526+
self.data.build["success"] = True
527+
else:
528+
self.data.build["success"] = False
524529

525530
def get_valid_artifact_types(self):
526531
"""

0 commit comments

Comments
 (0)