refactor: move act/model and act/exprparser to actionslib (#1143)

Gitea needs the workflow model and the expression evaluator to parse workflows and to build the task payload this runner consumes, so today it depends on `gitea.com/gitea/runner` just for `act/model` and `act/exprparser`. Both packages now live in `gitea.dev/actionslib` (`pkg/model`, `pkg/exprparser`), the module both sides already share, and this repository consumes them from there.

### Changes

- `act/model` and `act/exprparser` are deleted, all imports point at `gitea.dev/actionslib/pkg/...`.
- New `act/ghcontext` package: the `GithubContext` helpers that need a git checkout on disk (`SetRef`, `SetSha`, `SetRepositoryAndOwner`) are runner only and would drag a git client plus the act context logger into the shared module, so they stay here as functions, with their tests. Only caller is `RunContext.getGithubContext`.
- `act/common.CartesianProduct` moved to the shared model package, `act/model` was its only user.
- `act/model/testdata/container-volumes` moved to `act/runner/testdata/container-volumes`, its only user is `runner_test.go`.
- `internal/pkg/client.UUIDHeader` / `TokenHeader` now alias `pkg/protocol`, so the header names cannot drift apart from Gitea.

### Notes

- No behaviour change intended: the moved files are unchanged apart from the import paths and the split described above.
- `go.mod` depends on the released `gitea.dev/actionslib v0.7.0`, which carries both https://gitea.com/gitea/actionslib/pulls/11 and the `model.UsesHash` port in https://gitea.com/gitea/actionslib/pulls/14 that `main` needs after https://gitea.com/gitea/runner/pulls/1150.
- Verified with `go build ./...`, `go vet ./...` and `go test ./act/... ./internal/...`; the docker based `act/runner` integration tests (`TestRunEvent`, `TestRunMatrixWithUserDefinedInclusions`) fail identically with and without this change in my environment.

Assisted-by: Codet:GPT-5.1-Codex
Reviewed-on: https://gitea.com/gitea/runner/pulls/1143
Reviewed-by: silverwind <[email protected]>
This commit is contained in:
Lunny Xiao
2026-08-08 00:29:15 +00:00
parent da9b559fb5
commit a8dcd5b67c
87 changed files with 247 additions and 5735 deletions
+1 -1
View File
@@ -20,10 +20,10 @@ import (
"gitea.com/gitea/runner/act/artifactcache"
"gitea.com/gitea/runner/act/artifacts"
"gitea.com/gitea/runner/act/common"
"gitea.com/gitea/runner/act/model"
"gitea.com/gitea/runner/act/runner"
"gitea.com/gitea/runner/internal/app/run"
"gitea.dev/actionslib/pkg/model"
"github.com/joho/godotenv"
"github.com/moby/moby/api/types/container"
log "github.com/sirupsen/logrus"
+1 -2
View File
@@ -12,8 +12,7 @@ import (
"strings"
"testing"
"gitea.com/gitea/runner/act/model"
"gitea.dev/actionslib/pkg/model"
"github.com/stretchr/testify/require"
"go.yaml.in/yaml/v4"
)
+2 -2
View File
@@ -22,8 +22,8 @@ import (
"gitea.com/gitea/runner/internal/pkg/ver"
"connectrpc.com/connect"
pingv1 "gitea.dev/actions-proto-go/ping/v1"
runnerv1 "gitea.dev/actions-proto-go/runner/v1"
pingv1 "gitea.dev/actionslib/ping/v1"
runnerv1 "gitea.dev/actionslib/runner/v1"
"github.com/mattn/go-isatty"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
+1 -1
View File
@@ -17,7 +17,7 @@ import (
"gitea.com/gitea/runner/internal/pkg/metrics"
"connectrpc.com/connect"
runnerv1 "gitea.dev/actions-proto-go/runner/v1"
runnerv1 "gitea.dev/actionslib/runner/v1"
log "github.com/sirupsen/logrus"
)
+1 -1
View File
@@ -15,7 +15,7 @@ import (
"gitea.com/gitea/runner/internal/pkg/config"
connect_go "connectrpc.com/connect"
runnerv1 "gitea.dev/actions-proto-go/runner/v1"
runnerv1 "gitea.dev/actionslib/runner/v1"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
+1 -1
View File
@@ -19,7 +19,7 @@ import (
"gitea.com/gitea/runner/internal/pkg/process"
"gitea.com/gitea/runner/internal/pkg/report"
runnerv1 "gitea.dev/actions-proto-go/runner/v1"
runnerv1 "gitea.dev/actionslib/runner/v1"
log "github.com/sirupsen/logrus"
)
+1 -1
View File
@@ -14,7 +14,7 @@ import (
"gitea.com/gitea/runner/internal/pkg/metrics"
"gitea.com/gitea/runner/internal/pkg/report"
runnerv1 "gitea.dev/actions-proto-go/runner/v1"
runnerv1 "gitea.dev/actionslib/runner/v1"
log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
+2 -2
View File
@@ -24,7 +24,6 @@ import (
"gitea.com/gitea/runner/act/artifactcache"
"gitea.com/gitea/runner/act/common"
"gitea.com/gitea/runner/act/container"
"gitea.com/gitea/runner/act/model"
"gitea.com/gitea/runner/act/runner"
"gitea.com/gitea/runner/internal/pkg/client"
"gitea.com/gitea/runner/internal/pkg/config"
@@ -34,7 +33,8 @@ import (
"gitea.com/gitea/runner/internal/pkg/ver"
"connectrpc.com/connect"
runnerv1 "gitea.dev/actions-proto-go/runner/v1"
"gitea.dev/actionslib/pkg/model"
runnerv1 "gitea.dev/actionslib/runner/v1"
docker_container "github.com/moby/moby/api/types/container"
log "github.com/sirupsen/logrus"
)
+1 -1
View File
@@ -15,7 +15,7 @@ import (
"gitea.com/gitea/runner/internal/pkg/ver"
"connectrpc.com/connect"
runnerv1 "gitea.dev/actions-proto-go/runner/v1"
runnerv1 "gitea.dev/actionslib/runner/v1"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
+1 -1
View File
@@ -13,7 +13,7 @@ import (
"gitea.com/gitea/runner/internal/pkg/report"
"gitea.com/gitea/runner/internal/pkg/ver"
runnerv1 "gitea.dev/actions-proto-go/runner/v1"
runnerv1 "gitea.dev/actionslib/runner/v1"
)
// osReleasePath describes the host distribution on Linux; absent elsewhere, where the platform
+1 -1
View File
@@ -13,7 +13,7 @@ import (
"gitea.com/gitea/runner/internal/pkg/labels"
"gitea.com/gitea/runner/internal/pkg/ver"
runnerv1 "gitea.dev/actions-proto-go/runner/v1"
runnerv1 "gitea.dev/actionslib/runner/v1"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/types/known/structpb"
+2 -3
View File
@@ -9,9 +9,8 @@ import (
"sort"
"strings"
"gitea.com/gitea/runner/act/model"
runnerv1 "gitea.dev/actions-proto-go/runner/v1"
"gitea.dev/actionslib/pkg/model"
runnerv1 "gitea.dev/actionslib/runner/v1"
"go.yaml.in/yaml/v4"
)
+2 -3
View File
@@ -6,9 +6,8 @@ package run
import (
"testing"
"gitea.com/gitea/runner/act/model"
runnerv1 "gitea.dev/actions-proto-go/runner/v1"
"gitea.dev/actionslib/pkg/model"
runnerv1 "gitea.dev/actionslib/runner/v1"
"github.com/stretchr/testify/require"
"go.yaml.in/yaml/v4"
"gotest.tools/v3/assert"
+2 -2
View File
@@ -4,8 +4,8 @@
package client
import (
"gitea.dev/actions-proto-go/ping/v1/pingv1connect"
"gitea.dev/actions-proto-go/runner/v1/runnerv1connect"
"gitea.dev/actionslib/ping/v1/pingv1connect"
"gitea.dev/actionslib/runner/v1/runnerv1connect"
)
// A Client manages communication with the runner.
+6 -2
View File
@@ -3,7 +3,11 @@
package client
import "gitea.dev/actionslib/pkg/protocol"
// The headers are defined in the shared protocol package so that Gitea and the
// runner cannot drift apart.
const (
UUIDHeader = "x-runner-uuid"
TokenHeader = "x-runner-token"
UUIDHeader = protocol.UUIDHeader
TokenHeader = protocol.TokenHeader
)
+2 -2
View File
@@ -13,8 +13,8 @@ import (
"gitea.com/gitea/runner/internal/pkg/ver"
"connectrpc.com/connect"
"gitea.dev/actions-proto-go/ping/v1/pingv1connect"
"gitea.dev/actions-proto-go/runner/v1/runnerv1connect"
"gitea.dev/actionslib/ping/v1/pingv1connect"
"gitea.dev/actionslib/runner/v1/runnerv1connect"
)
func getHTTPClient(endpoint string, insecure bool) *http.Client {
+1 -1
View File
@@ -10,7 +10,7 @@ import (
"testing"
"connectrpc.com/connect"
pingv1 "gitea.dev/actions-proto-go/ping/v1"
pingv1 "gitea.dev/actionslib/ping/v1"
"github.com/stretchr/testify/require"
)
+2 -2
View File
@@ -9,9 +9,9 @@ import (
mock "github.com/stretchr/testify/mock"
pingv1 "gitea.dev/actions-proto-go/ping/v1"
pingv1 "gitea.dev/actionslib/ping/v1"
runnerv1 "gitea.dev/actions-proto-go/runner/v1"
runnerv1 "gitea.dev/actionslib/runner/v1"
)
// Client is an autogenerated mock type for the Client type
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"sync"
"time"
runnerv1 "gitea.dev/actions-proto-go/runner/v1"
runnerv1 "gitea.dev/actionslib/runner/v1"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/collectors"
)
+1 -1
View File
@@ -10,7 +10,7 @@ import (
"testing"
"time"
runnerv1 "gitea.dev/actions-proto-go/runner/v1"
runnerv1 "gitea.dev/actionslib/runner/v1"
"github.com/prometheus/client_golang/prometheus"
dto "github.com/prometheus/client_model/go"
"github.com/stretchr/testify/require"
+1 -1
View File
@@ -19,7 +19,7 @@ import (
"gitea.com/gitea/runner/internal/pkg/metrics"
"connectrpc.com/connect"
runnerv1 "gitea.dev/actions-proto-go/runner/v1"
runnerv1 "gitea.dev/actionslib/runner/v1"
"github.com/avast/retry-go/v5"
log "github.com/sirupsen/logrus"
"google.golang.org/protobuf/proto"
+1 -1
View File
@@ -21,7 +21,7 @@ import (
"gitea.com/gitea/runner/internal/pkg/config"
connect_go "connectrpc.com/connect"
runnerv1 "gitea.dev/actions-proto-go/runner/v1"
runnerv1 "gitea.dev/actionslib/runner/v1"
log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"