mirror of
https://gitea.com/gitea/runner.git
synced 2026-08-24 04:47:45 +00:00
546eca312e
Remove inherited act APIs, configuration branches, and test seams that neither the daemon nor exec can reach. Constant-fold settings both entry points already enforce and consolidate duplicate runner paths. Major removals: - Unwired custom action-cache and local-repository-cache implementations. - Legacy matrix, platform, input, container-reuse, logging, Git remote, and action-replacement configuration paths. - Unused Docker socket, container network, tar-copy, and platform PTY wrappers. - Single-implementation filesystem, environment, runner, and expression abstractions. - Duplicated step-container, command-logging, credential, reusable-workflow, and execution paths. - Generated client mock boilerplate, obsolete fixtures, test-only seams, stale wrappers, and commented-out code. This removes 2844 net Go lines while retaining Gitea RPC, event, matrix, input, cache, artifact, action, reusable workflow, Docker, host, exec, and release behavior. Assisted by Codex (GPT-5). Reviewed-on: https://gitea.com/gitea/runner/pulls/1179 Reviewed-by: bircni <bircni@icloud.com> Co-authored-by: silverwind <me@silverwind.io>
66 lines
2.2 KiB
Go
66 lines
2.2 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package mocks
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"connectrpc.com/connect"
|
|
"gitea.dev/actionslib/runner/v1"
|
|
"github.com/stretchr/testify/mock"
|
|
)
|
|
|
|
type Client struct {
|
|
mock.Mock
|
|
AddressValue string
|
|
}
|
|
|
|
func (m *Client) Address() string {
|
|
return m.AddressValue
|
|
}
|
|
|
|
func call[Request, Response any](ctx context.Context, m *Client, method string, request *connect.Request[Request]) (*connect.Response[Response], error) {
|
|
returns := m.MethodCalled(method, ctx, request)
|
|
if callback, ok := returns.Get(0).(func(context.Context, *connect.Request[Request]) (*connect.Response[Response], error)); ok {
|
|
return callback(ctx, request)
|
|
}
|
|
var response *connect.Response[Response]
|
|
if value := returns.Get(0); value != nil {
|
|
var ok bool
|
|
response, ok = value.(*connect.Response[Response])
|
|
if !ok {
|
|
panic(fmt.Sprintf("unexpected response type %T for %s", value, method))
|
|
}
|
|
}
|
|
return response, returns.Error(1)
|
|
}
|
|
|
|
func (m *Client) Declare(ctx context.Context, request *connect.Request[runnerv1.DeclareRequest]) (*connect.Response[runnerv1.DeclareResponse], error) {
|
|
return call[runnerv1.DeclareRequest, runnerv1.DeclareResponse](ctx, m, "Declare", request)
|
|
}
|
|
|
|
func (m *Client) FetchTask(ctx context.Context, request *connect.Request[runnerv1.FetchTaskRequest]) (*connect.Response[runnerv1.FetchTaskResponse], error) {
|
|
return call[runnerv1.FetchTaskRequest, runnerv1.FetchTaskResponse](ctx, m, "FetchTask", request)
|
|
}
|
|
|
|
func (m *Client) UpdateLog(ctx context.Context, request *connect.Request[runnerv1.UpdateLogRequest]) (*connect.Response[runnerv1.UpdateLogResponse], error) {
|
|
return call[runnerv1.UpdateLogRequest, runnerv1.UpdateLogResponse](ctx, m, "UpdateLog", request)
|
|
}
|
|
|
|
func (m *Client) UpdateTask(ctx context.Context, request *connect.Request[runnerv1.UpdateTaskRequest]) (*connect.Response[runnerv1.UpdateTaskResponse], error) {
|
|
return call[runnerv1.UpdateTaskRequest, runnerv1.UpdateTaskResponse](ctx, m, "UpdateTask", request)
|
|
}
|
|
|
|
func NewClient(t interface {
|
|
mock.TestingT
|
|
Cleanup(func())
|
|
},
|
|
) *Client {
|
|
client := &Client{}
|
|
client.Test(t)
|
|
t.Cleanup(func() { client.AssertExpectations(t) })
|
|
return client
|
|
}
|