Skip to content

Commit

Permalink
feat(schedule): replace later with cron (#32718)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Kriese <[email protected]>
  • Loading branch information
RahulGautamSingh and viceice authored Nov 28, 2024
1 parent bde1849 commit ed8c37c
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 37 deletions.
4 changes: 3 additions & 1 deletion docs/usage/configuration-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -2463,8 +2463,9 @@ Here's an example config to limit the "noisy" `aws-sdk` package to weekly update
{
"packageRules": [
{
"description": "Schedule aws-sdk updates on Sunday nights (9 PM - 12 AM)",
"matchPackageNames": ["aws-sdk"],
"schedule": ["after 9pm on sunday"]
"schedule": ["* 21-23 * * 0"]
}
]
}
Expand Down Expand Up @@ -3843,6 +3844,7 @@ You could then configure a schedule like this at the repository level:

```json
{
"description": "Schedule on weekdays at night (10 PM - 4 AM) and anytime on weekends",
"schedule": ["* 22-23,0-4 * * *", "* * * * 0,6"]
}
```
Expand Down
13 changes: 6 additions & 7 deletions docs/usage/key-concepts/scheduling.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,15 @@ Some config examples:

```json title="Renovate should run each day before 4 am"
{
"schedule": ["before 4am"]
"description": "Schedule daily before 4 AM",
"schedule": ["* 0-3 * * *"]
}
```

```json title="Renovate should run outside of common office hours"
{
"schedule": [
"after 10pm every weekday",
"before 5am every weekday",
"every weekend"
]
"description": "Schedule during typical non-office hours on weekdays (i.e., 10 PM - 5 AM) and anytime on weekends",
"schedule": ["* 0-4,22-23 * * 1-5", "* * * * 0,6"]
}
```

Expand All @@ -121,8 +119,9 @@ The scheduling feature can be very useful for "noisy" packages that are updated
{
"packageRules": [
{
"description": "Schedule aws-sdk updates on Sunday nights (9 PM - 12 AM)",
"matchPackageNames": ["aws-sdk"],
"schedule": ["after 9pm on sunday"]
"schedule": ["* 21-23 * * 0"]
}
]
}
Expand Down
9 changes: 6 additions & 3 deletions docs/usage/noise-reduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ You don't want to get too far behind, so how about we update `eslint` packages o
{
"packageRules": [
{
"description": "Schedule updates on first day of each month",
"matchPackageNames": ["/eslint/"],
"groupName": "eslint",
"schedule": ["on the first day of the month"]
"schedule": ["* * 1 * *"]
}
]
}
Expand All @@ -105,9 +106,10 @@ Or perhaps at least weekly:
{
"packageRules": [
{
"description": "Schedule updates on Monday mornings(before 4 AM)",
"matchPackageNames": ["/eslint/"],
"groupName": "eslint",
"schedule": ["before 4am on monday"]
"schedule": ["* 0-3 * * 1"]
}
]
}
Expand Down Expand Up @@ -165,9 +167,10 @@ Let's automerge it if all the linting updates pass:
{
"packageRules": [
{
"description": "Schedule updates on Monday mornings(before 4 AM)",
"matchPackageNames": ["/eslint/"],
"groupName": "eslint",
"schedule": ["before 4am on monday"],
"schedule": ["* 0-3 * * 1"],
"automerge": true,
"automergeType": "branch"
}
Expand Down
1 change: 1 addition & 0 deletions lib/config/presets/internal/schedule.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ describe('config/presets/internal/schedule', () => {
it.each`
datetime | expected
${'2017-01-01T00:50:00.000'} | ${true}
${'2017-01-02T00:50:00.000'} | ${false}
${'2017-04-01T01:50:00.000'} | ${true}
${'2017-07-01T02:50:00.000'} | ${true}
${'2017-10-01T03:50:00.000'} | ${true}
Expand Down
54 changes: 28 additions & 26 deletions lib/config/presets/internal/schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,76 +2,77 @@ import type { Preset } from '../types';

/* eslint sort-keys: ["error", "asc", {caseSensitive: false, natural: true}] */

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',
'every weekend',
];
const quarterly = ['every 3 months on the first day of the month'];
const weekdays = ['every weekday'];
const weekends = ['every weekend'];
const yearly = ['every 12 months on the first day of the month'];
const daily = ['* 0-3 * * *'];
const earlyMondays = ['* 0-3 * * 1'];
const monthly = ['* 0-3 1 * *'];
const nonOfficeHours = ['* 0-4,22-23 * * 1-5', '* * * * 0,6'];
const quarterly = ['* * 1 */3 *'];
const weekdays = ['* * * * 1-5'];
const weekends = ['* * * * 0,6'];
const yearly = ['* * 1 */12 *'];

export const presets: Record<string, Preset> = {
automergeDaily: {
automergeSchedule: daily,
description: 'Schedule automerge daily.',
description: 'Schedule automerge daily before 4 AM.',
},
automergeEarlyMondays: {
automergeSchedule: earlyMondays,
description: 'Weekly automerge schedule on early Monday mornings.',
description: 'Schedule automerge on Monday mornings (before 4 AM).',
},
automergeMonthly: {
automergeSchedule: monthly,
description: 'Schedule automerge monthly.',
description:
'Schedule automerge for the first day of each month, before 4 AM.',
},
automergeNonOfficeHours: {
automergeSchedule: nonOfficeHours,
description:
'Schedule automerge for typical non-office hours (night time and weekends).',
'Schedule automerge during typical non-office hours on weekdays (i.e., 10 PM - 5 AM) and anytime on weekends.',
},
automergeQuarterly: {
automergeSchedule: quarterly,
description: 'Schedule automerge quarterly.',
description:
'Schedule automerge on the first day of each quarter (i.e., January, April, July, October).',
},
automergeWeekdays: {
automergeSchedule: weekdays,
description: 'Schedule automerge for weekdays.',
description: 'Schedule automerge anytime on weekdays.',
},
automergeWeekends: {
automergeSchedule: weekends,
description: 'Schedule automerge for weekends.',
description: 'Schedule automerge anytime on weekends.',
},
automergeWeekly: {
description: 'Schedule automerge weekly.',
extends: ['schedule:automergeEarlyMondays'],
},
automergeYearly: {
automergeSchedule: yearly,
description: 'Schedule automerge once a year (not recommended).',
description:
'Schedule automerge once a year on the first day of January (not recommended).',
},
daily: {
description: 'Schedule daily.',
description: 'Schedule daily before 4 AM.',
schedule: daily,
},
earlyMondays: {
description: 'Weekly schedule on early Monday mornings.',
description: 'Weekly schedule on early Monday mornings (before 4 AM).',
schedule: earlyMondays,
},
monthly: {
description: 'Schedule monthly.',
description:
'Schedule once a month on the first day of the month before 4 AM.',
schedule: monthly,
},
nonOfficeHours: {
description:
'Schedule for typical non-office hours (night time and weekends).',
'Schedule during typical non-office hours on weekdays (i.e., 10 PM - 5 AM) and anytime on weekends.',
schedule: nonOfficeHours,
},
quarterly: {
description: 'Schedule quarterly.',
description:
'Schedule on the first day of each quarter (i.e., January, April, July, October).',
schedule: quarterly,
},
weekdays: {
Expand All @@ -87,7 +88,8 @@ export const presets: Record<string, Preset> = {
extends: ['schedule:earlyMondays'],
},
yearly: {
description: 'Schedule once a year (not recommended).',
description:
'Schedule once a year on the first day of January (not recommended).',
schedule: yearly,
},
};

0 comments on commit ed8c37c

Please sign in to comment.