1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-08-06 17:40:58 +00:00

fix!: default to node:22-bookworm instead of node:20-bullseye (#686)

Closes forgejo/runner#134

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/686
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
This commit is contained in:
Earl Warren 2025-07-12 09:36:58 +00:00 committed by earl-warren
parent ec05ed930f
commit f0090d8ac7
No known key found for this signature in database
GPG key ID: F128CBE6AB3A7201
3 changed files with 74 additions and 30 deletions

View file

@ -3,6 +3,7 @@
## 8.0.0 (not published yet) ## 8.0.0 (not published yet)
* Breaking change: workflows files go through a [schema validation](https://code.forgejo.org/forgejo/act/pulls/170) and will not run if they do not pass. Some existing workflows may have syntax errors that did not prevent them from running with versions 7.0.0 and below but they will no longer work with versions 8.0.0 and above. If the error is not immediately obvious, please file an issue with a copy of the failed workflow and revert to using version 7.0.0 until it is resolved. * Breaking change: workflows files go through a [schema validation](https://code.forgejo.org/forgejo/act/pulls/170) and will not run if they do not pass. Some existing workflows may have syntax errors that did not prevent them from running with versions 7.0.0 and below but they will no longer work with versions 8.0.0 and above. If the error is not immediately obvious, please file an issue with a copy of the failed workflow and revert to using version 7.0.0 until it is resolved.
* Breaking change: in the absence of a label or a label, [default to `docker://node:22-bookworm` instead of `docker://node:20-bullseye` or `host`](https://code.forgejo.org/forgejo/runner/issues/134). If the `lxc` scheme is set with no argument, it defaults to `lxc://debian:bookworm` instead of `lxc://debian:bullseye`.
* [secrets that contain multiple lines are masked from the output](https://code.forgejo.org/forgejo/runner/pulls/661). * [secrets that contain multiple lines are masked from the output](https://code.forgejo.org/forgejo/runner/pulls/661).
* [bash fallback to sh if it is not available](https://code.forgejo.org/forgejo/runner/issues/150). * [bash fallback to sh if it is not available](https://code.forgejo.org/forgejo/runner/issues/150).

View file

@ -9,9 +9,13 @@ import (
) )
const ( const (
SchemeHost = "host" SchemeHost = "host"
SchemeDocker = "docker" SchemeDocker = "docker"
SchemeLXC = "lxc" ArgDocker = "//node:22-bookworm"
SchemeLXC = "lxc"
ArgLXC = "//debian:bookworm"
) )
type Label struct { type Label struct {
@ -24,18 +28,32 @@ func Parse(str string) (*Label, error) {
splits := strings.SplitN(str, ":", 3) splits := strings.SplitN(str, ":", 3)
label := &Label{ label := &Label{
Name: splits[0], Name: splits[0],
Schema: "host", Schema: "docker",
Arg: "",
} }
if len(splits) >= 2 { if len(splits) >= 2 {
label.Schema = splits[1] label.Schema = splits[1]
if label.Schema != SchemeHost && label.Schema != SchemeDocker && label.Schema != SchemeLXC {
return nil, fmt.Errorf("unsupported schema: %s", label.Schema)
}
} }
if len(splits) >= 3 { if len(splits) >= 3 {
if label.Schema == SchemeHost {
return nil, fmt.Errorf("schema: %s does not have arguments", label.Schema)
}
label.Arg = splits[2] label.Arg = splits[2]
} }
if label.Schema != SchemeHost && label.Schema != SchemeDocker && label.Schema != SchemeLXC { if label.Arg == "" {
return nil, fmt.Errorf("unsupported schema: %s", label.Schema) switch label.Schema {
case SchemeDocker:
label.Arg = ArgDocker
case SchemeLXC:
label.Arg = ArgLXC
}
} }
return label, nil return label, nil
} }
@ -72,17 +90,7 @@ func (l Labels) PickPlatform(runsOn []string) string {
} }
} }
// TODO: support multiple labels return strings.TrimPrefix(ArgDocker, "//")
// like:
// ["ubuntu-22.04"] => "ubuntu:22.04"
// ["with-gpu"] => "linux:with-gpu"
// ["ubuntu-22.04", "with-gpu"] => "ubuntu:22.04_with-gpu"
// return default.
// So the runner receives a task with a label that the runner doesn't have,
// it happens when the user have edited the label of the runner in the web UI.
// TODO: it may be not correct, what if the runner is used as host mode only?
return "node:20-bullseye"
} }
func (l Labels) Names() []string { func (l Labels) Names() []string {

View file

@ -18,34 +18,69 @@ func TestParse(t *testing.T) {
wantErr bool wantErr bool
}{ }{
{ {
args: "ubuntu:docker://node:18", args: "label1",
want: &Label{ want: &Label{
Name: "ubuntu", Name: "label1",
Schema: "docker", Schema: SchemeDocker,
Arg: ArgDocker,
},
wantErr: false,
},
{
args: "label1:docker",
want: &Label{
Name: "label1",
Schema: SchemeDocker,
Arg: ArgDocker,
},
wantErr: false,
},
{
args: "label1:docker://node:18",
want: &Label{
Name: "label1",
Schema: SchemeDocker,
Arg: "//node:18", Arg: "//node:18",
}, },
wantErr: false, wantErr: false,
}, },
{ {
args: "ubuntu:host", args: "label1:lxc",
want: &Label{ want: &Label{
Name: "ubuntu", Name: "label1",
Schema: SchemeLXC,
Arg: ArgLXC,
},
wantErr: false,
},
{
args: "label1:lxc://debian:buster",
want: &Label{
Name: "label1",
Schema: SchemeLXC,
Arg: "//debian:buster",
},
wantErr: false,
},
{
args: "label1:host",
want: &Label{
Name: "label1",
Schema: "host", Schema: "host",
Arg: "", Arg: "",
}, },
wantErr: false, wantErr: false,
}, },
{ {
args: "ubuntu", args: "label1:host:something",
want: &Label{ want: nil,
Name: "ubuntu", wantErr: true,
Schema: "host",
Arg: "",
},
wantErr: false,
}, },
{ {
args: "ubuntu:vm:ubuntu-18.04", args: "label1:invalidscheme",
want: nil, want: nil,
wantErr: true, wantErr: true,
}, },