summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorearl-warren <earl-warren@noreply.code.forgejo.org>2024-03-11 16:57:19 +0100
committerearl-warren <earl-warren@noreply.code.forgejo.org>2024-03-11 16:57:19 +0100
commit3682c4ecb49cb4f49b4790650db97964a2096f9c (patch)
treeaa7c50dc68b4c867b29cb9df0e4696c6a8ee7141
parentMerge pull request '[FORGEJO] no need for the CA' (#154) from earl-warren/run... (diff)
parentupdate release notes for 3.4.0 (diff)
downloadforgejo-runner-3682c4ecb49cb4f49b4790650db97964a2096f9c.tar.xz
forgejo-runner-3682c4ecb49cb4f49b4790650db97964a2096f9c.zip
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>
-rw-r--r--RELEASE-NOTES.md2
-rw-r--r--internal/app/cmd/exec.go2
-rw-r--r--internal/app/run/runner.go10
-rw-r--r--internal/pkg/config/config.go3
-rw-r--r--internal/pkg/report/reporter.go8
5 files changed, 21 insertions, 4 deletions
diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index a8e94a8..21dff1e 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -13,6 +13,8 @@
* 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
* 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
diff --git a/internal/app/cmd/exec.go b/internal/app/cmd/exec.go
index ffd932c..30a8c76 100644
--- a/internal/app/cmd/exec.go
+++ b/internal/app/cmd/exec.go
@@ -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.debug, "debug", "d", false, "enable debug log")
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().BoolVarP(&execArg.enableIPv6, "enable-ipv6", "6", false, "Create network with IPv6 enabled.")
execCmd.PersistentFlags().StringVarP(&execArg.githubInstance, "gitea-instance", "", "", "Gitea instance to use.")
diff --git a/internal/app/run/runner.go b/internal/app/run/runner.go
index 0884c50..ee12165 100644
--- a/internal/app/run/runner.go
+++ b/internal/app/run/runner.go
@@ -81,6 +81,7 @@ func NewRunner(cfg *config.Config, reg *config.Registration, cli client.Client)
// set artifact gitea api
artifactGiteaAPI := strings.TrimSuffix(cli.Address(), "/") + "/api/actions_pipeline/"
envs["ACTIONS_RUNTIME_URL"] = artifactGiteaAPI
+ envs["ACTIONS_RESULTS_URL"] = strings.TrimSuffix(cli.Address(), "/")
// Set specific environments to distinguish between Gitea and GitHub
envs["GITEA_ACTIONS"] = "true"
@@ -169,8 +170,12 @@ func (r *Runner) run(ctx context.Context, task *runnerv1.Task, reporter *report.
preset.Token = t
}
- // use task token to action api token
- r.envs["ACTIONS_RUNTIME_TOKEN"] = preset.Token
+ giteaRuntimeToken := taskContext["gitea_runtime_token"].GetStringValue()
+ 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)
if err != nil {
@@ -212,6 +217,7 @@ func (r *Runner) run(ctx context.Context, task *runnerv1.Task, reporter *report.
PlatformPicker: r.labels.PickPlatform,
Vars: task.Vars,
ValidVolumes: r.cfg.Container.ValidVolumes,
+ InsecureSkipTLS: r.cfg.Runner.Insecure,
}
rr, err := runner.New(runnerConfig)
diff --git a/internal/pkg/config/config.go b/internal/pkg/config/config.go
index 540c82a..a7bb977 100644
--- a/internal/pkg/config/config.go
+++ b/internal/pkg/config/config.go
@@ -99,6 +99,9 @@ func LoadDefault(file string) (*Config, error) {
if err != nil {
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 {
cfg.Runner.Envs[k] = v
}
diff --git a/internal/pkg/report/reporter.go b/internal/pkg/report/reporter.go
index 7e9a2d5..0930e88 100644
--- a/internal/pkg/report/reporter.go
+++ b/internal/pkg/report/reporter.go
@@ -47,6 +47,9 @@ func NewReporter(ctx context.Context, cancel context.CancelFunc, client client.C
if v := task.Context.Fields["token"].GetStringValue(); v != "" {
oldnew = append(oldnew, v, "***")
}
+ if v := task.Context.Fields["gitea_runtime_token"].GetStringValue(); v != "" {
+ oldnew = append(oldnew, v, "***")
+ }
for _, v := range task.Secrets {
oldnew = append(oldnew, v, "***")
}
@@ -111,6 +114,9 @@ func (r *Reporter) Fire(entry *log.Entry) error {
for _, s := range r.state.Steps {
if s.Result == runnerv1.Result_RESULT_UNSPECIFIED {
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{
Time: timestamppb.New(entry.Time),
- Content: content,
+ Content: strings.ToValidUTF8(content, "?"),
}
}