mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-09 05:38:54 +09:00
2087d4a1a5
Pairs with https://gitea.com/gitea/runner/pulls/1143. Gitea depends on `gitea.com/gitea/runner` for exactly two packages: `act/model` and `act/exprparser`, the workflow model and the expression evaluator it needs to parse workflows and to build the task payload the runner consumes. Pulling the whole runner module in for that is heavy and puts shared code in the repository of one of the two consumers. Both packages now live in `gitea.dev/actionslib` (`pkg/model`, `pkg/exprparser`), the module Gitea and the runner already share for the runner API, so the dependency on the runner repository is dropped here. ### Changes - `gitea.com/gitea/runner/act/model` -> `gitea.dev/actionslib/pkg/model`, `.../act/exprparser` -> `gitea.dev/actionslib/pkg/exprparser` (22 files, import paths only). - `routers/api/actions/runner/interceptor.go` takes the `x-runner-uuid` / `x-runner-token` names from `gitea.dev/actionslib/pkg/protocol` instead of repeating the literals the runner also has. - `go.mod`: `gitea.com/gitea/runner` removed. --------- Signed-off-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Zettat123 <zettat123@gmail.com>
43 lines
1.2 KiB
Go
43 lines
1.2 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package actions
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gitea.dev/actionslib/pkg/model"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestCoerceDispatchInputTypes(t *testing.T) {
|
|
dispatch := &model.WorkflowDispatch{
|
|
Inputs: map[string]model.WorkflowDispatchInput{
|
|
"build_server": {Type: "boolean"},
|
|
"dry_run": {Type: "boolean"},
|
|
"already_bool": {Type: "boolean"},
|
|
"version": {Type: "string"},
|
|
},
|
|
}
|
|
|
|
inputs := map[string]any{
|
|
// dispatch callbacks fill booleans as strconv.FormatBool(...) strings
|
|
"build_server": "true",
|
|
"dry_run": "false",
|
|
// already-native booleans are passed through unchanged (coercion is idempotent)
|
|
"already_bool": true,
|
|
// non-boolean inputs must be left untouched
|
|
"version": "1.2.3",
|
|
}
|
|
|
|
coerceDispatchInputTypes(dispatch, inputs)
|
|
|
|
// Regression: without coercion these stay strings, and a server-side needs-gated
|
|
// job `if: inputs.build_server == true` never matches, leaving the job blocked.
|
|
assert.Equal(t, true, inputs["build_server"])
|
|
assert.Equal(t, false, inputs["dry_run"])
|
|
assert.Equal(t, true, inputs["already_bool"])
|
|
assert.Equal(t, "1.2.3", inputs["version"])
|
|
}
|