From 6e17128eb99cd8c88055ffc667d2e8a9af015b1a Mon Sep 17 00:00:00 2001
From: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
Date: Mon, 29 May 2023 09:45:54 +0200
Subject: [PATCH] feat(presets): timed presets give Renovate 4 hours to create
 branches (#22466)

---
 docs/usage/configuration-options.md                   | 2 +-
 docs/usage/faq.md                                     | 2 +-
 docs/usage/key-concepts/scheduling.md                 | 4 ++--
 docs/usage/noise-reduction.md                         | 4 ++--
 lib/config/options/index.ts                           | 2 +-
 lib/config/presets/internal/schedule.ts               | 6 +++---
 lib/workers/repository/update/branch/schedule.spec.ts | 6 +++---
 lib/workers/repository/update/branch/schedule.ts      | 4 ++--
 8 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md
index d26d31e7c1..c9010b177a 100644
--- a/docs/usage/configuration-options.md
+++ b/docs/usage/configuration-options.md
@@ -1695,7 +1695,7 @@ If you wish to enable this feature then you could add this to your configuration
 }
 ```
 
-To reduce "noise" in the repository, it defaults its schedule to `"before 5am on monday"`, i.e. to achieve once-per-week semantics.
+To reduce "noise" in the repository, it defaults its schedule to `"before 4am on monday"`, i.e. to achieve once-per-week semantics.
 Depending on its running schedule, Renovate may run a few times within that time window - even possibly updating the lock file more than once - but it hopefully leaves enough time for tests to run and automerge to apply, if configured.
 
 ## major
diff --git a/docs/usage/faq.md b/docs/usage/faq.md
index bfe5902dab..fcbd189467 100644
--- a/docs/usage/faq.md
+++ b/docs/usage/faq.md
@@ -154,7 +154,7 @@ Set configuration option `rangeStrategy` to `"replace"`.
 
 ### Keep lock files (including sub-dependencies) up-to-date, even when `package.json` hasn't changed
 
-By default, if you enable lock-file maintenance, Renovate will update the lockfile `["before 5am on monday"]`.
+By default, if you enable lock-file maintenance, Renovate will update the lockfile `["before 4am on monday"]`.
 If you want to update the lock file more often, set the `schedule` field inside the `lockFileMaintenance` object.
 
 ### Wait until tests have passed before creating the PR
diff --git a/docs/usage/key-concepts/scheduling.md b/docs/usage/key-concepts/scheduling.md
index c4589279e1..5ba8141457 100644
--- a/docs/usage/key-concepts/scheduling.md
+++ b/docs/usage/key-concepts/scheduling.md
@@ -93,11 +93,11 @@ If you use the GitHub hosted app, the default is that Renovate will always be al
 Be sure to schedule enough time for Renovate to process your repository.
 Do not set schedules like "Run Renovate for an hour each Sunday" as you _will_ run into problems.
 
-Say you want Renovate bot to run each day before 2 am:
+Say you want Renovate to run each day before 4 am:
 
 ```json
 {
-  "schedule": ["before 2am"]
+  "schedule": ["before 4am"]
 }
 ```
 
diff --git a/docs/usage/noise-reduction.md b/docs/usage/noise-reduction.md
index 01cb980557..6132878cdf 100644
--- a/docs/usage/noise-reduction.md
+++ b/docs/usage/noise-reduction.md
@@ -107,7 +107,7 @@ Or perhaps at least weekly:
     {
       "matchPackagePatterns": ["eslint"],
       "groupName": "eslint",
-      "schedule": ["before 2am on monday"]
+      "schedule": ["before 4am on monday"]
     }
   ]
 }
@@ -167,7 +167,7 @@ Let's automerge it if all the linting updates pass:
     {
       "matchPackagePatterns": ["eslint"],
       "groupName": "eslint",
-      "schedule": ["before 2am on monday"],
+      "schedule": ["before 4am on monday"],
       "automerge": true,
       "automergeType": "branch"
     }
diff --git a/lib/config/options/index.ts b/lib/config/options/index.ts
index b4d072920a..2d5009f81a 100644
--- a/lib/config/options/index.ts
+++ b/lib/config/options/index.ts
@@ -1905,7 +1905,7 @@ const options: RenovateOptions[] = [
       commitMessageAction: 'Lock file maintenance',
       commitMessageTopic: null,
       commitMessageExtra: null,
-      schedule: ['before 5am on monday'],
+      schedule: ['before 4am on monday'],
       groupName: null,
       prBodyDefinitions: {
         Change: 'All locks refreshed',
diff --git a/lib/config/presets/internal/schedule.ts b/lib/config/presets/internal/schedule.ts
index 3a927d5add..1f5eb5de94 100644
--- a/lib/config/presets/internal/schedule.ts
+++ b/lib/config/presets/internal/schedule.ts
@@ -2,9 +2,9 @@ import type { Preset } from '../types';
 
 /* eslint sort-keys: ["error", "asc", {caseSensitive: false, natural: true}] */
 
-const daily = ['before 2am'];
-const earlyMondays = ['before 3am on Monday'];
-const monthly = ['before 3am on the first day of the month'];
+const daily = ['before 4am'];
+const earlyMondays = ['before 4am on Monday'];
+const monthly = ['before 4am on the first day of the month'];
 const nonOfficeHours = [
   'after 10pm every weekday',
   'before 5am every weekday',
diff --git a/lib/workers/repository/update/branch/schedule.spec.ts b/lib/workers/repository/update/branch/schedule.spec.ts
index f8e75be82e..24b8995c46 100644
--- a/lib/workers/repository/update/branch/schedule.spec.ts
+++ b/lib/workers/repository/update/branch/schedule.spec.ts
@@ -115,7 +115,7 @@ describe('workers/repository/update/branch/schedule', () => {
     it('massages schedules', () => {
       expect(
         schedule.hasValidSchedule([
-          'before 3am on the first day of the month',
+          'before 5am on the first day of the month',
         ])[0]
       ).toBeTrue();
       expect(schedule.hasValidSchedule(['every month'])[0]).toBeTrue();
@@ -268,8 +268,8 @@ describe('workers/repository/update/branch/schedule', () => {
         sched                     | tz                  | datetime                          | expected
         ${'after 4pm'}            | ${'Asia/Singapore'} | ${'2017-06-30T15:59:00.000+0800'} | ${false}
         ${'after 4pm'}            | ${'Asia/Singapore'} | ${'2017-06-30T16:01:00.000+0800'} | ${true}
-        ${'before 3am on Monday'} | ${'Asia/Tokyo'}     | ${'2017-06-26T02:59:00.000+0900'} | ${true}
-        ${'before 3am on Monday'} | ${'Asia/Tokyo'}     | ${'2017-06-26T03:01:00.000+0900'} | ${false}
+        ${'before 4am on Monday'} | ${'Asia/Tokyo'}     | ${'2017-06-26T03:59:00.000+0900'} | ${true}
+        ${'before 4am on Monday'} | ${'Asia/Tokyo'}     | ${'2017-06-26T04:01:00.000+0900'} | ${false}
       `('$sched, $tz, $datetime', ({ sched, tz, datetime, expected }) => {
         config.schedule = [sched];
         config.timezone = tz;
diff --git a/lib/workers/repository/update/branch/schedule.ts b/lib/workers/repository/update/branch/schedule.ts
index 279da36b4e..938362f8e2 100644
--- a/lib/workers/repository/update/branch/schedule.ts
+++ b/lib/workers/repository/update/branch/schedule.ts
@@ -9,8 +9,8 @@ import { logger } from '../../../../logger';
 const minutesChar = '*';
 
 const scheduleMappings: Record<string, string> = {
-  'every month': 'before 3am on the first day of the month',
-  monthly: 'before 3am on the first day of the month',
+  'every month': 'before 5am on the first day of the month',
+  monthly: 'before 5am on the first day of the month',
 };
 
 export function hasValidTimezone(timezone: string): [true] | [false, string] {
-- 
GitLab