Skip to content

Commit d2f9e65

Browse files
committed
update document to describe the timezone check in on.schedule
1 parent c03b271 commit d2f9e65

3 files changed

Lines changed: 19 additions & 5 deletions

File tree

docs/checks.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ List of checks:
2424
- [Webhook events validation](#check-webhook-events)
2525
- [Workflow dispatch event validation](#check-workflow-dispatch-events)
2626
- [Glob filter pattern syntax validation](#check-glob-pattern)
27-
- [CRON syntax check at `schedule:`](#check-cron-syntax)
27+
- [CRON syntax and IANA timezone string check at `schedule:`](#check-cron-syntax-and-timezone)
2828
- [Runner labels](#check-runner-labels)
2929
- [Action format in `uses:`](#check-action-format)
3030
- [Local action inputs validation at `with:`](#check-local-action-inputs)
@@ -1564,7 +1564,7 @@ workflow. It checks:
15641564
Most common mistake I have ever seen here is a misunderstanding that regular expression is available for filtering.
15651565
This rule can catch the mistake so that users can notice their mistakes.
15661566

1567-
<a id="check-cron-syntax"></a>
1567+
<a id="check-cron-syntax-and-timezone"></a>
15681568
## CRON syntax check at `schedule:`
15691569

15701570
Example input:
@@ -1576,6 +1576,9 @@ on:
15761576
- cron: '0 */3 * *'
15771577
# ERROR: Interval of scheduled job is too small (job runs too frequently)
15781578
- cron: '* */3 * * *'
1579+
# ERROR: Timezone is not a valid IANA timezone string
1580+
- cron: '*/5 * * * *'
1581+
timezone: 'Asia/Somewhere'
15791582

15801583
jobs:
15811584
test:
@@ -1595,9 +1598,13 @@ test.yaml:6:13: scheduled job runs too frequently. it runs once per 60 seconds.
15951598
|
15961599
6 | - cron: '* */3 * * *'
15971600
| ^~
1601+
test.yaml:9:17: invalid timezone "Asia/Somewhere" in schedule event. it must be a valid IANA timezone name [events]
1602+
|
1603+
9 | timezone: 'Asia/Somewhere'
1604+
| ^~~~~~~~~~~~~~~~
15981605
```
15991606
1600-
[Playground](https://rhysd.github.io/actionlint/#eNpUjEEKAjEMRfdzir8bCLQK7nobpwYGKYk0yf0lFhezC/+9PJW2AdZPfsXgvIGCPlUa9jvo9gCB9utO/z3J9tbD8tHZfAVmiJU04wjxKOOZ7IfM+WPLyuAMaeB+Kmqt3wAAAP//hKgjxA==)
1607+
[Playground](https://rhysd.github.io/actionlint/#eNpkjUHKwjAQRvc5xbcLBJL88OMmO8/gCdo4kEqbkUyC4OllrF2Iu+G94XtckwEkF7qOlfQGPHLjmmD/4OI/HJz95u7gvyaedn4YoC8bPblSgj3LMsULb/Qo1Mgac+NZtNlJ+t5uo4rXqTGP2odfJ3VvJZ3ukj6rXj8TKBdGCOEVAAD//8YnMuQ=)
16011608
16021609
To trigger a workflow in specific interval, [scheduled event][schedule-event-doc] can be defined in [POSIX CRON syntax][cron-syntax].
16031610
@@ -1607,6 +1614,8 @@ actionlint checks the CRON syntax and frequency of running a job. [The official
16071614
16081615
When the job is run more frequently than once every 5 minutes, actionlint reports it as an error.
16091616
1617+
actionlint also checks the `timezone` configuration [is a valid IANA timezone string][schedule-item-doc].
1618+
16101619
<a id="check-runner-labels"></a>
16111620
## Runner labels
16121621

@@ -3197,6 +3206,7 @@ test.yaml:0:0: could not parse as YAML: yaml: unknown anchor 'credentials' refer
31973206
[webhook-doc]: https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#webhook-events
31983207
[schedule-event-doc]: https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#scheduled-events
31993208
[cron-syntax]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html#tag_20_25_07
3209+
[schedule-item-doc]: https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#onschedule
32003210
[gh-hosted-runner]: https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners
32013211
[self-hosted-runner]: https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners
32023212
[action-uses-doc]: https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepsuses
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
test.yaml:4:13: invalid CRON format "0 */3 * *" in schedule event: expected exactly 5 fields, found 4: [0 */3 * *] [events]
22
test.yaml:6:13: scheduled job runs too frequently. it runs once per 60 seconds. the shortest interval is once every 5 minutes [events]
3+
test.yaml:9:17: invalid timezone "Asia/Somewhere" in schedule event. it must be a valid IANA timezone name [events]

testdata/examples/cron_schedule_check.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
on:
22
schedule:
3-
# Cron syntax is not correct
3+
# ERROR: Cron syntax is not correct
44
- cron: '0 */3 * *'
5-
# Interval of scheduled job is too small (job runs too frequently)
5+
# ERROR: Interval of scheduled job is too small (job runs too frequently)
66
- cron: '* */3 * * *'
7+
# ERROR: Timezone is not a valid IANA timezone string
8+
- cron: '*/5 * * * *'
9+
timezone: 'Asia/Somewhere'
710

811
jobs:
912
test:

0 commit comments

Comments
 (0)