Use node 20 by default (#526)

Because Octokit requires Node 18 or higher now.

See https://github.com/octokit/octokit.js/#fetch-missing .

However, for existing runners, users should manually modify `labels` in the `.runner` file or `runner.labels` in the `config.yaml` file to update. Don't forget to restart.

Reviewed-on: https://gitea.com/gitea/act_runner/pulls/526
Reviewed-by: sillyguodong <sillyguodong@noreply.gitea.com>
This commit is contained in:
Jason Song 2024-03-29 03:03:26 +00:00
parent 1760899d27
commit 94c45acf6b
5 changed files with 16 additions and 12 deletions

View File

@ -58,9 +58,9 @@ INFO Enter the runner token:
fe884e8027dc292970d4e0303fe82b14xxxxxxxx fe884e8027dc292970d4e0303fe82b14xxxxxxxx
INFO Enter the runner name (if set empty, use hostname: Test.local): INFO Enter the runner name (if set empty, use hostname: Test.local):
INFO Enter the runner labels, leave blank to use the default labels (comma-separated, for example, ubuntu-20.04:docker://node:16-bullseye,ubuntu-18.04:docker://node:16-buster,linux_arm:host): INFO Enter the runner labels, leave blank to use the default labels (comma-separated, for example, docker://node:20-bookworm,ubuntu-22.04:docker://node:20-bookworm,ubuntu-20.04:docker://node:20-bullseye,ubuntu-18.04:docker://node:20-buster):
INFO Registering runner, name=Test.local, instance=http://192.168.8.8:3000/, labels=[ubuntu-latest:docker://node:16-bullseye ubuntu-22.04:docker://node:16-bullseye ubuntu-20.04:docker://node:16-bullseye ubuntu-18.04:docker://node:16-buster]. INFO Registering runner, name=Test.local, instance=http://192.168.8.8:3000/, labels=[ubuntu-latest:docker://node:20-bookworm ubuntu-22.04:docker://node:20-bookworm ubuntu-20.04:docker://node:20-bullseye ubuntu-18.04:docker://node:20-buster].
DEBU Successfully pinged the Gitea instance server DEBU Successfully pinged the Gitea instance server
INFO Runner registered successfully. INFO Runner registered successfully.
``` ```

View File

@ -484,7 +484,7 @@ func loadExecCmd(ctx context.Context) *cobra.Command {
execCmd.PersistentFlags().BoolVarP(&execArg.noSkipCheckout, "no-skip-checkout", "", false, "Do not skip actions/checkout") execCmd.PersistentFlags().BoolVarP(&execArg.noSkipCheckout, "no-skip-checkout", "", false, "Do not skip actions/checkout")
execCmd.PersistentFlags().BoolVarP(&execArg.debug, "debug", "d", false, "enable debug log") execCmd.PersistentFlags().BoolVarP(&execArg.debug, "debug", "d", false, "enable debug log")
execCmd.PersistentFlags().BoolVarP(&execArg.dryrun, "dryrun", "n", false, "dryrun mode") execCmd.PersistentFlags().BoolVarP(&execArg.dryrun, "dryrun", "n", false, "dryrun mode")
execCmd.PersistentFlags().StringVarP(&execArg.image, "image", "i", "node:16-bullseye", "Docker image to use. Use \"-self-hosted\" to run directly on the host.") execCmd.PersistentFlags().StringVarP(&execArg.image, "image", "i", "node:20-bookworm", "Docker image to use. Use \"-self-hosted\" to run directly on the host.")
execCmd.PersistentFlags().StringVarP(&execArg.network, "network", "", "", "Specify the network to which the container will connect") execCmd.PersistentFlags().StringVarP(&execArg.network, "network", "", "", "Specify the network to which the container will connect")
execCmd.PersistentFlags().StringVarP(&execArg.githubInstance, "gitea-instance", "", "", "Gitea instance to use.") execCmd.PersistentFlags().StringVarP(&execArg.githubInstance, "gitea-instance", "", "", "Gitea instance to use.")

View File

@ -90,11 +90,16 @@ const (
StageExit StageExit
) )
/*
ubuntu-18.04 -> bionic -> buster: https://git.launchpad.net/ubuntu/+source/base-files/tree/etc/debian_version?h=ubuntu/bionic
ubuntu-20.04 -> focal -> bullseye: https://git.launchpad.net/ubuntu/+source/base-files/tree/etc/debian_version?h=ubuntu/focal
ubuntu-22.04 -> jammy -> bookworm: https://git.launchpad.net/ubuntu/+source/base-files/tree/etc/debian_version?h=ubuntu/jammy
*/
var defaultLabels = []string{ var defaultLabels = []string{
"ubuntu-latest:docker://node:16-bullseye", "ubuntu-latest:docker://node:20-bookworm",
"ubuntu-22.04:docker://node:16-bullseye", // There's no node:16-bookworm yet "ubuntu-22.04:docker://node:20-bookworm",
"ubuntu-20.04:docker://node:16-bullseye", "ubuntu-20.04:docker://node:20-bullseye",
"ubuntu-18.04:docker://node:16-buster", "ubuntu-18.04:docker://node:20-buster",
} }
type registerInputs struct { type registerInputs struct {
@ -179,7 +184,7 @@ func (r *registerInputs) assignToNext(stage registerStage, value string, cfg *co
} }
if validateLabels(r.Labels) != nil { if validateLabels(r.Labels) != nil {
log.Infoln("Invalid labels, please input again, leave blank to use the default labels (for example, ubuntu-20.04:docker://node:16-bullseye,ubuntu-18.04:docker://node:16-buster,linux_arm:host)") log.Infoln("Invalid labels, please input again, leave blank to use the default labels (for example, docker://node:20-bookworm,ubuntu-22.04:docker://node:20-bookworm,ubuntu-20.04:docker://node:20-bullseye,ubuntu-18.04:docker://node:20-buster)")
return StageInputLabels return StageInputLabels
} }
return StageWaitingForRegistration return StageWaitingForRegistration
@ -243,7 +248,7 @@ func printStageHelp(stage registerStage) {
hostname, _ := os.Hostname() hostname, _ := os.Hostname()
log.Infof("Enter the runner name (if set empty, use hostname: %s):\n", hostname) log.Infof("Enter the runner name (if set empty, use hostname: %s):\n", hostname)
case StageInputLabels: case StageInputLabels:
log.Infoln("Enter the runner labels, leave blank to use the default labels (comma-separated, for example, ubuntu-20.04:docker://node:16-bullseye,ubuntu-18.04:docker://node:16-buster,linux_arm:host):") log.Infoln("Enter the runner labels, leave blank to use the default labels (comma-separated, for example, docker://node:20-bookworm,ubuntu-22.04:docker://node:20-bookworm,ubuntu-20.04:docker://node:20-bullseye,ubuntu-18.04:docker://node:20-buster):")
case StageWaitingForRegistration: case StageWaitingForRegistration:
log.Infoln("Waiting for registration...") log.Infoln("Waiting for registration...")
} }

View File

@ -30,7 +30,7 @@ runner:
# The interval for fetching the job from the Gitea instance. # The interval for fetching the job from the Gitea instance.
fetch_interval: 2s fetch_interval: 2s
# The labels of a runner are used to determine which jobs the runner can run, and how to run them. # The labels of a runner are used to determine which jobs the runner can run, and how to run them.
# Like: ["macos-arm64:host", "ubuntu-latest:docker://node:16-bullseye", "ubuntu-22.04:docker://node:16-bullseye"] # Like: ["macos-arm64:host", "ubuntu-latest:docker://node:20-bookworm", "ubuntu-22.04:docker://node:20-bookworm"]
# If it's empty when registering, it will ask for inputting labels. # If it's empty when registering, it will ask for inputting labels.
# If it's empty when execute `deamon`, will use labels in `.runner` file. # If it's empty when execute `deamon`, will use labels in `.runner` file.
labels: [] labels: []

View File

@ -55,7 +55,6 @@ func (l Labels) PickPlatform(runsOn []string) string {
switch label.Schema { switch label.Schema {
case SchemeDocker: case SchemeDocker:
// "//" will be ignored // "//" will be ignored
// TODO maybe we should use 'ubuntu-18.04:docker:node:16-buster' instead
platforms[label.Name] = strings.TrimPrefix(label.Arg, "//") platforms[label.Name] = strings.TrimPrefix(label.Arg, "//")
case SchemeHost: case SchemeHost:
platforms[label.Name] = "-self-hosted" platforms[label.Name] = "-self-hosted"
@ -80,7 +79,7 @@ func (l Labels) PickPlatform(runsOn []string) string {
// So the runner receives a task with a label that the runner doesn't have, // 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. // 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? // TODO: it may be not correct, what if the runner is used as host mode only?
return "node:16-bullseye" return "node:20-bookworm"
} }
func (l Labels) Names() []string { func (l Labels) Names() []string {