diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 15fcd429..77de8b65 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -25,7 +25,7 @@ jobs: run: | env GOOS=windows GOARCH=${{matrix.architecture}} \ go build \ - -ldflags "-s -w -X gitea.com/gitea/act_runner/internal/pkg/ver.version=${{ github.ref_name }}" \ + -ldflags "-s -w -X runner.forgejo.org/internal/pkg/ver.version=${{ github.ref_name }}" \ -o forgejo-runner-windows-${{matrix.architecture}}.exe - uses: actions/upload-artifact@v4 @@ -149,4 +149,3 @@ jobs: token: ${{ secrets.RELEASE_TOKEN }} fail_on_unmatched_files: true body: See [original release notes](https://code.forgejo.org/forgejo/runner/releases/tag/${{ github.ref_name }}). - diff --git a/.gitignore b/.gitignore index 57ec96d6..ad418a72 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ forgejo-runner .env .runner coverage.txt -/gitea-vet /config.yaml # MS VSCode diff --git a/.golangci.yml b/.golangci.yml index 41f96835..ba1d4110 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -74,12 +74,8 @@ linters-settings: extra-rules: true lang-version: "1.18" depguard: - # TODO: use depguard to replace import checks in gitea-vet list-type: denylist - # Check the list against standard lib. include-go-root: true - packages-with-error-message: - - github.com/unknwon/com: "use gitea's util and replacements" issues: exclude-rules: diff --git a/LICENSE b/LICENSE index ce49c38f..76462726 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2023 The Forgejo Authors +Copyright (c) 2023-2025 The Forgejo Authors Copyright (c) 2022 The Gitea Authors Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/Makefile b/Makefile index a1a65130..b45e0585 100644 --- a/Makefile +++ b/Makefile @@ -61,11 +61,11 @@ else endif endif -GO_PACKAGES_TO_VET ?= $(filter-out gitea.com/gitea/act_runner/internal/pkg/client/mocks,$(shell $(GO) list ./...)) +GO_PACKAGES_TO_VET ?= $(filter-out runner.forgejo.org/internal/pkg/client/mocks,$(shell $(GO) list ./...)) TAGS ?= -LDFLAGS ?= -X "gitea.com/gitea/act_runner/internal/pkg/ver.version=v$(RELEASE_VERSION)" +LDFLAGS ?= -X "runner.forgejo.org/internal/pkg/ver.version=v$(RELEASE_VERSION)" all: build diff --git a/build.go b/build.go deleted file mode 100644 index f2e5d825..00000000 --- a/build.go +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2023 The Gitea Authors. All rights reserved. -// SPDX-License-Identifier: MIT - -//go:build vendor - -package main - -import ( - // for vet - _ "code.gitea.io/gitea-vet" -) diff --git a/go.mod b/go.mod index cd1b0bd6..251cf542 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module gitea.com/gitea/act_runner +module runner.forgejo.org go 1.23.0 @@ -6,7 +6,6 @@ toolchain go1.23.10 require ( code.forgejo.org/forgejo/actions-proto v0.5.1 - code.gitea.io/gitea-vet v0.2.3 connectrpc.com/connect v1.18.1 github.com/avast/retry-go/v4 v4.6.1 github.com/docker/docker v28.3.0+incompatible @@ -100,7 +99,6 @@ require ( golang.org/x/net v0.38.0 // indirect golang.org/x/sync v0.12.0 // indirect golang.org/x/sys v0.33.0 // indirect - golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect gopkg.in/warnings.v0 v0.1.2 // indirect ) diff --git a/go.sum b/go.sum index ac8cc261..59ea74bc 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,6 @@ code.forgejo.org/forgejo/act v1.28.0 h1:96njNC7C1YNyjWq5OWvLZMF/nw0PMthzIA8Nwbnn code.forgejo.org/forgejo/act v1.28.0/go.mod h1:dFuiwAmD5vyrzecysHB2kL/GM3wRpoVPl+WdbCTC8Bs= code.forgejo.org/forgejo/actions-proto v0.5.1 h1:GCJHR/Y/Apk7Yl7CH9qOsKrdf/k0tRVFeVhz1EIZvb4= code.forgejo.org/forgejo/actions-proto v0.5.1/go.mod h1:nu8N1HQLsu3c4T/PpYWbqwNBxsZnEOVxqV0mQWtIQvE= -code.gitea.io/gitea-vet v0.2.3 h1:gdFmm6WOTM65rE8FUBTRzeQZYzXePKSSB1+r574hWwI= -code.gitea.io/gitea-vet v0.2.3/go.mod h1:zcNbT/aJEmivCAhfmkHOlT645KNOf9W2KnkLgFjGGfE= connectrpc.com/connect v1.18.1 h1:PAg7CjSAGvscaf6YZKUefjoih5Z/qYkyaTrBW8xvYPw= connectrpc.com/connect v1.18.1/go.mod h1:0292hj1rnx8oFrStN7cB4jjVBeqs+Yx5yDIC2prWDO8= dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= @@ -206,7 +204,6 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHo github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= -github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.etcd.io/bbolt v1.3.8/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= @@ -241,8 +238,6 @@ golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0 golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= -golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -283,11 +278,8 @@ golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE= golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200325010219-a49f79bcc224/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/internal/app/cmd/cache-server.go b/internal/app/cmd/cache-server.go index 033f91d2..8701b558 100644 --- a/internal/app/cmd/cache-server.go +++ b/internal/app/cmd/cache-server.go @@ -9,7 +9,7 @@ import ( "os" "os/signal" - "gitea.com/gitea/act_runner/internal/pkg/config" + "runner.forgejo.org/internal/pkg/config" "github.com/nektos/act/pkg/artifactcache" log "github.com/sirupsen/logrus" diff --git a/internal/app/cmd/cmd.go b/internal/app/cmd/cmd.go index 390c5068..d4f7ce8a 100644 --- a/internal/app/cmd/cmd.go +++ b/internal/app/cmd/cmd.go @@ -10,8 +10,8 @@ import ( "github.com/spf13/cobra" - "gitea.com/gitea/act_runner/internal/pkg/config" - "gitea.com/gitea/act_runner/internal/pkg/ver" + "runner.forgejo.org/internal/pkg/config" + "runner.forgejo.org/internal/pkg/ver" ) func Execute(ctx context.Context) { diff --git a/internal/app/cmd/create-runner-file.go b/internal/app/cmd/create-runner-file.go index 09cf00f0..9e60842e 100644 --- a/internal/app/cmd/create-runner-file.go +++ b/internal/app/cmd/create-runner-file.go @@ -14,10 +14,10 @@ import ( log "github.com/sirupsen/logrus" "github.com/spf13/cobra" - "gitea.com/gitea/act_runner/internal/app/run" - "gitea.com/gitea/act_runner/internal/pkg/client" - "gitea.com/gitea/act_runner/internal/pkg/config" - "gitea.com/gitea/act_runner/internal/pkg/ver" + "runner.forgejo.org/internal/app/run" + "runner.forgejo.org/internal/pkg/client" + "runner.forgejo.org/internal/pkg/config" + "runner.forgejo.org/internal/pkg/ver" ) type createRunnerFileArgs struct { diff --git a/internal/app/cmd/create-runner-file_test.go b/internal/app/cmd/create-runner-file_test.go index 1d84faf4..f2eb68bf 100644 --- a/internal/app/cmd/create-runner-file_test.go +++ b/internal/app/cmd/create-runner-file_test.go @@ -10,9 +10,9 @@ import ( runnerv1 "code.forgejo.org/forgejo/actions-proto/runner/v1" "connectrpc.com/connect" - "gitea.com/gitea/act_runner/internal/pkg/client" - "gitea.com/gitea/act_runner/internal/pkg/config" - "gitea.com/gitea/act_runner/internal/pkg/ver" + "runner.forgejo.org/internal/pkg/client" + "runner.forgejo.org/internal/pkg/config" + "runner.forgejo.org/internal/pkg/ver" "github.com/spf13/cobra" "github.com/stretchr/testify/assert" diff --git a/internal/app/cmd/daemon.go b/internal/app/cmd/daemon.go index a02f36d6..def8f4af 100644 --- a/internal/app/cmd/daemon.go +++ b/internal/app/cmd/daemon.go @@ -18,13 +18,13 @@ import ( log "github.com/sirupsen/logrus" "github.com/spf13/cobra" - "gitea.com/gitea/act_runner/internal/app/poll" - "gitea.com/gitea/act_runner/internal/app/run" - "gitea.com/gitea/act_runner/internal/pkg/client" - "gitea.com/gitea/act_runner/internal/pkg/config" - "gitea.com/gitea/act_runner/internal/pkg/envcheck" - "gitea.com/gitea/act_runner/internal/pkg/labels" - "gitea.com/gitea/act_runner/internal/pkg/ver" + "runner.forgejo.org/internal/app/poll" + "runner.forgejo.org/internal/app/run" + "runner.forgejo.org/internal/pkg/client" + "runner.forgejo.org/internal/pkg/config" + "runner.forgejo.org/internal/pkg/envcheck" + "runner.forgejo.org/internal/pkg/labels" + "runner.forgejo.org/internal/pkg/ver" ) func runDaemon(ctx context.Context, configFile *string) func(cmd *cobra.Command, args []string) error { @@ -99,7 +99,6 @@ func runDaemon(ctx context.Context, configFile *string) func(cmd *cobra.Command, // declare the labels of the runner before fetching tasks resp, err := runner.Declare(ctx, ls.Names()) if err != nil && connect.CodeOf(err) == connect.CodeUnimplemented { - // Gitea instance is older version. skip declare step. log.Warn("Because the Forgejo instance is an old version, skipping declaring the labels and version.") } else if err != nil { log.WithError(err).Error("fail to invoke Declare") diff --git a/internal/app/cmd/exec.go b/internal/app/cmd/exec.go index ff84019b..d5c22a1c 100644 --- a/internal/app/cmd/exec.go +++ b/internal/app/cmd/exec.go @@ -382,7 +382,7 @@ func runExec(ctx context.Context, execArgs *executeArgs) func(cmd *cobra.Command } if len(execArgs.artifactServerPath) == 0 { - tempDir, err := os.MkdirTemp("", "gitea-act-") + tempDir, err := os.MkdirTemp("", "forgejo-runner-") if err != nil { fmt.Println(err) } @@ -509,7 +509,7 @@ func loadExecCmd(ctx context.Context) *cobra.Command { execCmd.PersistentFlags().StringVarP(&execArg.image, "image", "i", "node:20-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.") + execCmd.PersistentFlags().StringVarP(&execArg.githubInstance, "forgejo-instance", "", "", "Forgejo instance to use.") return execCmd } diff --git a/internal/app/cmd/job.go b/internal/app/cmd/job.go index a4ded060..f3e7ad8b 100644 --- a/internal/app/cmd/job.go +++ b/internal/app/cmd/job.go @@ -13,13 +13,13 @@ import ( log "github.com/sirupsen/logrus" "github.com/spf13/cobra" - "gitea.com/gitea/act_runner/internal/app/job" - "gitea.com/gitea/act_runner/internal/app/run" - "gitea.com/gitea/act_runner/internal/pkg/client" - "gitea.com/gitea/act_runner/internal/pkg/config" - "gitea.com/gitea/act_runner/internal/pkg/envcheck" - "gitea.com/gitea/act_runner/internal/pkg/labels" - "gitea.com/gitea/act_runner/internal/pkg/ver" + "runner.forgejo.org/internal/app/job" + "runner.forgejo.org/internal/app/run" + "runner.forgejo.org/internal/pkg/client" + "runner.forgejo.org/internal/pkg/config" + "runner.forgejo.org/internal/pkg/envcheck" + "runner.forgejo.org/internal/pkg/labels" + "runner.forgejo.org/internal/pkg/ver" ) func runJob(ctx context.Context, configFile *string) func(cmd *cobra.Command, args []string) error { @@ -95,7 +95,6 @@ func runJob(ctx context.Context, configFile *string) func(cmd *cobra.Command, ar // declare the labels of the runner before fetching tasks resp, err := runner.Declare(ctx, ls.Names()) if err != nil && connect.CodeOf(err) == connect.CodeUnimplemented { - // Gitea instance is older version. skip declare step. log.Warn("Because the Forgejo instance is an old version, skipping declaring the labels and version.") } else if err != nil { log.WithError(err).Error("fail to invoke Declare") diff --git a/internal/app/cmd/register.go b/internal/app/cmd/register.go index 43633a40..c036448d 100644 --- a/internal/app/cmd/register.go +++ b/internal/app/cmd/register.go @@ -20,10 +20,10 @@ import ( log "github.com/sirupsen/logrus" "github.com/spf13/cobra" - "gitea.com/gitea/act_runner/internal/pkg/client" - "gitea.com/gitea/act_runner/internal/pkg/config" - "gitea.com/gitea/act_runner/internal/pkg/labels" - "gitea.com/gitea/act_runner/internal/pkg/ver" + "runner.forgejo.org/internal/pkg/client" + "runner.forgejo.org/internal/pkg/config" + "runner.forgejo.org/internal/pkg/labels" + "runner.forgejo.org/internal/pkg/ver" ) // runRegister registers a runner to the server diff --git a/internal/app/job/job.go b/internal/app/job/job.go index ec0ad92e..ee84f93c 100644 --- a/internal/app/job/job.go +++ b/internal/app/job/job.go @@ -13,9 +13,9 @@ import ( log "github.com/sirupsen/logrus" runnerv1 "code.forgejo.org/forgejo/actions-proto/runner/v1" - "gitea.com/gitea/act_runner/internal/app/run" - "gitea.com/gitea/act_runner/internal/pkg/client" - "gitea.com/gitea/act_runner/internal/pkg/config" + "runner.forgejo.org/internal/app/run" + "runner.forgejo.org/internal/pkg/client" + "runner.forgejo.org/internal/pkg/config" ) type Job struct { diff --git a/internal/app/job/job_test.go b/internal/app/job/job_test.go index 19b05d29..22784a5a 100644 --- a/internal/app/job/job_test.go +++ b/internal/app/job/job_test.go @@ -11,7 +11,7 @@ import ( "code.forgejo.org/forgejo/actions-proto/ping/v1/pingv1connect" runnerv1 "code.forgejo.org/forgejo/actions-proto/runner/v1" "code.forgejo.org/forgejo/actions-proto/runner/v1/runnerv1connect" - "gitea.com/gitea/act_runner/internal/pkg/config" + "runner.forgejo.org/internal/pkg/config" log "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" diff --git a/internal/app/poll/poller.go b/internal/app/poll/poller.go index 6fd3e027..0afadb4e 100644 --- a/internal/app/poll/poller.go +++ b/internal/app/poll/poller.go @@ -15,9 +15,9 @@ import ( log "github.com/sirupsen/logrus" "golang.org/x/time/rate" - "gitea.com/gitea/act_runner/internal/app/run" - "gitea.com/gitea/act_runner/internal/pkg/client" - "gitea.com/gitea/act_runner/internal/pkg/config" + "runner.forgejo.org/internal/app/run" + "runner.forgejo.org/internal/pkg/client" + "runner.forgejo.org/internal/pkg/config" ) const PollerID = "PollerID" diff --git a/internal/app/poll/poller_test.go b/internal/app/poll/poller_test.go index 2df133d3..ed0dd89c 100644 --- a/internal/app/poll/poller_test.go +++ b/internal/app/poll/poller_test.go @@ -14,7 +14,7 @@ import ( "code.forgejo.org/forgejo/actions-proto/ping/v1/pingv1connect" runnerv1 "code.forgejo.org/forgejo/actions-proto/runner/v1" "code.forgejo.org/forgejo/actions-proto/runner/v1/runnerv1connect" - "gitea.com/gitea/act_runner/internal/pkg/config" + "runner.forgejo.org/internal/pkg/config" log "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" diff --git a/internal/app/run/runner.go b/internal/app/run/runner.go index 4f121514..1e4eb8e8 100644 --- a/internal/app/run/runner.go +++ b/internal/app/run/runner.go @@ -25,11 +25,11 @@ import ( "github.com/nektos/act/pkg/runner" log "github.com/sirupsen/logrus" - "gitea.com/gitea/act_runner/internal/pkg/client" - "gitea.com/gitea/act_runner/internal/pkg/config" - "gitea.com/gitea/act_runner/internal/pkg/labels" - "gitea.com/gitea/act_runner/internal/pkg/report" - "gitea.com/gitea/act_runner/internal/pkg/ver" + "runner.forgejo.org/internal/pkg/client" + "runner.forgejo.org/internal/pkg/config" + "runner.forgejo.org/internal/pkg/labels" + "runner.forgejo.org/internal/pkg/report" + "runner.forgejo.org/internal/pkg/ver" ) // Runner runs the pipeline. @@ -77,15 +77,16 @@ func NewRunner(cfg *config.Config, reg *config.Registration, cli client.Client) cacheProxy = nil } - // set artifact gitea api - artifactGiteaAPI := strings.TrimSuffix(cli.Address(), "/") + "/api/actions_pipeline/" - envs["ACTIONS_RUNTIME_URL"] = artifactGiteaAPI + artifactAPI := strings.TrimSuffix(cli.Address(), "/") + "/api/actions_pipeline/" + envs["ACTIONS_RUNTIME_URL"] = artifactAPI envs["ACTIONS_RESULTS_URL"] = strings.TrimSuffix(cli.Address(), "/") - // Set specific environments to distinguish between Gitea and GitHub envs["GITEA_ACTIONS"] = "true" envs["GITEA_ACTIONS_RUNNER_VERSION"] = ver.Version() + envs["FORGEJO_ACTIONS"] = "true" + envs["FORGEJO_ACTIONS_RUNNER_VERSION"] = ver.Version() + return &Runner{ name: reg.Name, cfg: cfg, @@ -205,8 +206,12 @@ func (r *Runner) run(ctx context.Context, task *runnerv1.Task, reporter *report. taskContext := task.Context.Fields + defaultActionURL := client.BackwardCompatibleContext(task, "default_actions_url") + if defaultActionURL == "" { + return fmt.Errorf("task %v context does not contain a {forgejo,gitea}_default_actions_url key", task.Id) + } log.Infof("task %v repo is %v %v %v", task.Id, taskContext["repository"].GetStringValue(), - taskContext["gitea_default_actions_url"].GetStringValue(), + defaultActionURL, r.client.Address()) preset := &model.GithubContext{ @@ -240,12 +245,12 @@ func (r *Runner) run(ctx context.Context, task *runnerv1.Task, reporter *report. runEnvs[id] = v } - giteaRuntimeToken := taskContext["gitea_runtime_token"].GetStringValue() - if giteaRuntimeToken == "" { + runtimeToken := client.BackwardCompatibleContext(task, "runtime_token") + if runtimeToken == "" { // use task token to action api token for previous Gitea Server Versions - giteaRuntimeToken = preset.Token + runtimeToken = preset.Token } - runEnvs["ACTIONS_RUNTIME_TOKEN"] = giteaRuntimeToken + runEnvs["ACTIONS_RUNTIME_TOKEN"] = runtimeToken // Register the run with the cacheproxy and modify the CACHE_URL if r.cacheProxy != nil { @@ -302,7 +307,7 @@ func (r *Runner) run(ctx context.Context, task *runnerv1.Task, reporter *report. ContainerOptions: r.cfg.Container.Options, ContainerDaemonSocket: r.cfg.Container.DockerHost, Privileged: r.cfg.Container.Privileged, - DefaultActionInstance: taskContext["gitea_default_actions_url"].GetStringValue(), + DefaultActionInstance: defaultActionURL, PlatformPicker: r.labels.PickPlatform, Vars: task.Vars, ValidVolumes: r.cfg.Container.ValidVolumes, diff --git a/internal/app/run/runner_test.go b/internal/app/run/runner_test.go index 0145c706..09428944 100644 --- a/internal/app/run/runner_test.go +++ b/internal/app/run/runner_test.go @@ -4,7 +4,8 @@ import ( "context" "testing" - "gitea.com/gitea/act_runner/internal/pkg/labels" + "runner.forgejo.org/internal/pkg/labels" + "github.com/stretchr/testify/assert" ) diff --git a/internal/pkg/client/backward.go b/internal/pkg/client/backward.go new file mode 100644 index 00000000..02f1dc16 --- /dev/null +++ b/internal/pkg/client/backward.go @@ -0,0 +1,18 @@ +// Copyright 2025 The Forgejo Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package client + +import ( + runnerv1 "code.forgejo.org/forgejo/actions-proto/runner/v1" +) + +func BackwardCompatibleContext(task *runnerv1.Task, suffix string) string { + for _, prefix := range []string{"forgejo_", "gitea_"} { + value := task.Context.Fields[prefix+suffix] + if value != nil { + return value.GetStringValue() + } + } + return "" +} diff --git a/internal/pkg/report/reporter.go b/internal/pkg/report/reporter.go index 1cbe19b4..11f00d99 100644 --- a/internal/pkg/report/reporter.go +++ b/internal/pkg/report/reporter.go @@ -18,7 +18,7 @@ import ( "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/timestamppb" - "gitea.com/gitea/act_runner/internal/pkg/client" + "runner.forgejo.org/internal/pkg/client" ) type Reporter struct { @@ -43,12 +43,12 @@ type Reporter struct { stopCommandEndToken string } -func NewReporter(ctx context.Context, cancel context.CancelFunc, client client.Client, task *runnerv1.Task, reportInterval time.Duration) *Reporter { +func NewReporter(ctx context.Context, cancel context.CancelFunc, c client.Client, task *runnerv1.Task, reportInterval time.Duration) *Reporter { var oldnew []string if v := task.Context.Fields["token"].GetStringValue(); v != "" { oldnew = append(oldnew, v, "***") } - if v := task.Context.Fields["gitea_runtime_token"].GetStringValue(); v != "" { + if v := client.BackwardCompatibleContext(task, "runtime_token"); v != "" { oldnew = append(oldnew, v, "***") } for _, v := range task.Secrets { @@ -58,7 +58,7 @@ func NewReporter(ctx context.Context, cancel context.CancelFunc, client client.C rv := &Reporter{ ctx: ctx, cancel: cancel, - client: client, + client: c, oldnew: oldnew, reportInterval: reportInterval, logReplacer: strings.NewReplacer(oldnew...), diff --git a/internal/pkg/report/reporter_test.go b/internal/pkg/report/reporter_test.go index 0b9379b2..cbf1be97 100644 --- a/internal/pkg/report/reporter_test.go +++ b/internal/pkg/report/reporter_test.go @@ -17,7 +17,7 @@ import ( "github.com/stretchr/testify/require" "google.golang.org/protobuf/types/known/structpb" - "gitea.com/gitea/act_runner/internal/pkg/client/mocks" + "runner.forgejo.org/internal/pkg/client/mocks" ) func TestReporter_parseLogRow(t *testing.T) { diff --git a/internal/pkg/ver/version.go b/internal/pkg/ver/version.go index 3c07a189..cbf46414 100644 --- a/internal/pkg/ver/version.go +++ b/internal/pkg/ver/version.go @@ -3,7 +3,7 @@ package ver -// go build -ldflags "-X gitea.com/gitea/act_runner/internal/pkg/ver.version=1.2.3" +// go build -ldflags "-X runner.forgejo.org/internal/pkg/ver.version=1.2.3" var version = "dev" func Version() string { diff --git a/main.go b/main.go index 4adbd13f..40886589 100644 --- a/main.go +++ b/main.go @@ -8,7 +8,7 @@ import ( "os/signal" "syscall" - "gitea.com/gitea/act_runner/internal/app/cmd" + "runner.forgejo.org/internal/app/cmd" ) func main() {