mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 22:46:27 +00:00
feat(schedule): Support scheduling by weeks of year. (#3914)
Fixes #3879.
This commit is contained in:
parent
4ce426560c
commit
9212a876fc
2 changed files with 16 additions and 0 deletions
|
@ -172,6 +172,10 @@ function isScheduledNow(config) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Check for week of year
|
||||||
|
if (schedule.wy && !schedule.wy.includes(now.week())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
logger.debug(`Matches schedule ${scheduleText}`);
|
logger.debug(`Matches schedule ${scheduleText}`);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
|
@ -202,5 +202,17 @@ describe('workers/branch/schedule', () => {
|
||||||
const res = schedule.isScheduledNow(config);
|
const res = schedule.isScheduledNow(config);
|
||||||
expect(res).toBe(true);
|
expect(res).toBe(true);
|
||||||
});
|
});
|
||||||
|
it('approves valid weeks of year', () => {
|
||||||
|
config.schedule = ['every 2 weeks of the year before 08:00 on Monday'];
|
||||||
|
mockDate.set('2017-01-02T06:00:00.000'); // Locally Monday, 2 January 2017 6am (first Monday of the year)
|
||||||
|
const res = schedule.isScheduledNow(config);
|
||||||
|
expect(res).toBe(true);
|
||||||
|
});
|
||||||
|
it('rejects on weeks of year', () => {
|
||||||
|
config.schedule = ['every 2 weeks of the year before 08:00 on Monday'];
|
||||||
|
mockDate.set('2017-01-09T06:00:00.000'); // Locally Monday, 2 January 2017 6am (second Monday of the year)
|
||||||
|
const res = schedule.isScheduledNow(config);
|
||||||
|
expect(res).toBe(false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue