mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-05-04 22:45:30 +08:00
## Consumer-facing breaking changes
- **Go module path**: `gitea.com/gitea/act_runner` → `gitea.com/gitea/runner`. Anything importing `act/...` or `internal/...` packages (notably Gitea itself) must update imports.
- **Binary name**: `act_runner` → `gitea-runner`. Wrapper scripts, systemd units, init scripts, and documentation referencing the binary by `act_runner` will break.
- **Docker image**: `gitea/act_runner` → `gitea/runner` (incl. `*-dind-rootless` variants). Users pulling `gitea/act_runner:nightly` etc. will get stale images. Note: the image name is `gitea/runner`, not `gitea/gitea-runner`.
- **Release artifact paths**: S3 directory `act_runner/{{.Version}}` → `gitea-runner/{{.Version}}`, and artifact filenames change with the new project name. Existing download URLs break.
- **Metrics namespace**: changed from `act_runner` to `gitea_runner` (e.g. `act_runner_jobs_total` → `gitea_runner_jobs_total`); existing monitors/dashboards must be updated.
- **ldflags version path**: `gitea.com/gitea/act_runner/internal/pkg/ver.version` → `gitea.com/gitea/runner/internal/pkg/ver.version`. Affects anyone building with custom ldflags.
- **Kubernetes example resource names**: `act-runner` / `act-runner-vol` → `runner` / `runner-vol`. Users who copied the manifests verbatim will see resource churn on apply.
- **s6 service name**: `scripts/s6/act_runner/` → `scripts/s6/gitea-runner/` (image-internal; only matters for downstream image overrides).
Unchanged: YAML config field names, env vars (`GITEA_*`), CLI flags/subcommands, registration file format.
---------
Co-authored-by: silverwind <me@silverwind.io>
Reviewed-on: https://gitea.com/gitea/runner/pulls/850
Reviewed-by: Zettat123 <39446+zettat123@noreply.gitea.com>
Reviewed-by: silverwind <2021+silverwind@noreply.gitea.com>
Reviewed-by: Nicolas <bircni@icloud.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
143 lines
3.9 KiB
Go
143 lines
3.9 KiB
Go
// Copyright 2022 The Gitea Authors. All rights reserved.
|
|
// Copyright 2022 The nektos/act Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package runner
|
|
|
|
import (
|
|
"archive/tar"
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"io"
|
|
"io/fs"
|
|
"os"
|
|
"path"
|
|
"path/filepath"
|
|
|
|
"gitea.com/gitea/runner/act/common"
|
|
"gitea.com/gitea/runner/act/model"
|
|
)
|
|
|
|
type stepActionLocal struct {
|
|
Step *model.Step
|
|
RunContext *RunContext
|
|
compositeRunContext *RunContext
|
|
compositeSteps *compositeSteps
|
|
runAction runAction
|
|
readAction readAction
|
|
env map[string]string
|
|
action *model.Action
|
|
}
|
|
|
|
func (sal *stepActionLocal) pre() common.Executor {
|
|
sal.env = map[string]string{}
|
|
|
|
return func(ctx context.Context) error {
|
|
return nil
|
|
}
|
|
}
|
|
|
|
func (sal *stepActionLocal) main() common.Executor {
|
|
return runStepExecutor(sal, stepStageMain, func(ctx context.Context) error {
|
|
if common.Dryrun(ctx) {
|
|
return nil
|
|
}
|
|
|
|
printRunActionHeader(ctx, sal.Step, sal.env, sal.getRunContext())
|
|
rawLogger := common.Logger(ctx).WithField(rawOutputField, true)
|
|
defer rawLogger.Infof("::endgroup::")
|
|
|
|
actionDir := filepath.Join(sal.getRunContext().Config.Workdir, sal.Step.Uses)
|
|
|
|
localReader := func(ctx context.Context) actionYamlReader {
|
|
_, cpath := getContainerActionPaths(sal.Step, path.Join(actionDir, ""), sal.RunContext)
|
|
return func(filename string) (io.Reader, io.Closer, error) {
|
|
spath := path.Join(cpath, filename)
|
|
for range maxSymlinkDepth {
|
|
tars, err := sal.RunContext.JobContainer.GetContainerArchive(ctx, spath)
|
|
if errors.Is(err, fs.ErrNotExist) {
|
|
return nil, nil, err
|
|
} else if err != nil {
|
|
return nil, nil, fs.ErrNotExist
|
|
}
|
|
treader := tar.NewReader(tars)
|
|
header, err := treader.Next()
|
|
if errors.Is(err, io.EOF) {
|
|
return nil, nil, os.ErrNotExist
|
|
} else if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
if header.FileInfo().Mode()&os.ModeSymlink == os.ModeSymlink {
|
|
spath, err = symlinkJoin(spath, header.Linkname, cpath)
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
} else {
|
|
return treader, tars, nil
|
|
}
|
|
}
|
|
return nil, nil, fmt.Errorf("max depth %d of symlinks exceeded while reading %s", maxSymlinkDepth, spath)
|
|
}
|
|
}
|
|
|
|
actionModel, err := sal.readAction(ctx, sal.Step, actionDir, "", localReader(ctx), os.WriteFile)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
sal.action = actionModel
|
|
|
|
return sal.runAction(sal, actionDir, nil)(ctx)
|
|
})
|
|
}
|
|
|
|
func (sal *stepActionLocal) post() common.Executor {
|
|
return runStepExecutor(sal, stepStagePost, runPostStep(sal)).If(hasPostStep(sal)).If(shouldRunPostStep(sal))
|
|
}
|
|
|
|
func (sal *stepActionLocal) getRunContext() *RunContext {
|
|
return sal.RunContext
|
|
}
|
|
|
|
func (sal *stepActionLocal) getGithubContext(ctx context.Context) *model.GithubContext {
|
|
return sal.getRunContext().getGithubContext(ctx)
|
|
}
|
|
|
|
func (sal *stepActionLocal) getStepModel() *model.Step {
|
|
return sal.Step
|
|
}
|
|
|
|
func (sal *stepActionLocal) getEnv() *map[string]string {
|
|
return &sal.env
|
|
}
|
|
|
|
func (sal *stepActionLocal) getIfExpression(_ context.Context, stage stepStage) string {
|
|
switch stage {
|
|
case stepStageMain:
|
|
return sal.Step.If.Value
|
|
case stepStagePost:
|
|
return sal.action.Runs.PostIf
|
|
}
|
|
return ""
|
|
}
|
|
|
|
func (sal *stepActionLocal) getActionModel() *model.Action {
|
|
return sal.action
|
|
}
|
|
|
|
func (sal *stepActionLocal) getCompositeRunContext(ctx context.Context) *RunContext {
|
|
if sal.compositeRunContext == nil {
|
|
actionDir := filepath.Join(sal.RunContext.Config.Workdir, sal.Step.Uses)
|
|
_, containerActionDir := getContainerActionPaths(sal.getStepModel(), actionDir, sal.RunContext)
|
|
|
|
sal.compositeRunContext = newCompositeRunContext(ctx, sal.RunContext, sal, containerActionDir)
|
|
sal.compositeSteps = sal.compositeRunContext.compositeExecutor(sal.action)
|
|
}
|
|
return sal.compositeRunContext
|
|
}
|
|
|
|
func (sal *stepActionLocal) getCompositeSteps() *compositeSteps {
|
|
return sal.compositeSteps
|
|
}
|