1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-11-30 08:06:52 +02:00
woodpecker/server/cron/cron.go

144 lines
3.7 KiB
Go
Raw Normal View History

// Copyright 2022 Woodpecker Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package cron
import (
"context"
"fmt"
"time"
"github.com/robfig/cron"
"github.com/rs/zerolog/log"
"go.woodpecker-ci.org/woodpecker/v2/server/forge"
"go.woodpecker-ci.org/woodpecker/v2/server/model"
"go.woodpecker-ci.org/woodpecker/v2/server/pipeline"
"go.woodpecker-ci.org/woodpecker/v2/server/store"
)
const (
// checkTime specifies the interval woodpecker checks for new crons to exec
checkTime = 10 * time.Second
// checkItems specifies the batch size of crons to retrieve per check from database
checkItems = 10
)
// Start starts the cron scheduler loop
func Start(ctx context.Context, store store.Store, forge forge.Forge) error {
for {
select {
case <-ctx.Done():
return nil
case <-time.After(checkTime):
go func() {
now := time.Now()
log.Trace().Msg("cron: fetch next crons")
crons, err := store.CronListNextExecute(now.Unix(), checkItems)
if err != nil {
log.Error().Err(err).Int64("now", now.Unix()).Msg("obtain cron list")
return
}
for _, cron := range crons {
Update golang (packages) (#3564) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [github.com/cenkalti/backoff/v4](https://togithub.com/cenkalti/backoff) | `v4.2.1` -> `v4.3.0` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fcenkalti%2fbackoff%2fv4/v4.3.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fcenkalti%2fbackoff%2fv4/v4.3.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fcenkalti%2fbackoff%2fv4/v4.2.1/v4.3.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fcenkalti%2fbackoff%2fv4/v4.2.1/v4.3.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [github.com/charmbracelet/huh/spinner](https://togithub.com/charmbracelet/huh) | `v0.0.0-20240306161957-71f31c155b08` -> `v0.3.0` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fcharmbracelet%2fhuh%2fspinner/v0.3.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fcharmbracelet%2fhuh%2fspinner/v0.3.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fcharmbracelet%2fhuh%2fspinner/v0.0.0-20240306161957-71f31c155b08/v0.3.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fcharmbracelet%2fhuh%2fspinner/v0.0.0-20240306161957-71f31c155b08/v0.3.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [github.com/distribution/reference](https://togithub.com/distribution/reference) | `v0.5.0` -> `v0.6.0` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fdistribution%2freference/v0.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fdistribution%2freference/v0.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fdistribution%2freference/v0.5.0/v0.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fdistribution%2freference/v0.5.0/v0.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [github.com/expr-lang/expr](https://togithub.com/expr-lang/expr) | `v1.16.2` -> `v1.16.3` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fexpr-lang%2fexpr/v1.16.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fexpr-lang%2fexpr/v1.16.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fexpr-lang%2fexpr/v1.16.2/v1.16.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fexpr-lang%2fexpr/v1.16.2/v1.16.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [github.com/go-sql-driver/mysql](https://togithub.com/go-sql-driver/mysql) | `v1.8.0` -> `v1.8.1` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fgo-sql-driver%2fmysql/v1.8.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fgo-sql-driver%2fmysql/v1.8.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fgo-sql-driver%2fmysql/v1.8.0/v1.8.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fgo-sql-driver%2fmysql/v1.8.0/v1.8.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>cenkalti/backoff (github.com/cenkalti/backoff/v4)</summary> ### [`v4.3.0`](https://togithub.com/cenkalti/backoff/compare/v4.2.1...v4.3.0) [Compare Source](https://togithub.com/cenkalti/backoff/compare/v4.2.1...v4.3.0) </details> <details> <summary>charmbracelet/huh (github.com/charmbracelet/huh/spinner)</summary> ### [`v0.3.0`](https://togithub.com/charmbracelet/huh/releases/tag/v0.3.0) [Compare Source](https://togithub.com/charmbracelet/huh/compare/v0.2.3...v0.3.0) ### Scrolling, autocomplete, smaller binaries and more! This is a big release with a tonne of new features. - Scrollable Forms - Scrollable Selects and Multi selects - Autocomplete for inputs - 7x smaller binaries - Multi select filtering - Lotsa' bugfixes and quality-of-life improvements To upgrade to `huh` v0.3.0: ```bash go get -u github.com/charmbracelet/huh@latest ``` For details read on! #### Scrollable forms If a form is in a small terminal it will automatically resize to fit the available space and the active group will scroll to stay in view. Form heights can also be set manually with the new [`WithHeight`](https://pkg.go.dev/github.com/charmbracelet/huh@v0.3.0#Form.WithHeight) method. <img width="800" src="https://vhs.charm.sh/vhs-1krvQFrEFaf3H1h7jbQomc.gif" alt="Made with VHS"> #### Select and Multi select Scrolling Select and Multi select fields can now be restricted to a certain height, allowing their options to be scrollable. This means you can now pack in tonnes of options. To make a `Select` or `MultiSelect` scrollable simply set the height on the field or form through the `Height` method. ```go s := huh.NewSelect() .Title("What’s for dinner?") .Options(/* ... */) .Height(height) ``` <img width="600" src="https://vhs.charm.sh/vhs-7vcNAV9T20oeMFraAFd0B7.gif" alt="Made with VHS"> #### Autocomplete Now `Input`s can offer suggestions making it easier for users to fill out inputs. These suggestions can be accepted autocomplete-style with a configurable key binding (which defaults to <kbd>ctrl+e</kbd>). Simply provide a `[]string` to `Suggestions` to enable this feature. ```go huh.NewInput(). Title("What's for lunch?"). Prompt("? "). Suggestions([]string{ "Artichoke", // ... "Cashew Apple", "Cashews", "Cat Food", "Coconut Milk", "Cucumber", "Curry Paste", "Currywurst", // ... }) ``` <img width="600" src="https://vhs.charm.sh/vhs-49L7gt948FkJxfTzfa2qmE.gif" alt="Made with VHS"> #### More helpful help Forms will automatically adjust their help text to indicate to the user whether the form will continue or submit on actions. This works with hidden groups. In the below example, the user will be asked to list their allergies if they select "Yes" otherwise, the form will submit. <img width="600" src="https://vhs.charm.sh/vhs-7skg7qpQYCMG2Y5Vl751si.gif" alt="Made with VHS"> #### Way smaller binaries Huh now produces way smaller binaries! Thanks to [#&#8203;94](https://togithub.com/charmbracelet/huh/issues/94) Huh now has a 7x smaller compiled footprint. Before, using `huh@v0.2.3`: 33M ./burger After, using `huh@v0.3.0`: 4.5M ./burger #### Thanks, Vitor! Special thanks to the intrepid [@&#8203;vitor-mariano](https://togithub.com/vitor-mariano), one of the earliest `huh` contributors, who came in hot with features, fixes, improvements and good vibes. Thank you, Vitor! #### Changelog ##### New - scrollable multi-select by [@&#8203;meowgorithm](https://togithub.com/meowgorithm) in [https://github.com/charmbracelet/huh/pull/71](https://togithub.com/charmbracelet/huh/pull/71) - scrollable select by [@&#8203;meowgorithm](https://togithub.com/meowgorithm) in [https://github.com/charmbracelet/huh/pull/76](https://togithub.com/charmbracelet/huh/pull/76) - feat: enable filtering on MultiSelect by [@&#8203;vitor-mariano](https://togithub.com/vitor-mariano) in [https://github.com/charmbracelet/huh/pull/81](https://togithub.com/charmbracelet/huh/pull/81) - skippable Fields by [@&#8203;maaslalani](https://togithub.com/maaslalani) in [https://github.com/charmbracelet/huh/pull/116](https://togithub.com/charmbracelet/huh/pull/116) - autocomplete suggestions on inputs by [@&#8203;maaslalani](https://togithub.com/maaslalani) in [https://github.com/charmbracelet/huh/pull/93](https://togithub.com/charmbracelet/huh/pull/93) - scroll form Inputs by [@&#8203;maaslalani](https://togithub.com/maaslalani) in [https://github.com/charmbracelet/huh/pull/95](https://togithub.com/charmbracelet/huh/pull/95) - next / previous dynamic help by [@&#8203;maaslalani](https://togithub.com/maaslalani) in [https://github.com/charmbracelet/huh/pull/104](https://togithub.com/charmbracelet/huh/pull/104) - reduce binary size by [@&#8203;maaslalani](https://togithub.com/maaslalani) in [https://github.com/charmbracelet/huh/pull/94](https://togithub.com/charmbracelet/huh/pull/94) ##### Fixed - fix Select and MultiSelect height when unfocused by [@&#8203;vitor-mariano](https://togithub.com/vitor-mariano) in [https://github.com/charmbracelet/huh/pull/80](https://togithub.com/charmbracelet/huh/pull/80) - use CharLimit in textinput by [@&#8203;maaslalani](https://togithub.com/maaslalani) in [https://github.com/charmbracelet/huh/pull/79](https://togithub.com/charmbracelet/huh/pull/79) - select viewport on filtering by [@&#8203;vitor-mariano](https://togithub.com/vitor-mariano) in [https://github.com/charmbracelet/huh/pull/84](https://togithub.com/charmbracelet/huh/pull/84) - set default theme on inputs by [@&#8203;maaslalani](https://togithub.com/maaslalani) in [https://github.com/charmbracelet/huh/pull/92](https://togithub.com/charmbracelet/huh/pull/92) - multiselect: set height in WithHeight by [@&#8203;ardnew](https://togithub.com/ardnew) in [https://github.com/charmbracelet/huh/pull/118](https://togithub.com/charmbracelet/huh/pull/118) - shift+tab would fail if first group is hidden by [@&#8203;caarlos0](https://togithub.com/caarlos0) in [https://github.com/charmbracelet/huh/pull/103](https://togithub.com/charmbracelet/huh/pull/103) - prevField should not select skippable fields by [@&#8203;maaslalani](https://togithub.com/maaslalani) in [https://github.com/charmbracelet/huh/pull/121](https://togithub.com/charmbracelet/huh/pull/121) **Full Changelog**: https://github.com/charmbracelet/huh/compare/v0.2.3...v0.3.0 *** <a href="https://charm.sh/"><img alt="The Charm logo" src="https://stuff.charm.sh/charm-badge.jpg" width="400"></a> Thoughts? Questions? We love hearing from you. Feel free to reach out on [Twitter](https://twitter.com/charmcli), [The Fediverse](https://mastodon.technology/@&#8203;charm), or on [Discord](https://charm.sh/chat). ### [`v0.2.3`](https://togithub.com/charmbracelet/huh/releases/tag/v0.2.3) [Compare Source](https://togithub.com/charmbracelet/huh/compare/v0.2.2...v0.2.3) #### Better Defaults! Huh? `v0.2.3` fixes some bugs for more consistent behaviour across inputs 🐞 - `Text` inputs now update values on each keystroke rather than on `Blur` for consistency. - `Select` and `MultiSelect` read their default values from the initial values set by the `Value` variable if provided. A *special* thanks to [@&#8203;vitor-mariano](https://togithub.com/vitor-mariano) for all his contributions to this release 🤗 ##### Defaults Example You can now have preselected options by declaring them in the `Value` variable: ```go var toppings = []string{"Lettuce", "Tomatoes"} var options = huh.NewOptions("Lettuce", "Tomatoes", "Charm Sauce", "Cheese", "Vegan Cheese") huh.NewMultiSelect[string]().Title("Toppings").Options(options...).Value(&toppings).Run() ``` In the above example, `Lettuce` and `Tomatoes` will be preselected by default. #### What's Changed - `Text` value updates by [@&#8203;vitor-mariano](https://togithub.com/vitor-mariano) in [https://github.com/charmbracelet/huh/pull/64](https://togithub.com/charmbracelet/huh/pull/64) - Prefill `Select` and `MultiSelect` inputs with default values by [@&#8203;vitor-mariano](https://togithub.com/vitor-mariano) in [https://github.com/charmbracelet/huh/pull/62](https://togithub.com/charmbracelet/huh/pull/62) **Full Changelog**: https://github.com/charmbracelet/huh/compare/v0.2.2...v0.2.3 *** <a href="https://charm.sh/"><img alt="The Charm logo" src="https://stuff.charm.sh/charm-badge.jpg" width="400"></a> Thoughts? Questions? We love hearing from you. Feel free to reach out on [Twitter](https://twitter.com/charmcli), [The Fediverse](https://mastodon.technology/@&#8203;charm), or on [Discord](https://charm.sh/chat). ### [`v0.2.2`](https://togithub.com/charmbracelet/huh/releases/tag/v0.2.2) [Compare Source](https://togithub.com/charmbracelet/huh/compare/v0.2.1...v0.2.2) #### Better Wrapping 🎁 `Huh?` v0.2.2 improves wrapping of the `Input` and `Text` fields. It applies width set on the form to the inputs to perform wrapping based on the specified or terminal width. - Fixed in [https://github.com/charmbracelet/huh/pull/60](https://togithub.com/charmbracelet/huh/pull/60) #### New Contributors - [@&#8203;ddddddO](https://togithub.com/ddddddO) made their first contribution in [https://github.com/charmbracelet/huh/pull/56](https://togithub.com/charmbracelet/huh/pull/56) - [@&#8203;vitor-mariano](https://togithub.com/vitor-mariano) made their first contribution in [https://github.com/charmbracelet/huh/pull/57](https://togithub.com/charmbracelet/huh/pull/57) **Full Changelog**: https://github.com/charmbracelet/huh/compare/v0.2.1...v0.2.2 *** <a href="https://charm.sh/"><img alt="The Charm logo" src="https://stuff.charm.sh/charm-badge.jpg" width="400"></a> Thoughts? Questions? We love hearing from you. Feel free to reach out on [Twitter](https://twitter.com/charmcli), [The Fediverse](https://mastodon.social/@&#8203;charmcli), or [Discord](https://charm.sh/chat). ### [`v0.2.1`](https://togithub.com/charmbracelet/huh/releases/tag/v0.2.1) [Compare Source](https://togithub.com/charmbracelet/huh/compare/v0.2.0...v0.2.1) ### New Theme! 😸 `huh?` forms can now use Catppuccin themes. (Thanks to the wonderful [@&#8203;sgoudham](https://togithub.com/sgoudham) ✨) Simply add the following to your `huh.Form`s: ```go .WithTheme(huh.ThemeCatppuccin()) ``` <img width="500" src="https://github.com/charmbracelet/huh/assets/42545625/fdea4eb5-fa3b-472c-8aa4-9537e9577ab5" /> *** <a href="https://charm.sh/"><img alt="The Charm logo" src="https://stuff.charm.sh/charm-badge.jpg" width="400"></a> Thoughts? Questions? We love hearing from you. Feel free to reach out on [Twitter](https://twitter.com/charmcli), [The Fediverse](https://mastodon.social/@&#8203;charmcli), or [Discord](https://charm.sh/chat). ### [`v0.2.0`](https://togithub.com/charmbracelet/huh/releases/tag/v0.2.0) [Compare Source](https://togithub.com/charmbracelet/huh/compare/v0.1.0...v0.2.0) ### Better Help Styles! `Help` Styles now apply on a `Theme` rather than embedded in `FieldStyles`. (Thanks to the wonderful [@&#8203;jolheiser](https://togithub.com/jolheiser) ✨) ```go // Old... theme.Focused.Help.ShortKey = lipgloss.NewStyle() //... // Updated! theme.Help.ShortKey = lipgloss.NewStyle() //... ``` *** <a href="https://charm.sh/"><img alt="The Charm logo" src="https://stuff.charm.sh/charm-badge.jpg" width="400"></a> Thoughts? Questions? We love hearing from you. Feel free to reach out on [Twitter](https://twitter.com/charmcli), [The Fediverse](https://mastodon.social/@&#8203;charmcli), or [Discord](https://charm.sh/chat). </details> <details> <summary>distribution/reference (github.com/distribution/reference)</summary> ### [`v0.6.0`](https://togithub.com/distribution/reference/releases/tag/v0.6.0) [Compare Source](https://togithub.com/distribution/reference/compare/v0.5.0...v0.6.0) #### What's Changed - remove deprecated SplitHostname by [@&#8203;thaJeztah](https://togithub.com/thaJeztah) in [https://github.com/distribution/reference/pull/5](https://togithub.com/distribution/reference/pull/5) - refactor splitDockerDomain to include more documentation by [@&#8203;thaJeztah](https://togithub.com/thaJeztah) in [https://github.com/distribution/reference/pull/7](https://togithub.com/distribution/reference/pull/7) - fix typo in readme by [@&#8203;xrstf](https://togithub.com/xrstf) in [https://github.com/distribution/reference/pull/10](https://togithub.com/distribution/reference/pull/10) - Exclude domain from name length check by [@&#8203;ozairasim](https://togithub.com/ozairasim) in [https://github.com/distribution/reference/pull/9](https://togithub.com/distribution/reference/pull/9) #### New Contributors - [@&#8203;xrstf](https://togithub.com/xrstf) made their first contribution in [https://github.com/distribution/reference/pull/10](https://togithub.com/distribution/reference/pull/10) - [@&#8203;ozairasim](https://togithub.com/ozairasim) made their first contribution in [https://github.com/distribution/reference/pull/9](https://togithub.com/distribution/reference/pull/9) **Full Changelog**: https://github.com/distribution/reference/compare/v0.5.0...v0.6.0 </details> <details> <summary>expr-lang/expr (github.com/expr-lang/expr)</summary> ### [`v1.16.3`](https://togithub.com/expr-lang/expr/releases/tag/v1.16.3) [Compare Source](https://togithub.com/expr-lang/expr/compare/v1.16.2...v1.16.3) **Expr** is a Go-centric expression language designed to deliver dynamic configurations with unparalleled accuracy, safety, and speed. ```go program, err := expr.Compile(`let x = 2 + 2; x ^ x`) output, err := expr.Run(program, env) ``` **In this release**: - Improved printing for maps: `{(foo + bar): 42}` **Expr Editor** The [Expr Editor](https://expr-lang.org/editor) is an embeddable code editor written in JavaScript with full support of Expr language. **Expr Pro** [Expr Pro](https://expr-lang.org/expr-pro) is a set of extensions for Expr for advanced use cases. It includes expressions explanation, performance profiling, and more. </details> <details> <summary>go-sql-driver/mysql (github.com/go-sql-driver/mysql)</summary> ### [`v1.8.1`](https://togithub.com/go-sql-driver/mysql/releases/tag/v1.8.1) [Compare Source](https://togithub.com/go-sql-driver/mysql/compare/v1.8.0...v1.8.1) #### What's Changed Bugfixes: - fix race condition when context is canceled in [#&#8203;1562](https://togithub.com/go-sql-driver/mysql/pull/1562) and [#&#8203;1570](https://togithub.com/go-sql-driver/mysql/pull/1570) **Full Changelog**: https://github.com/go-sql-driver/mysql/compare/v1.8.0...v1.8.1 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "before 4am" (UTC), Automerge - "before 4am" (UTC). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/woodpecker-ci/woodpecker). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNjkuMiIsInVwZGF0ZWRJblZlciI6IjM3LjI2OS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: qwerty287 <qwerty287@posteo.de>
2024-03-29 10:21:54 +02:00
if err := runCron(ctx, store, forge, cron, now); err != nil {
log.Error().Err(err).Int64("cronID", cron.ID).Msg("run cron failed")
}
}
}()
}
}
}
// CalcNewNext parses a cron string and calculates the next exec time based on it
func CalcNewNext(schedule string, now time.Time) (time.Time, error) {
// remove local timezone
now = now.UTC()
// TODO: allow the users / the admin to set a specific timezone
c, err := cron.Parse(schedule)
if err != nil {
return time.Time{}, fmt.Errorf("cron parse schedule: %w", err)
}
return c.Next(now), nil
}
Update golang (packages) (#3564) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [github.com/cenkalti/backoff/v4](https://togithub.com/cenkalti/backoff) | `v4.2.1` -> `v4.3.0` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fcenkalti%2fbackoff%2fv4/v4.3.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fcenkalti%2fbackoff%2fv4/v4.3.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fcenkalti%2fbackoff%2fv4/v4.2.1/v4.3.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fcenkalti%2fbackoff%2fv4/v4.2.1/v4.3.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [github.com/charmbracelet/huh/spinner](https://togithub.com/charmbracelet/huh) | `v0.0.0-20240306161957-71f31c155b08` -> `v0.3.0` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fcharmbracelet%2fhuh%2fspinner/v0.3.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fcharmbracelet%2fhuh%2fspinner/v0.3.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fcharmbracelet%2fhuh%2fspinner/v0.0.0-20240306161957-71f31c155b08/v0.3.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fcharmbracelet%2fhuh%2fspinner/v0.0.0-20240306161957-71f31c155b08/v0.3.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [github.com/distribution/reference](https://togithub.com/distribution/reference) | `v0.5.0` -> `v0.6.0` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fdistribution%2freference/v0.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fdistribution%2freference/v0.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fdistribution%2freference/v0.5.0/v0.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fdistribution%2freference/v0.5.0/v0.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [github.com/expr-lang/expr](https://togithub.com/expr-lang/expr) | `v1.16.2` -> `v1.16.3` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fexpr-lang%2fexpr/v1.16.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fexpr-lang%2fexpr/v1.16.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fexpr-lang%2fexpr/v1.16.2/v1.16.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fexpr-lang%2fexpr/v1.16.2/v1.16.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [github.com/go-sql-driver/mysql](https://togithub.com/go-sql-driver/mysql) | `v1.8.0` -> `v1.8.1` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fgo-sql-driver%2fmysql/v1.8.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fgo-sql-driver%2fmysql/v1.8.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fgo-sql-driver%2fmysql/v1.8.0/v1.8.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fgo-sql-driver%2fmysql/v1.8.0/v1.8.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>cenkalti/backoff (github.com/cenkalti/backoff/v4)</summary> ### [`v4.3.0`](https://togithub.com/cenkalti/backoff/compare/v4.2.1...v4.3.0) [Compare Source](https://togithub.com/cenkalti/backoff/compare/v4.2.1...v4.3.0) </details> <details> <summary>charmbracelet/huh (github.com/charmbracelet/huh/spinner)</summary> ### [`v0.3.0`](https://togithub.com/charmbracelet/huh/releases/tag/v0.3.0) [Compare Source](https://togithub.com/charmbracelet/huh/compare/v0.2.3...v0.3.0) ### Scrolling, autocomplete, smaller binaries and more! This is a big release with a tonne of new features. - Scrollable Forms - Scrollable Selects and Multi selects - Autocomplete for inputs - 7x smaller binaries - Multi select filtering - Lotsa' bugfixes and quality-of-life improvements To upgrade to `huh` v0.3.0: ```bash go get -u github.com/charmbracelet/huh@latest ``` For details read on! #### Scrollable forms If a form is in a small terminal it will automatically resize to fit the available space and the active group will scroll to stay in view. Form heights can also be set manually with the new [`WithHeight`](https://pkg.go.dev/github.com/charmbracelet/huh@v0.3.0#Form.WithHeight) method. <img width="800" src="https://vhs.charm.sh/vhs-1krvQFrEFaf3H1h7jbQomc.gif" alt="Made with VHS"> #### Select and Multi select Scrolling Select and Multi select fields can now be restricted to a certain height, allowing their options to be scrollable. This means you can now pack in tonnes of options. To make a `Select` or `MultiSelect` scrollable simply set the height on the field or form through the `Height` method. ```go s := huh.NewSelect() .Title("What’s for dinner?") .Options(/* ... */) .Height(height) ``` <img width="600" src="https://vhs.charm.sh/vhs-7vcNAV9T20oeMFraAFd0B7.gif" alt="Made with VHS"> #### Autocomplete Now `Input`s can offer suggestions making it easier for users to fill out inputs. These suggestions can be accepted autocomplete-style with a configurable key binding (which defaults to <kbd>ctrl+e</kbd>). Simply provide a `[]string` to `Suggestions` to enable this feature. ```go huh.NewInput(). Title("What's for lunch?"). Prompt("? "). Suggestions([]string{ "Artichoke", // ... "Cashew Apple", "Cashews", "Cat Food", "Coconut Milk", "Cucumber", "Curry Paste", "Currywurst", // ... }) ``` <img width="600" src="https://vhs.charm.sh/vhs-49L7gt948FkJxfTzfa2qmE.gif" alt="Made with VHS"> #### More helpful help Forms will automatically adjust their help text to indicate to the user whether the form will continue or submit on actions. This works with hidden groups. In the below example, the user will be asked to list their allergies if they select "Yes" otherwise, the form will submit. <img width="600" src="https://vhs.charm.sh/vhs-7skg7qpQYCMG2Y5Vl751si.gif" alt="Made with VHS"> #### Way smaller binaries Huh now produces way smaller binaries! Thanks to [#&#8203;94](https://togithub.com/charmbracelet/huh/issues/94) Huh now has a 7x smaller compiled footprint. Before, using `huh@v0.2.3`: 33M ./burger After, using `huh@v0.3.0`: 4.5M ./burger #### Thanks, Vitor! Special thanks to the intrepid [@&#8203;vitor-mariano](https://togithub.com/vitor-mariano), one of the earliest `huh` contributors, who came in hot with features, fixes, improvements and good vibes. Thank you, Vitor! #### Changelog ##### New - scrollable multi-select by [@&#8203;meowgorithm](https://togithub.com/meowgorithm) in [https://github.com/charmbracelet/huh/pull/71](https://togithub.com/charmbracelet/huh/pull/71) - scrollable select by [@&#8203;meowgorithm](https://togithub.com/meowgorithm) in [https://github.com/charmbracelet/huh/pull/76](https://togithub.com/charmbracelet/huh/pull/76) - feat: enable filtering on MultiSelect by [@&#8203;vitor-mariano](https://togithub.com/vitor-mariano) in [https://github.com/charmbracelet/huh/pull/81](https://togithub.com/charmbracelet/huh/pull/81) - skippable Fields by [@&#8203;maaslalani](https://togithub.com/maaslalani) in [https://github.com/charmbracelet/huh/pull/116](https://togithub.com/charmbracelet/huh/pull/116) - autocomplete suggestions on inputs by [@&#8203;maaslalani](https://togithub.com/maaslalani) in [https://github.com/charmbracelet/huh/pull/93](https://togithub.com/charmbracelet/huh/pull/93) - scroll form Inputs by [@&#8203;maaslalani](https://togithub.com/maaslalani) in [https://github.com/charmbracelet/huh/pull/95](https://togithub.com/charmbracelet/huh/pull/95) - next / previous dynamic help by [@&#8203;maaslalani](https://togithub.com/maaslalani) in [https://github.com/charmbracelet/huh/pull/104](https://togithub.com/charmbracelet/huh/pull/104) - reduce binary size by [@&#8203;maaslalani](https://togithub.com/maaslalani) in [https://github.com/charmbracelet/huh/pull/94](https://togithub.com/charmbracelet/huh/pull/94) ##### Fixed - fix Select and MultiSelect height when unfocused by [@&#8203;vitor-mariano](https://togithub.com/vitor-mariano) in [https://github.com/charmbracelet/huh/pull/80](https://togithub.com/charmbracelet/huh/pull/80) - use CharLimit in textinput by [@&#8203;maaslalani](https://togithub.com/maaslalani) in [https://github.com/charmbracelet/huh/pull/79](https://togithub.com/charmbracelet/huh/pull/79) - select viewport on filtering by [@&#8203;vitor-mariano](https://togithub.com/vitor-mariano) in [https://github.com/charmbracelet/huh/pull/84](https://togithub.com/charmbracelet/huh/pull/84) - set default theme on inputs by [@&#8203;maaslalani](https://togithub.com/maaslalani) in [https://github.com/charmbracelet/huh/pull/92](https://togithub.com/charmbracelet/huh/pull/92) - multiselect: set height in WithHeight by [@&#8203;ardnew](https://togithub.com/ardnew) in [https://github.com/charmbracelet/huh/pull/118](https://togithub.com/charmbracelet/huh/pull/118) - shift+tab would fail if first group is hidden by [@&#8203;caarlos0](https://togithub.com/caarlos0) in [https://github.com/charmbracelet/huh/pull/103](https://togithub.com/charmbracelet/huh/pull/103) - prevField should not select skippable fields by [@&#8203;maaslalani](https://togithub.com/maaslalani) in [https://github.com/charmbracelet/huh/pull/121](https://togithub.com/charmbracelet/huh/pull/121) **Full Changelog**: https://github.com/charmbracelet/huh/compare/v0.2.3...v0.3.0 *** <a href="https://charm.sh/"><img alt="The Charm logo" src="https://stuff.charm.sh/charm-badge.jpg" width="400"></a> Thoughts? Questions? We love hearing from you. Feel free to reach out on [Twitter](https://twitter.com/charmcli), [The Fediverse](https://mastodon.technology/@&#8203;charm), or on [Discord](https://charm.sh/chat). ### [`v0.2.3`](https://togithub.com/charmbracelet/huh/releases/tag/v0.2.3) [Compare Source](https://togithub.com/charmbracelet/huh/compare/v0.2.2...v0.2.3) #### Better Defaults! Huh? `v0.2.3` fixes some bugs for more consistent behaviour across inputs 🐞 - `Text` inputs now update values on each keystroke rather than on `Blur` for consistency. - `Select` and `MultiSelect` read their default values from the initial values set by the `Value` variable if provided. A *special* thanks to [@&#8203;vitor-mariano](https://togithub.com/vitor-mariano) for all his contributions to this release 🤗 ##### Defaults Example You can now have preselected options by declaring them in the `Value` variable: ```go var toppings = []string{"Lettuce", "Tomatoes"} var options = huh.NewOptions("Lettuce", "Tomatoes", "Charm Sauce", "Cheese", "Vegan Cheese") huh.NewMultiSelect[string]().Title("Toppings").Options(options...).Value(&toppings).Run() ``` In the above example, `Lettuce` and `Tomatoes` will be preselected by default. #### What's Changed - `Text` value updates by [@&#8203;vitor-mariano](https://togithub.com/vitor-mariano) in [https://github.com/charmbracelet/huh/pull/64](https://togithub.com/charmbracelet/huh/pull/64) - Prefill `Select` and `MultiSelect` inputs with default values by [@&#8203;vitor-mariano](https://togithub.com/vitor-mariano) in [https://github.com/charmbracelet/huh/pull/62](https://togithub.com/charmbracelet/huh/pull/62) **Full Changelog**: https://github.com/charmbracelet/huh/compare/v0.2.2...v0.2.3 *** <a href="https://charm.sh/"><img alt="The Charm logo" src="https://stuff.charm.sh/charm-badge.jpg" width="400"></a> Thoughts? Questions? We love hearing from you. Feel free to reach out on [Twitter](https://twitter.com/charmcli), [The Fediverse](https://mastodon.technology/@&#8203;charm), or on [Discord](https://charm.sh/chat). ### [`v0.2.2`](https://togithub.com/charmbracelet/huh/releases/tag/v0.2.2) [Compare Source](https://togithub.com/charmbracelet/huh/compare/v0.2.1...v0.2.2) #### Better Wrapping 🎁 `Huh?` v0.2.2 improves wrapping of the `Input` and `Text` fields. It applies width set on the form to the inputs to perform wrapping based on the specified or terminal width. - Fixed in [https://github.com/charmbracelet/huh/pull/60](https://togithub.com/charmbracelet/huh/pull/60) #### New Contributors - [@&#8203;ddddddO](https://togithub.com/ddddddO) made their first contribution in [https://github.com/charmbracelet/huh/pull/56](https://togithub.com/charmbracelet/huh/pull/56) - [@&#8203;vitor-mariano](https://togithub.com/vitor-mariano) made their first contribution in [https://github.com/charmbracelet/huh/pull/57](https://togithub.com/charmbracelet/huh/pull/57) **Full Changelog**: https://github.com/charmbracelet/huh/compare/v0.2.1...v0.2.2 *** <a href="https://charm.sh/"><img alt="The Charm logo" src="https://stuff.charm.sh/charm-badge.jpg" width="400"></a> Thoughts? Questions? We love hearing from you. Feel free to reach out on [Twitter](https://twitter.com/charmcli), [The Fediverse](https://mastodon.social/@&#8203;charmcli), or [Discord](https://charm.sh/chat). ### [`v0.2.1`](https://togithub.com/charmbracelet/huh/releases/tag/v0.2.1) [Compare Source](https://togithub.com/charmbracelet/huh/compare/v0.2.0...v0.2.1) ### New Theme! 😸 `huh?` forms can now use Catppuccin themes. (Thanks to the wonderful [@&#8203;sgoudham](https://togithub.com/sgoudham) ✨) Simply add the following to your `huh.Form`s: ```go .WithTheme(huh.ThemeCatppuccin()) ``` <img width="500" src="https://github.com/charmbracelet/huh/assets/42545625/fdea4eb5-fa3b-472c-8aa4-9537e9577ab5" /> *** <a href="https://charm.sh/"><img alt="The Charm logo" src="https://stuff.charm.sh/charm-badge.jpg" width="400"></a> Thoughts? Questions? We love hearing from you. Feel free to reach out on [Twitter](https://twitter.com/charmcli), [The Fediverse](https://mastodon.social/@&#8203;charmcli), or [Discord](https://charm.sh/chat). ### [`v0.2.0`](https://togithub.com/charmbracelet/huh/releases/tag/v0.2.0) [Compare Source](https://togithub.com/charmbracelet/huh/compare/v0.1.0...v0.2.0) ### Better Help Styles! `Help` Styles now apply on a `Theme` rather than embedded in `FieldStyles`. (Thanks to the wonderful [@&#8203;jolheiser](https://togithub.com/jolheiser) ✨) ```go // Old... theme.Focused.Help.ShortKey = lipgloss.NewStyle() //... // Updated! theme.Help.ShortKey = lipgloss.NewStyle() //... ``` *** <a href="https://charm.sh/"><img alt="The Charm logo" src="https://stuff.charm.sh/charm-badge.jpg" width="400"></a> Thoughts? Questions? We love hearing from you. Feel free to reach out on [Twitter](https://twitter.com/charmcli), [The Fediverse](https://mastodon.social/@&#8203;charmcli), or [Discord](https://charm.sh/chat). </details> <details> <summary>distribution/reference (github.com/distribution/reference)</summary> ### [`v0.6.0`](https://togithub.com/distribution/reference/releases/tag/v0.6.0) [Compare Source](https://togithub.com/distribution/reference/compare/v0.5.0...v0.6.0) #### What's Changed - remove deprecated SplitHostname by [@&#8203;thaJeztah](https://togithub.com/thaJeztah) in [https://github.com/distribution/reference/pull/5](https://togithub.com/distribution/reference/pull/5) - refactor splitDockerDomain to include more documentation by [@&#8203;thaJeztah](https://togithub.com/thaJeztah) in [https://github.com/distribution/reference/pull/7](https://togithub.com/distribution/reference/pull/7) - fix typo in readme by [@&#8203;xrstf](https://togithub.com/xrstf) in [https://github.com/distribution/reference/pull/10](https://togithub.com/distribution/reference/pull/10) - Exclude domain from name length check by [@&#8203;ozairasim](https://togithub.com/ozairasim) in [https://github.com/distribution/reference/pull/9](https://togithub.com/distribution/reference/pull/9) #### New Contributors - [@&#8203;xrstf](https://togithub.com/xrstf) made their first contribution in [https://github.com/distribution/reference/pull/10](https://togithub.com/distribution/reference/pull/10) - [@&#8203;ozairasim](https://togithub.com/ozairasim) made their first contribution in [https://github.com/distribution/reference/pull/9](https://togithub.com/distribution/reference/pull/9) **Full Changelog**: https://github.com/distribution/reference/compare/v0.5.0...v0.6.0 </details> <details> <summary>expr-lang/expr (github.com/expr-lang/expr)</summary> ### [`v1.16.3`](https://togithub.com/expr-lang/expr/releases/tag/v1.16.3) [Compare Source](https://togithub.com/expr-lang/expr/compare/v1.16.2...v1.16.3) **Expr** is a Go-centric expression language designed to deliver dynamic configurations with unparalleled accuracy, safety, and speed. ```go program, err := expr.Compile(`let x = 2 + 2; x ^ x`) output, err := expr.Run(program, env) ``` **In this release**: - Improved printing for maps: `{(foo + bar): 42}` **Expr Editor** The [Expr Editor](https://expr-lang.org/editor) is an embeddable code editor written in JavaScript with full support of Expr language. **Expr Pro** [Expr Pro](https://expr-lang.org/expr-pro) is a set of extensions for Expr for advanced use cases. It includes expressions explanation, performance profiling, and more. </details> <details> <summary>go-sql-driver/mysql (github.com/go-sql-driver/mysql)</summary> ### [`v1.8.1`](https://togithub.com/go-sql-driver/mysql/releases/tag/v1.8.1) [Compare Source](https://togithub.com/go-sql-driver/mysql/compare/v1.8.0...v1.8.1) #### What's Changed Bugfixes: - fix race condition when context is canceled in [#&#8203;1562](https://togithub.com/go-sql-driver/mysql/pull/1562) and [#&#8203;1570](https://togithub.com/go-sql-driver/mysql/pull/1570) **Full Changelog**: https://github.com/go-sql-driver/mysql/compare/v1.8.0...v1.8.1 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "before 4am" (UTC), Automerge - "before 4am" (UTC). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/woodpecker-ci/woodpecker). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNjkuMiIsInVwZGF0ZWRJblZlciI6IjM3LjI2OS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: qwerty287 <qwerty287@posteo.de>
2024-03-29 10:21:54 +02:00
func runCron(ctx context.Context, store store.Store, forge forge.Forge, cron *model.Cron, now time.Time) error {
log.Trace().Msgf("cron: run id[%d]", cron.ID)
newNext, err := CalcNewNext(cron.Schedule, now)
if err != nil {
return err
}
// try to get lock on cron
gotLock, err := store.CronGetLock(cron, newNext.Unix())
if err != nil {
return err
}
if !gotLock {
// another go routine caught it
return nil
}
repo, newPipeline, err := CreatePipeline(ctx, store, forge, cron)
if err != nil {
return err
}
_, err = pipeline.Create(ctx, store, repo, newPipeline)
return err
}
func CreatePipeline(ctx context.Context, store store.Store, f forge.Forge, cron *model.Cron) (*model.Repo, *model.Pipeline, error) {
repo, err := store.GetRepo(cron.RepoID)
if err != nil {
return nil, nil, err
}
if cron.Branch == "" {
// fallback to the repos default branch
cron.Branch = repo.Branch
}
creator, err := store.GetUser(cron.CreatorID)
if err != nil {
return nil, nil, err
}
// If the forge has a refresh token, the current access token
// may be stale. Therefore, we should refresh prior to dispatching
// the pipeline.
forge.Refresh(ctx, f, store, creator)
commit, err := f.BranchHead(ctx, creator, repo, cron.Branch)
if err != nil {
return nil, nil, err
}
return repo, &model.Pipeline{
Event: model.EventCron,
Commit: commit.SHA,
Ref: "refs/heads/" + cron.Branch,
Branch: cron.Branch,
Message: cron.Name,
Timestamp: cron.NextExec,
Sender: cron.Name,
ForgeURL: commit.ForgeURL,
}, nil
}