Skip to content

Commit d0a136c

Browse files
committed
add tests to ensure workflow crons are unique and do not run at top of the hour
1 parent 82ed7fd commit d0a136c

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

tests/unit/actions-workflows.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ function actionsUsedInWorkflow (workflow) {
1919
.map(key => get(workflow, key))
2020
}
2121

22+
const scheduledWorkflows = workflows
23+
.map(workflow => workflow.data.on.schedule)
24+
.filter(Boolean)
25+
.flat()
26+
.map(schedule => schedule.cron)
27+
2228
const allUsedActions = chain(workflows)
2329
.map(actionsUsedInWorkflow)
2430
.flatten()
@@ -38,4 +44,16 @@ describe('GitHub Actions workflows', () => {
3844
const disallowedActions = difference(allUsedActions, allowedActions)
3945
expect(disallowedActions).toEqual([])
4046
})
47+
48+
test('no scheduled workflows run on the hour', () => {
49+
const hourlySchedules = scheduledWorkflows.filter(schedule => {
50+
const hour = schedule.split(' ')[0]
51+
return hour === '0' || hour === '00'
52+
})
53+
expect(hourlySchedules).toEqual([])
54+
})
55+
56+
test('all scheduled workflows run at unique times', () => {
57+
expect(scheduledWorkflows.length).toEqual(new Set(scheduledWorkflows).size)
58+
})
4159
})

0 commit comments

Comments
 (0)