1
0
mirror of https://gitea.com/gitea/act_runner synced 2024-11-09 18:05:52 +01:00

feat: avoid reuse of containers

This commit is contained in:
Jason Song 2022-11-08 18:35:13 +08:00
parent d650bae0b6
commit cbd21b8ec5
3 changed files with 7 additions and 14 deletions

2
go.mod

@ -72,4 +72,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)
replace github.com/nektos/act => gitea.com/gitea/act v0.0.0-20220922135643-52a5bba9e7fa
replace github.com/nektos/act => gitea.com/gitea/act v0.0.0-20221108101106-28099ee68a88

6
go.sum

@ -23,10 +23,8 @@ cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiy
cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos=
cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
gitea.com/gitea/act v0.0.0-20220922135643-52a5bba9e7fa h1:HHqlvfIvqFlny3sgJgAM1BYeLNr1uM4yXtvF7aAoYK8=
gitea.com/gitea/act v0.0.0-20220922135643-52a5bba9e7fa/go.mod h1:9W/Nz16tjfnWp7O5DUo3EjZBnZFBI/5rlWstX4o7+hU=
gitea.com/gitea/proto-go v0.0.0-20221014123629-9116865c883b h1:TSz7VRHfnM/5JwGPgIAjSlDIvcr4pTGfuRMtgMxttmg=
gitea.com/gitea/proto-go v0.0.0-20221014123629-9116865c883b/go.mod h1:hD8YwSHusjwjEEgubW6XFvnZuNhMZTHz6lwjfltEt/Y=
gitea.com/gitea/act v0.0.0-20221108101106-28099ee68a88 h1:pfeGhadGGQbQuXqIgi/C6NQ+VopNEkHayz49IgANPAg=
gitea.com/gitea/act v0.0.0-20221108101106-28099ee68a88/go.mod h1:lpzib6X73FHLSaTqTakan1xcsCAVhlZvPSpLns7jkRo=
gitea.com/gitea/proto-go v0.0.0-20221028125601-35c4f6b05835 h1:27PhT7Nli/pgRo1bDYVZ+hlCKuF9cfFuo+y9muaPVJY=
gitea.com/gitea/proto-go v0.0.0-20221028125601-35c4f6b05835/go.mod h1:hD8YwSHusjwjEEgubW6XFvnZuNhMZTHz6lwjfltEt/Y=
github.com/Azure/azure-sdk-for-go v16.2.1+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=

@ -72,7 +72,7 @@ type Task struct {
func NewTask(forgeInstance string, buildID int64, client client.Client, runnerEnvs map[string]string) *Task {
task := &Task{
Input: &TaskInput{
reuseContainers: true,
reuseContainers: false,
ForgeInstance: forgeInstance,
envs: runnerEnvs,
},
@ -166,12 +166,6 @@ func (t *Task) Run(ctx context.Context, task *runnerv1.Task) error {
log.Infof("plan: %+v", plan.Stages[0].Runs)
curDir, err := os.Getwd()
if err != nil {
lastWords = err.Error()
return err
}
token := getToken(task)
dataContext := task.Context.Fields
@ -202,13 +196,14 @@ func (t *Task) Run(ctx context.Context, task *runnerv1.Task) error {
input := t.Input
config := &runner.Config{
Workdir: curDir, // TODO: temp dir?
Workdir: "/root",
BindWorkdir: input.bindWorkdir,
ReuseContainers: input.reuseContainers,
ForcePull: input.forcePull,
ForceRebuild: input.forceRebuild,
LogOutput: true,
JSONLogger: input.jsonLogger,
Env: input.envs,
Secrets: task.Secrets,
InsecureSecrets: input.insecureSecrets,
Platforms: demoPlatforms(), // TODO: supported platforms
@ -226,7 +221,7 @@ func (t *Task) Run(ctx context.Context, task *runnerv1.Task) error {
NoSkipCheckout: input.noSkipCheckout,
PresetGitHubContext: preset,
EventJSON: string(eventJSON),
Env: t.Input.envs,
ContainerNamePrefix: fmt.Sprintf("gitea-task-%d", task.Id),
}
r, err := runner.New(config)
if err != nil {