mirror of https://code.forgejo.org/forgejo/runner
Merge pull request 'cherry-pick commits from act_runner' (#157) from earl-warren/runner:wip-gitea into main
Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/157 Reviewed-by: dachary <dachary@noreply.code.forgejo.org>pull/160/head
commit
3682c4ecb4
|
@ -13,6 +13,8 @@
|
||||||
* add support for `runs-on.labels` which is equivalent to `runs-on` followed by a list of labels
|
* add support for `runs-on.labels` which is equivalent to `runs-on` followed by a list of labels
|
||||||
* the expressions in the service `ports` and `volumes` values are evaluated
|
* the expressions in the service `ports` and `volumes` values are evaluated
|
||||||
* network aliases are only supported when the network is user specified, not when it is provided by the runner
|
* network aliases are only supported when the network is user specified, not when it is provided by the runner
|
||||||
|
* Fix compatibility issue with actions/{upload,download}-artifact@v4
|
||||||
|
* If `[runner].insecure` is true in the configuration, insecure cloning actions is allowed
|
||||||
|
|
||||||
## 3.3.0
|
## 3.3.0
|
||||||
|
|
||||||
|
|
|
@ -486,7 +486,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")
|
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.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().BoolVarP(&execArg.enableIPv6, "enable-ipv6", "6", false, "Create network with IPv6 enabled.")
|
execCmd.PersistentFlags().BoolVarP(&execArg.enableIPv6, "enable-ipv6", "6", false, "Create network with IPv6 enabled.")
|
||||||
execCmd.PersistentFlags().StringVarP(&execArg.githubInstance, "gitea-instance", "", "", "Gitea instance to use.")
|
execCmd.PersistentFlags().StringVarP(&execArg.githubInstance, "gitea-instance", "", "", "Gitea instance to use.")
|
||||||
|
|
|
@ -81,6 +81,7 @@ func NewRunner(cfg *config.Config, reg *config.Registration, cli client.Client)
|
||||||
// set artifact gitea api
|
// set artifact gitea api
|
||||||
artifactGiteaAPI := strings.TrimSuffix(cli.Address(), "/") + "/api/actions_pipeline/"
|
artifactGiteaAPI := strings.TrimSuffix(cli.Address(), "/") + "/api/actions_pipeline/"
|
||||||
envs["ACTIONS_RUNTIME_URL"] = artifactGiteaAPI
|
envs["ACTIONS_RUNTIME_URL"] = artifactGiteaAPI
|
||||||
|
envs["ACTIONS_RESULTS_URL"] = strings.TrimSuffix(cli.Address(), "/")
|
||||||
|
|
||||||
// Set specific environments to distinguish between Gitea and GitHub
|
// Set specific environments to distinguish between Gitea and GitHub
|
||||||
envs["GITEA_ACTIONS"] = "true"
|
envs["GITEA_ACTIONS"] = "true"
|
||||||
|
@ -169,8 +170,12 @@ func (r *Runner) run(ctx context.Context, task *runnerv1.Task, reporter *report.
|
||||||
preset.Token = t
|
preset.Token = t
|
||||||
}
|
}
|
||||||
|
|
||||||
// use task token to action api token
|
giteaRuntimeToken := taskContext["gitea_runtime_token"].GetStringValue()
|
||||||
r.envs["ACTIONS_RUNTIME_TOKEN"] = preset.Token
|
if giteaRuntimeToken == "" {
|
||||||
|
// use task token to action api token for previous Gitea Server Versions
|
||||||
|
giteaRuntimeToken = preset.Token
|
||||||
|
}
|
||||||
|
r.envs["ACTIONS_RUNTIME_TOKEN"] = giteaRuntimeToken
|
||||||
|
|
||||||
eventJSON, err := json.Marshal(preset.Event)
|
eventJSON, err := json.Marshal(preset.Event)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -212,6 +217,7 @@ func (r *Runner) run(ctx context.Context, task *runnerv1.Task, reporter *report.
|
||||||
PlatformPicker: r.labels.PickPlatform,
|
PlatformPicker: r.labels.PickPlatform,
|
||||||
Vars: task.Vars,
|
Vars: task.Vars,
|
||||||
ValidVolumes: r.cfg.Container.ValidVolumes,
|
ValidVolumes: r.cfg.Container.ValidVolumes,
|
||||||
|
InsecureSkipTLS: r.cfg.Runner.Insecure,
|
||||||
}
|
}
|
||||||
|
|
||||||
rr, err := runner.New(runnerConfig)
|
rr, err := runner.New(runnerConfig)
|
||||||
|
|
|
@ -99,6 +99,9 @@ func LoadDefault(file string) (*Config, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("read env file %q: %w", cfg.Runner.EnvFile, err)
|
return nil, fmt.Errorf("read env file %q: %w", cfg.Runner.EnvFile, err)
|
||||||
}
|
}
|
||||||
|
if cfg.Runner.Envs == nil {
|
||||||
|
cfg.Runner.Envs = map[string]string{}
|
||||||
|
}
|
||||||
for k, v := range envs {
|
for k, v := range envs {
|
||||||
cfg.Runner.Envs[k] = v
|
cfg.Runner.Envs[k] = v
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,9 @@ func NewReporter(ctx context.Context, cancel context.CancelFunc, client client.C
|
||||||
if v := task.Context.Fields["token"].GetStringValue(); v != "" {
|
if v := task.Context.Fields["token"].GetStringValue(); v != "" {
|
||||||
oldnew = append(oldnew, v, "***")
|
oldnew = append(oldnew, v, "***")
|
||||||
}
|
}
|
||||||
|
if v := task.Context.Fields["gitea_runtime_token"].GetStringValue(); v != "" {
|
||||||
|
oldnew = append(oldnew, v, "***")
|
||||||
|
}
|
||||||
for _, v := range task.Secrets {
|
for _, v := range task.Secrets {
|
||||||
oldnew = append(oldnew, v, "***")
|
oldnew = append(oldnew, v, "***")
|
||||||
}
|
}
|
||||||
|
@ -111,6 +114,9 @@ func (r *Reporter) Fire(entry *log.Entry) error {
|
||||||
for _, s := range r.state.Steps {
|
for _, s := range r.state.Steps {
|
||||||
if s.Result == runnerv1.Result_RESULT_UNSPECIFIED {
|
if s.Result == runnerv1.Result_RESULT_UNSPECIFIED {
|
||||||
s.Result = runnerv1.Result_RESULT_CANCELLED
|
s.Result = runnerv1.Result_RESULT_CANCELLED
|
||||||
|
if jobResult == runnerv1.Result_RESULT_SKIPPED {
|
||||||
|
s.Result = runnerv1.Result_RESULT_SKIPPED
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -418,7 +424,7 @@ func (r *Reporter) parseLogRow(entry *log.Entry) *runnerv1.LogRow {
|
||||||
|
|
||||||
return &runnerv1.LogRow{
|
return &runnerv1.LogRow{
|
||||||
Time: timestamppb.New(entry.Time),
|
Time: timestamppb.New(entry.Time),
|
||||||
Content: content,
|
Content: strings.ToValidUTF8(content, "?"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue