Skip to content

Commit

Permalink
Build: remove browndates for config file (#11012)
Browse files Browse the repository at this point in the history
We are ahead of the dates for these deprecations, so they became the default
path now and we have to always check for them.
  • Loading branch information
humitos authored Jan 9, 2024
1 parent bde1f43 commit ac125ee
Showing 1 changed file with 7 additions and 38 deletions.
45 changes: 7 additions & 38 deletions readthedocs/doc_builder/director.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
import os
import tarfile

import pytz
import structlog
import yaml
from django.conf import settings
from django.utils import timezone
from django.utils.translation import gettext_lazy as _

from readthedocs.builds.constants import EXTERNAL
Expand Down Expand Up @@ -249,47 +247,18 @@ def checkout(self):
self.data.build["config"] = self.data.config.as_dict()
self.data.build["readthedocs_yaml_path"] = custom_config_file

now = timezone.now()
pdt = pytz.timezone("America/Los_Angeles")

# fmt: off
# These browndates matches https://blog.readthedocs.com/use-build-os-config/
browndates = any([
timezone.datetime(2023, 7, 14, 0, 0, 0, tzinfo=pdt) < now < timezone.datetime(2023, 7, 14, 12, 0, 0, tzinfo=pdt), # First, 12hs
timezone.datetime(2023, 8, 14, 0, 0, 0, tzinfo=pdt) < now < timezone.datetime(2023, 8, 15, 0, 0, 0, tzinfo=pdt), # Second, 24hs
timezone.datetime(2023, 9, 4, 0, 0, 0, tzinfo=pdt) < now < timezone.datetime(2023, 9, 6, 0, 0, 0, tzinfo=pdt), # Third, 24hs
timezone.datetime(2023, 9, 25, 0, 0, 0, tzinfo=pdt) < now, # Fully removal
])
# fmt: on

# Raise a build error if the project is not using a config file or using v1
if (
settings.RTD_ENFORCE_BROWNOUTS_FOR_DEPRECATIONS
and browndates
and self.data.config.version not in ("2", 2)
):
if self.data.config.version not in ("2", 2):
raise BuildUserError(BuildUserError.NO_CONFIG_FILE_DEPRECATED)

# Raise a build error if the project is using "build.image" on their config file
build_config_key = self.data.config.source_config.get("build", {})
if "image" in build_config_key:
raise BuildUserError(BuildUserError.BUILD_IMAGE_CONFIG_KEY_DEPRECATED)

# fmt: off
# These browndates matches https://blog.readthedocs.com/use-build-os-config/
browndates = any([
timezone.datetime(2023, 8, 28, 0, 0, 0, tzinfo=pdt) < now < timezone.datetime(2023, 8, 28, 12, 0, 0, tzinfo=pdt), # First, 12hs
timezone.datetime(2023, 9, 18, 0, 0, 0, tzinfo=pdt) < now < timezone.datetime(2023, 9, 19, 0, 0, 0, tzinfo=pdt), # Second, 24hs
timezone.datetime(2023, 10, 2, 0, 0, 0, tzinfo=pdt) < now < timezone.datetime(2023, 10, 4, 0, 0, 0, tzinfo=pdt), # Third, 48hs
timezone.datetime(2023, 10, 16, 0, 0, 0, tzinfo=pdt) < now, # Fully removal
])
# fmt: on

if settings.RTD_ENFORCE_BROWNOUTS_FOR_DEPRECATIONS and browndates:
build_config_key = self.data.config.source_config.get("build", {})
if "image" in build_config_key:
raise BuildUserError(BuildUserError.BUILD_IMAGE_CONFIG_KEY_DEPRECATED)

# TODO: move this validation to the Config object once we are settled here
if "image" not in build_config_key and "os" not in build_config_key:
raise BuildUserError(BuildUserError.BUILD_OS_REQUIRED)
# TODO: move this validation to the Config object once we are settled here
if "image" not in build_config_key and "os" not in build_config_key:
raise BuildUserError(BuildUserError.BUILD_OS_REQUIRED)

if self.vcs_repository.supports_submodules:
self.vcs_repository.update_submodules(self.data.config)
Expand Down

0 comments on commit ac125ee

Please sign in to comment.