1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-09-15 18:57:01 +00:00

assorted set of fixes and features for rebranding (#652)

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/652
Reviewed-by: Gusted <gusted@noreply.code.forgejo.org>
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
This commit is contained in:
earl-warren 2025-07-06 06:59:00 +00:00
commit df2524586e
No known key found for this signature in database
GPG key ID: F128CBE6AB3A7201
27 changed files with 90 additions and 95 deletions

View file

@ -25,7 +25,7 @@ jobs:
run: | run: |
env GOOS=windows GOARCH=${{matrix.architecture}} \ env GOOS=windows GOARCH=${{matrix.architecture}} \
go build \ 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 -o forgejo-runner-windows-${{matrix.architecture}}.exe
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
@ -149,4 +149,3 @@ jobs:
token: ${{ secrets.RELEASE_TOKEN }} token: ${{ secrets.RELEASE_TOKEN }}
fail_on_unmatched_files: true fail_on_unmatched_files: true
body: See [original release notes](https://code.forgejo.org/forgejo/runner/releases/tag/${{ github.ref_name }}). body: See [original release notes](https://code.forgejo.org/forgejo/runner/releases/tag/${{ github.ref_name }}).

1
.gitignore vendored
View file

@ -4,7 +4,6 @@ forgejo-runner
.env .env
.runner .runner
coverage.txt coverage.txt
/gitea-vet
/config.yaml /config.yaml
# MS VSCode # MS VSCode

View file

@ -74,12 +74,8 @@ linters-settings:
extra-rules: true extra-rules: true
lang-version: "1.18" lang-version: "1.18"
depguard: depguard:
# TODO: use depguard to replace import checks in gitea-vet
list-type: denylist list-type: denylist
# Check the list against standard lib.
include-go-root: true include-go-root: true
packages-with-error-message:
- github.com/unknwon/com: "use gitea's util and replacements"
issues: issues:
exclude-rules: exclude-rules:

View file

@ -1,4 +1,4 @@
Copyright (c) 2023 The Forgejo Authors Copyright (c) 2023-2025 The Forgejo Authors
Copyright (c) 2022 The Gitea Authors Copyright (c) 2022 The Gitea Authors
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy

View file

@ -61,11 +61,11 @@ else
endif endif
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 ?= 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 all: build

View file

@ -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"
)

4
go.mod
View file

@ -1,4 +1,4 @@
module gitea.com/gitea/act_runner module runner.forgejo.org
go 1.23.0 go 1.23.0
@ -6,7 +6,6 @@ toolchain go1.23.10
require ( require (
code.forgejo.org/forgejo/actions-proto v0.5.1 code.forgejo.org/forgejo/actions-proto v0.5.1
code.gitea.io/gitea-vet v0.2.3
connectrpc.com/connect v1.18.1 connectrpc.com/connect v1.18.1
github.com/avast/retry-go/v4 v4.6.1 github.com/avast/retry-go/v4 v4.6.1
github.com/docker/docker v28.3.0+incompatible github.com/docker/docker v28.3.0+incompatible
@ -100,7 +99,6 @@ require (
golang.org/x/net v0.38.0 // indirect golang.org/x/net v0.38.0 // indirect
golang.org/x/sync v0.12.0 // indirect golang.org/x/sync v0.12.0 // indirect
golang.org/x/sys v0.33.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 gopkg.in/warnings.v0 v0.1.2 // indirect
) )

8
go.sum
View file

@ -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/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 h1:GCJHR/Y/Apk7Yl7CH9qOsKrdf/k0tRVFeVhz1EIZvb4=
code.forgejo.org/forgejo/actions-proto v0.5.1/go.mod h1:nu8N1HQLsu3c4T/PpYWbqwNBxsZnEOVxqV0mQWtIQvE= 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 h1:PAg7CjSAGvscaf6YZKUefjoih5Z/qYkyaTrBW8xvYPw=
connectrpc.com/connect v1.18.1/go.mod h1:0292hj1rnx8oFrStN7cB4jjVBeqs+Yx5yDIC2prWDO8= connectrpc.com/connect v1.18.1/go.mod h1:0292hj1rnx8oFrStN7cB4jjVBeqs+Yx5yDIC2prWDO8=
dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= 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/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 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= 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.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/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= 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/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.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.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-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-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= 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/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-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-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-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.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-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-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

View file

@ -9,7 +9,7 @@ import (
"os" "os"
"os/signal" "os/signal"
"gitea.com/gitea/act_runner/internal/pkg/config" "runner.forgejo.org/internal/pkg/config"
"github.com/nektos/act/pkg/artifactcache" "github.com/nektos/act/pkg/artifactcache"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"

View file

@ -10,8 +10,8 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"gitea.com/gitea/act_runner/internal/pkg/config" "runner.forgejo.org/internal/pkg/config"
"gitea.com/gitea/act_runner/internal/pkg/ver" "runner.forgejo.org/internal/pkg/ver"
) )
func Execute(ctx context.Context) { func Execute(ctx context.Context) {

View file

@ -14,10 +14,10 @@ import (
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"gitea.com/gitea/act_runner/internal/app/run" "runner.forgejo.org/internal/app/run"
"gitea.com/gitea/act_runner/internal/pkg/client" "runner.forgejo.org/internal/pkg/client"
"gitea.com/gitea/act_runner/internal/pkg/config" "runner.forgejo.org/internal/pkg/config"
"gitea.com/gitea/act_runner/internal/pkg/ver" "runner.forgejo.org/internal/pkg/ver"
) )
type createRunnerFileArgs struct { type createRunnerFileArgs struct {

View file

@ -10,9 +10,9 @@ import (
runnerv1 "code.forgejo.org/forgejo/actions-proto/runner/v1" runnerv1 "code.forgejo.org/forgejo/actions-proto/runner/v1"
"connectrpc.com/connect" "connectrpc.com/connect"
"gitea.com/gitea/act_runner/internal/pkg/client" "runner.forgejo.org/internal/pkg/client"
"gitea.com/gitea/act_runner/internal/pkg/config" "runner.forgejo.org/internal/pkg/config"
"gitea.com/gitea/act_runner/internal/pkg/ver" "runner.forgejo.org/internal/pkg/ver"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"

View file

@ -18,13 +18,13 @@ import (
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"gitea.com/gitea/act_runner/internal/app/poll" "runner.forgejo.org/internal/app/poll"
"gitea.com/gitea/act_runner/internal/app/run" "runner.forgejo.org/internal/app/run"
"gitea.com/gitea/act_runner/internal/pkg/client" "runner.forgejo.org/internal/pkg/client"
"gitea.com/gitea/act_runner/internal/pkg/config" "runner.forgejo.org/internal/pkg/config"
"gitea.com/gitea/act_runner/internal/pkg/envcheck" "runner.forgejo.org/internal/pkg/envcheck"
"gitea.com/gitea/act_runner/internal/pkg/labels" "runner.forgejo.org/internal/pkg/labels"
"gitea.com/gitea/act_runner/internal/pkg/ver" "runner.forgejo.org/internal/pkg/ver"
) )
func runDaemon(ctx context.Context, configFile *string) func(cmd *cobra.Command, args []string) error { 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 // declare the labels of the runner before fetching tasks
resp, err := runner.Declare(ctx, ls.Names()) resp, err := runner.Declare(ctx, ls.Names())
if err != nil && connect.CodeOf(err) == connect.CodeUnimplemented { 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.") log.Warn("Because the Forgejo instance is an old version, skipping declaring the labels and version.")
} else if err != nil { } else if err != nil {
log.WithError(err).Error("fail to invoke Declare") log.WithError(err).Error("fail to invoke Declare")

View file

@ -382,7 +382,7 @@ func runExec(ctx context.Context, execArgs *executeArgs) func(cmd *cobra.Command
} }
if len(execArgs.artifactServerPath) == 0 { if len(execArgs.artifactServerPath) == 0 {
tempDir, err := os.MkdirTemp("", "gitea-act-") tempDir, err := os.MkdirTemp("", "forgejo-runner-")
if err != nil { if err != nil {
fmt.Println(err) 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.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().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, "forgejo-instance", "", "", "Forgejo instance to use.")
return execCmd return execCmd
} }

View file

@ -13,13 +13,13 @@ import (
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"gitea.com/gitea/act_runner/internal/app/job" "runner.forgejo.org/internal/app/job"
"gitea.com/gitea/act_runner/internal/app/run" "runner.forgejo.org/internal/app/run"
"gitea.com/gitea/act_runner/internal/pkg/client" "runner.forgejo.org/internal/pkg/client"
"gitea.com/gitea/act_runner/internal/pkg/config" "runner.forgejo.org/internal/pkg/config"
"gitea.com/gitea/act_runner/internal/pkg/envcheck" "runner.forgejo.org/internal/pkg/envcheck"
"gitea.com/gitea/act_runner/internal/pkg/labels" "runner.forgejo.org/internal/pkg/labels"
"gitea.com/gitea/act_runner/internal/pkg/ver" "runner.forgejo.org/internal/pkg/ver"
) )
func runJob(ctx context.Context, configFile *string) func(cmd *cobra.Command, args []string) error { 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 // declare the labels of the runner before fetching tasks
resp, err := runner.Declare(ctx, ls.Names()) resp, err := runner.Declare(ctx, ls.Names())
if err != nil && connect.CodeOf(err) == connect.CodeUnimplemented { 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.") log.Warn("Because the Forgejo instance is an old version, skipping declaring the labels and version.")
} else if err != nil { } else if err != nil {
log.WithError(err).Error("fail to invoke Declare") log.WithError(err).Error("fail to invoke Declare")

View file

@ -20,10 +20,10 @@ import (
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"gitea.com/gitea/act_runner/internal/pkg/client" "runner.forgejo.org/internal/pkg/client"
"gitea.com/gitea/act_runner/internal/pkg/config" "runner.forgejo.org/internal/pkg/config"
"gitea.com/gitea/act_runner/internal/pkg/labels" "runner.forgejo.org/internal/pkg/labels"
"gitea.com/gitea/act_runner/internal/pkg/ver" "runner.forgejo.org/internal/pkg/ver"
) )
// runRegister registers a runner to the server // runRegister registers a runner to the server

View file

@ -13,9 +13,9 @@ import (
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
runnerv1 "code.forgejo.org/forgejo/actions-proto/runner/v1" runnerv1 "code.forgejo.org/forgejo/actions-proto/runner/v1"
"gitea.com/gitea/act_runner/internal/app/run" "runner.forgejo.org/internal/app/run"
"gitea.com/gitea/act_runner/internal/pkg/client" "runner.forgejo.org/internal/pkg/client"
"gitea.com/gitea/act_runner/internal/pkg/config" "runner.forgejo.org/internal/pkg/config"
) )
type Job struct { type Job struct {

View file

@ -11,7 +11,7 @@ import (
"code.forgejo.org/forgejo/actions-proto/ping/v1/pingv1connect" "code.forgejo.org/forgejo/actions-proto/ping/v1/pingv1connect"
runnerv1 "code.forgejo.org/forgejo/actions-proto/runner/v1" runnerv1 "code.forgejo.org/forgejo/actions-proto/runner/v1"
"code.forgejo.org/forgejo/actions-proto/runner/v1/runnerv1connect" "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" log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"

View file

@ -15,9 +15,9 @@ import (
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"golang.org/x/time/rate" "golang.org/x/time/rate"
"gitea.com/gitea/act_runner/internal/app/run" "runner.forgejo.org/internal/app/run"
"gitea.com/gitea/act_runner/internal/pkg/client" "runner.forgejo.org/internal/pkg/client"
"gitea.com/gitea/act_runner/internal/pkg/config" "runner.forgejo.org/internal/pkg/config"
) )
const PollerID = "PollerID" const PollerID = "PollerID"

View file

@ -14,7 +14,7 @@ import (
"code.forgejo.org/forgejo/actions-proto/ping/v1/pingv1connect" "code.forgejo.org/forgejo/actions-proto/ping/v1/pingv1connect"
runnerv1 "code.forgejo.org/forgejo/actions-proto/runner/v1" runnerv1 "code.forgejo.org/forgejo/actions-proto/runner/v1"
"code.forgejo.org/forgejo/actions-proto/runner/v1/runnerv1connect" "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" log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"

View file

@ -25,11 +25,11 @@ import (
"github.com/nektos/act/pkg/runner" "github.com/nektos/act/pkg/runner"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"gitea.com/gitea/act_runner/internal/pkg/client" "runner.forgejo.org/internal/pkg/client"
"gitea.com/gitea/act_runner/internal/pkg/config" "runner.forgejo.org/internal/pkg/config"
"gitea.com/gitea/act_runner/internal/pkg/labels" "runner.forgejo.org/internal/pkg/labels"
"gitea.com/gitea/act_runner/internal/pkg/report" "runner.forgejo.org/internal/pkg/report"
"gitea.com/gitea/act_runner/internal/pkg/ver" "runner.forgejo.org/internal/pkg/ver"
) )
// Runner runs the pipeline. // Runner runs the pipeline.
@ -77,15 +77,16 @@ func NewRunner(cfg *config.Config, reg *config.Registration, cli client.Client)
cacheProxy = nil cacheProxy = nil
} }
// set artifact gitea api artifactAPI := strings.TrimSuffix(cli.Address(), "/") + "/api/actions_pipeline/"
artifactGiteaAPI := strings.TrimSuffix(cli.Address(), "/") + "/api/actions_pipeline/" envs["ACTIONS_RUNTIME_URL"] = artifactAPI
envs["ACTIONS_RUNTIME_URL"] = artifactGiteaAPI
envs["ACTIONS_RESULTS_URL"] = strings.TrimSuffix(cli.Address(), "/") envs["ACTIONS_RESULTS_URL"] = strings.TrimSuffix(cli.Address(), "/")
// Set specific environments to distinguish between Gitea and GitHub
envs["GITEA_ACTIONS"] = "true" envs["GITEA_ACTIONS"] = "true"
envs["GITEA_ACTIONS_RUNNER_VERSION"] = ver.Version() envs["GITEA_ACTIONS_RUNNER_VERSION"] = ver.Version()
envs["FORGEJO_ACTIONS"] = "true"
envs["FORGEJO_ACTIONS_RUNNER_VERSION"] = ver.Version()
return &Runner{ return &Runner{
name: reg.Name, name: reg.Name,
cfg: cfg, cfg: cfg,
@ -205,8 +206,12 @@ func (r *Runner) run(ctx context.Context, task *runnerv1.Task, reporter *report.
taskContext := task.Context.Fields 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(), log.Infof("task %v repo is %v %v %v", task.Id, taskContext["repository"].GetStringValue(),
taskContext["gitea_default_actions_url"].GetStringValue(), defaultActionURL,
r.client.Address()) r.client.Address())
preset := &model.GithubContext{ preset := &model.GithubContext{
@ -240,12 +245,12 @@ func (r *Runner) run(ctx context.Context, task *runnerv1.Task, reporter *report.
runEnvs[id] = v runEnvs[id] = v
} }
giteaRuntimeToken := taskContext["gitea_runtime_token"].GetStringValue() runtimeToken := client.BackwardCompatibleContext(task, "runtime_token")
if giteaRuntimeToken == "" { if runtimeToken == "" {
// use task token to action api token for previous Gitea Server Versions // 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 // Register the run with the cacheproxy and modify the CACHE_URL
if r.cacheProxy != nil { 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, ContainerOptions: r.cfg.Container.Options,
ContainerDaemonSocket: r.cfg.Container.DockerHost, ContainerDaemonSocket: r.cfg.Container.DockerHost,
Privileged: r.cfg.Container.Privileged, Privileged: r.cfg.Container.Privileged,
DefaultActionInstance: taskContext["gitea_default_actions_url"].GetStringValue(), DefaultActionInstance: defaultActionURL,
PlatformPicker: r.labels.PickPlatform, PlatformPicker: r.labels.PickPlatform,
Vars: task.Vars, Vars: task.Vars,
ValidVolumes: r.cfg.Container.ValidVolumes, ValidVolumes: r.cfg.Container.ValidVolumes,

View file

@ -4,7 +4,8 @@ import (
"context" "context"
"testing" "testing"
"gitea.com/gitea/act_runner/internal/pkg/labels" "runner.forgejo.org/internal/pkg/labels"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )

View file

@ -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 ""
}

View file

@ -18,7 +18,7 @@ import (
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/timestamppb" "google.golang.org/protobuf/types/known/timestamppb"
"gitea.com/gitea/act_runner/internal/pkg/client" "runner.forgejo.org/internal/pkg/client"
) )
type Reporter struct { type Reporter struct {
@ -43,12 +43,12 @@ type Reporter struct {
stopCommandEndToken string 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 var oldnew []string
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 != "" { if v := client.BackwardCompatibleContext(task, "runtime_token"); v != "" {
oldnew = append(oldnew, v, "***") oldnew = append(oldnew, v, "***")
} }
for _, v := range task.Secrets { for _, v := range task.Secrets {
@ -58,7 +58,7 @@ func NewReporter(ctx context.Context, cancel context.CancelFunc, client client.C
rv := &Reporter{ rv := &Reporter{
ctx: ctx, ctx: ctx,
cancel: cancel, cancel: cancel,
client: client, client: c,
oldnew: oldnew, oldnew: oldnew,
reportInterval: reportInterval, reportInterval: reportInterval,
logReplacer: strings.NewReplacer(oldnew...), logReplacer: strings.NewReplacer(oldnew...),

View file

@ -17,7 +17,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"google.golang.org/protobuf/types/known/structpb" "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) { func TestReporter_parseLogRow(t *testing.T) {

View file

@ -3,7 +3,7 @@
package ver 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" var version = "dev"
func Version() string { func Version() string {

View file

@ -8,7 +8,7 @@ import (
"os/signal" "os/signal"
"syscall" "syscall"
"gitea.com/gitea/act_runner/internal/app/cmd" "runner.forgejo.org/internal/app/cmd"
) )
func main() { func main() {