Skip to content

Commit ac125ee

Browse files
authored
Build: remove browndates for config file (#11012)
We are ahead of the dates for these deprecations, so they became the default path now and we have to always check for them.
1 parent bde1f43 commit ac125ee

File tree

1 file changed

+7
-38
lines changed

1 file changed

+7
-38
lines changed

readthedocs/doc_builder/director.py

+7-38
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@
1010
import os
1111
import tarfile
1212

13-
import pytz
1413
import structlog
1514
import yaml
1615
from django.conf import settings
17-
from django.utils import timezone
1816
from django.utils.translation import gettext_lazy as _
1917

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

252-
now = timezone.now()
253-
pdt = pytz.timezone("America/Los_Angeles")
254-
255-
# fmt: off
256-
# These browndates matches https://blog.readthedocs.com/use-build-os-config/
257-
browndates = any([
258-
timezone.datetime(2023, 7, 14, 0, 0, 0, tzinfo=pdt) < now < timezone.datetime(2023, 7, 14, 12, 0, 0, tzinfo=pdt), # First, 12hs
259-
timezone.datetime(2023, 8, 14, 0, 0, 0, tzinfo=pdt) < now < timezone.datetime(2023, 8, 15, 0, 0, 0, tzinfo=pdt), # Second, 24hs
260-
timezone.datetime(2023, 9, 4, 0, 0, 0, tzinfo=pdt) < now < timezone.datetime(2023, 9, 6, 0, 0, 0, tzinfo=pdt), # Third, 24hs
261-
timezone.datetime(2023, 9, 25, 0, 0, 0, tzinfo=pdt) < now, # Fully removal
262-
])
263-
# fmt: on
264-
265250
# Raise a build error if the project is not using a config file or using v1
266-
if (
267-
settings.RTD_ENFORCE_BROWNOUTS_FOR_DEPRECATIONS
268-
and browndates
269-
and self.data.config.version not in ("2", 2)
270-
):
251+
if self.data.config.version not in ("2", 2):
271252
raise BuildUserError(BuildUserError.NO_CONFIG_FILE_DEPRECATED)
272253

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

275-
# fmt: off
276-
# These browndates matches https://blog.readthedocs.com/use-build-os-config/
277-
browndates = any([
278-
timezone.datetime(2023, 8, 28, 0, 0, 0, tzinfo=pdt) < now < timezone.datetime(2023, 8, 28, 12, 0, 0, tzinfo=pdt), # First, 12hs
279-
timezone.datetime(2023, 9, 18, 0, 0, 0, tzinfo=pdt) < now < timezone.datetime(2023, 9, 19, 0, 0, 0, tzinfo=pdt), # Second, 24hs
280-
timezone.datetime(2023, 10, 2, 0, 0, 0, tzinfo=pdt) < now < timezone.datetime(2023, 10, 4, 0, 0, 0, tzinfo=pdt), # Third, 48hs
281-
timezone.datetime(2023, 10, 16, 0, 0, 0, tzinfo=pdt) < now, # Fully removal
282-
])
283-
# fmt: on
284-
285-
if settings.RTD_ENFORCE_BROWNOUTS_FOR_DEPRECATIONS and browndates:
286-
build_config_key = self.data.config.source_config.get("build", {})
287-
if "image" in build_config_key:
288-
raise BuildUserError(BuildUserError.BUILD_IMAGE_CONFIG_KEY_DEPRECATED)
289-
290-
# TODO: move this validation to the Config object once we are settled here
291-
if "image" not in build_config_key and "os" not in build_config_key:
292-
raise BuildUserError(BuildUserError.BUILD_OS_REQUIRED)
259+
# TODO: move this validation to the Config object once we are settled here
260+
if "image" not in build_config_key and "os" not in build_config_key:
261+
raise BuildUserError(BuildUserError.BUILD_OS_REQUIRED)
293262

294263
if self.vcs_repository.supports_submodules:
295264
self.vcs_repository.update_submodules(self.data.config)

0 commit comments

Comments
 (0)