github / vscode-github-actions

GitHub Actions extension for VS Code
https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-github-actions
MIT License
487 stars 85 forks source link

Says a working cron string is not valid #331

Closed peterbe closed 4 months ago

peterbe commented 4 months ago

Describe the bug

It says that 20 */24 * * * is not a valid cron schedule. (see screenshot below)

To Reproduce Steps to reproduce the behavior:

  1. https://github.com/github/docs/blob/7aacc9a619dc8d01c025340ad5934fcf688a19fd/.github/workflows/sync-search-elasticsearch.yml#L20
  2. Open this in VS Code
  3. See warning

Expected behavior

That it doesn't say it's invalid.

Screenshots

VS code warning

Extension Version Don't know how to look that up. But I think it's the latest because it automatically upgrades itself.

Additional context

I know the schedule works by looking at our Actions runs.

I used https://crontab.guru/#20_*/24_*_*_* to see if it works there.

muzimuzhi commented 4 months ago

It's the 24 in hour field of 20 */24 * * * that made the cron string invalid. Strictly speaking, the hour should be in range [0, 23].

Testing on https://crontab.guru, 20 */24 * * * can be replaced with valid 20 0 * * *.

BTW, the cron validation is done in https://github.com/actions/languageservices, file workflow-parser/src/model/converter/cron.ts. Looks like it's stricter than the validators used by https://crontab.guru and GitHub Action.

peterbe commented 4 months ago

You're right. It does say "Hour [0, 23]" in the spec. So the strictness is just a minor differences. Seems GitHub Actions is a bit more forgiving in this corner case.

I changed it on our end to your recommendation and now the validator is not showing any warnings or errors.