Skip to content

Commit c03b271

Browse files
committed
Merge branch 'followup-issue641' (#641)
2 parents 4897c1d + c9efd91 commit c03b271

7 files changed

Lines changed: 38 additions & 16 deletions

File tree

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ cov: coverage.out coverage.html
4949

5050
.linttimestamp: $(TESTS) $(SRCS) $(TOOL) docs/checks.md
5151
go vet ./...
52-
staticcheck ./...
52+
# ./... is not available because ./playground/node_dodules/ contains some Go packages
53+
staticcheck ./ ./scripts/... ./cmd/...
5354
govulncheck ./...
5455
ifneq ($(OS),Windows_NT)
5556
GOOS=js GOARCH=wasm staticcheck ./playground

cmd/actionlint/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"os"
55

66
"github.com/rhysd/actionlint"
7+
8+
_ "time/tzdata"
79
)
810

911
func main() {

parse.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,9 @@ func (p *parser) parseScheduleEvent(pos *Pos, n *yaml.Node) *ScheduledEvent {
393393
entry.Cron = s
394394
}
395395
case "timezone":
396-
entry.Timezone = p.parseString(e.val, false)
396+
if s := p.parseString(e.val, false); s.Value != "" {
397+
entry.Timezone = s
398+
}
397399
default:
398400
p.unexpectedKey(e.key, "element of \"schedule\" section", []string{"cron", "timezone"})
399401
}

rule_events.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,14 @@ func (rule *RuleEvents) checkCron(spec *String) {
8181

8282
// https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#onschedule
8383
func (rule *RuleEvents) checkTimezone(tz *String) {
84-
if _, err := time.LoadLocation(tz.Value); err != nil {
85-
rule.Errorf(tz.Pos, "invalid timezone %q in schedule event. It must be a valid IANA timezone name", tz.Value)
84+
// `time.LoadLocation` accepts special values "", "UTC", and "Local" but they are not correct IANA timezone names.
85+
ok := tz.Value != "" && !strings.EqualFold(tz.Value, "utc") && !strings.EqualFold(tz.Value, "local")
86+
if ok {
87+
_, err := time.LoadLocation(tz.Value)
88+
ok = err == nil
89+
}
90+
if !ok {
91+
rule.Errorf(tz.Pos, "invalid timezone %q in schedule event. it must be a valid IANA timezone name", tz.Value)
8692
}
8793
}
8894

scripts/generate-actionlint-matcher/test.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ for (const parent of ['examples', 'err']) {
3838
if (line.length === 0 || line.startsWith('/')) {
3939
continue
4040
}
41-
const msg = `Line '${line}' did not match to the regex`
41+
const msg = `Line '${line}' did not match to the regex ${regexp}`
4242
const m = line.match(regexp);
4343
assert.ok(m, msg); // not null
4444
assert.equal('test.yaml', m[pattern.file], msg);
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
test.yaml:4:17: invalid timezone "Not/A/Timezone" in schedule event. It must be a valid IANA timezone name [events]
1+
test.yaml:4:17: invalid timezone "Not/A/Timezone" in schedule event. it must be a valid IANA timezone name [events]
2+
test.yaml:6:17: invalid timezone "UTC" in schedule event. it must be a valid IANA timezone name [events]
3+
test.yaml:8:17: invalid timezone "local" in schedule event. it must be a valid IANA timezone name [events]
4+
test.yaml:10:17: string should not be empty [syntax-check]
5+
test.yaml:11:13: string should not be empty [syntax-check]
Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1-
on:
2-
schedule:
3-
- cron: '*/5 * * * *'
4-
timezone: "Not/A/Timezone"
5-
6-
jobs:
7-
test:
8-
runs-on: ubuntu-latest
9-
steps:
10-
- run: echo hello
1+
on:
2+
schedule:
3+
- cron: '*/5 * * * *'
4+
timezone: 'Not/A/Timezone'
5+
- cron: '*/5 * * * *'
6+
timezone: 'UTC'
7+
- cron: '*/5 * * * *'
8+
timezone: 'local'
9+
- cron: '*/5 * * * *'
10+
timezone: ''
11+
- cron: ''
12+
13+
jobs:
14+
test:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- run: echo hello

0 commit comments

Comments
 (0)