Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use UTC as default timezone when schedule Actions cron tasks #31742

Merged
merged 6 commits into from
Aug 1, 2024

Conversation

wolfogre
Copy link
Member

@wolfogre wolfogre commented Jul 31, 2024

Fix #31657.

According to the doc of GitHub Actions, The timezone for cron should be UTC, not the local timezone. And Gitea Actions doesn't have any reasons to change this, so I think it's a bug.

However, Gitea Actions has extended the syntax, as it supports descriptors like @weekly and @every 5m, and supports specifying the timezone like TZ=UTC 0 10 * * *. So we can make it use UTC only when the timezone is not specified, to be compatible with GitHub Actions, and also respect the user's specified.

It does break the feature because the times to run tasks would be changed, and it may confuse users. So I don't think we should backport this.

⚠️ BREAKING ⚠️

If the server's local time zone is not UTC, a scheduled task would run at a different time after upgrading Gitea to this version.

@wolfogre wolfogre added type/bug pr/breaking Merging this PR means builds will break. Needs a description what exactly breaks, and how to fix it! topic/gitea-actions related to the actions of Gitea labels Jul 31, 2024
@wolfogre wolfogre added this to the 1.23.0 milestone Jul 31, 2024
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 31, 2024
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 31, 2024
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Jul 31, 2024
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Aug 1, 2024
}

// If the spec has specified a timezone, use it
if strings.HasPrefix(s.Spec, "TZ=") || strings.HasPrefix(s.Spec, "CRON_TZ=") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we handle leading whitespace?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not "we", it's how "robfig/cron" handle this.

https://github.com/robfig/cron/blob/bc59245fe10efaed9d51b56900192527ed733435/parser.go#L95

If we want to handle leading whitespace, it could be done before storing it into the database.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Aug 1, 2024
@wolfogre wolfogre added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Aug 1, 2024
@wolfogre wolfogre enabled auto-merge (squash) August 1, 2024 09:31
@wolfogre wolfogre merged commit 21a73ae into go-gitea:main Aug 1, 2024
26 checks passed
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Aug 1, 2024
zjjhot added a commit to zjjhot/gitea that referenced this pull request Aug 2, 2024
* giteaofficial/main:
  Clear up old Actions logs (go-gitea#31735)
  Fix createElementFromAttrs bug (go-gitea#31751)
  bump vue-bar-graph (go-gitea#31705)
  Use UTC as default timezone when schedule Actions cron tasks (go-gitea#31742)
  Add permission description for API to add repo collaborator (go-gitea#31744)
  Clarify Actions resources ownership (go-gitea#31724)
  Exclude protected branches from recently pushed (go-gitea#31748)
  [skip ci] Updated translations via Crowdin
  Distinguish LFS object errors to ignore missing objects during migration (go-gitea#31702)
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Oct 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/go Pull requests that update Go code pr/breaking Merging this PR means builds will break. Needs a description what exactly breaks, and how to fix it! size/L Denotes a PR that changes 100-499 lines, ignoring generated files. topic/gitea-actions related to the actions of Gitea type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Actions workflow schedule to support UTC
4 participants