Update act to v0.243 (#54)

- Update act to v0.243.1
- Disable artifacts server when run daemon.
- Adjust cmd.

Reviewed-on: https://gitea.com/gitea/act_runner/pulls/54
Reviewed-by: Zettat123 <zettat123@noreply.gitea.io>
This commit is contained in:
Jason Song 2023-03-17 09:45:46 +08:00 committed by Earl Warren
parent 154555e912
commit df4bfdc0d3
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
4 changed files with 114 additions and 794 deletions

View file

@ -13,7 +13,6 @@ import (
"strings" "strings"
"time" "time"
"codeberg.org/forgejo/runner/artifactcache"
"github.com/joho/godotenv" "github.com/joho/godotenv"
"github.com/nektos/act/pkg/artifacts" "github.com/nektos/act/pkg/artifacts"
"github.com/nektos/act/pkg/common" "github.com/nektos/act/pkg/common"
@ -22,6 +21,8 @@ import (
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"golang.org/x/term" "golang.org/x/term"
"codeberg.org/forgejo/runner/artifactcache"
) )
type executeArgs struct { type executeArgs struct {
@ -48,6 +49,7 @@ type executeArgs struct {
containerCapAdd []string containerCapAdd []string
containerCapDrop []string containerCapDrop []string
artifactServerPath string artifactServerPath string
artifactServerAddr string
artifactServerPort string artifactServerPort string
noSkipCheckout bool noSkipCheckout bool
debug bool debug bool
@ -262,15 +264,25 @@ func runExecList(ctx context.Context, planner model.WorkflowPlanner, execArgs *e
filterEventName = events[0] filterEventName = events[0]
} }
var err error
if execArgs.job != "" { if execArgs.job != "" {
log.Infof("Preparing plan with a job: %s", execArgs.job) log.Infof("Preparing plan with a job: %s", execArgs.job)
filterPlan = planner.PlanJob(execArgs.job) filterPlan, err = planner.PlanJob(execArgs.job)
if err != nil {
return err
}
} else if filterEventName != "" { } else if filterEventName != "" {
log.Infof("Preparing plan for a event: %s", filterEventName) log.Infof("Preparing plan for a event: %s", filterEventName)
filterPlan = planner.PlanEvent(filterEventName) filterPlan, err = planner.PlanEvent(filterEventName)
if err != nil {
return err
}
} else { } else {
log.Infof("Preparing plan with all jobs") log.Infof("Preparing plan with all jobs")
filterPlan = planner.PlanAll() filterPlan, err = planner.PlanAll()
if err != nil {
return err
}
} }
printList(filterPlan) printList(filterPlan)
@ -317,10 +329,16 @@ func runExec(ctx context.Context, execArgs *executeArgs) func(cmd *cobra.Command
// build the plan for this run // build the plan for this run
if execArgs.job != "" { if execArgs.job != "" {
log.Infof("Planning job: %s", execArgs.job) log.Infof("Planning job: %s", execArgs.job)
plan = planner.PlanJob(execArgs.job) plan, err = planner.PlanJob(execArgs.job)
if err != nil {
return err
}
} else { } else {
log.Infof("Planning jobs for event: %s", eventName) log.Infof("Planning jobs for event: %s", eventName)
plan = planner.PlanEvent(eventName) plan, err = planner.PlanEvent(eventName)
if err != nil {
return err
}
} }
maxLifetime := 3 * time.Hour maxLifetime := 3 * time.Hour
@ -393,7 +411,7 @@ func runExec(ctx context.Context, execArgs *executeArgs) func(cmd *cobra.Command
execArgs.artifactServerPath = tempDir execArgs.artifactServerPath = tempDir
} }
artifactCancel := artifacts.Serve(ctx, execArgs.artifactServerPath, execArgs.artifactServerPort) artifactCancel := artifacts.Serve(ctx, execArgs.artifactServerPath, execArgs.artifactServerAddr, execArgs.artifactServerPort)
log.Debugf("artifacts server started at %s:%s", execArgs.artifactServerPath, execArgs.artifactServerPort) log.Debugf("artifacts server started at %s:%s", execArgs.artifactServerPath, execArgs.artifactServerPort)
ctx = common.WithDryrun(ctx, execArgs.dryrun) ctx = common.WithDryrun(ctx, execArgs.dryrun)

57
go.mod
View file

@ -1,23 +1,23 @@
module codeberg.org/forgejo/runner module codeberg.org/forgejo/runner
go 1.18 go 1.20
require ( require (
code.gitea.io/actions-proto-go v0.2.0 code.gitea.io/actions-proto-go v0.2.0
code.gitea.io/gitea-vet v0.2.3-0.20230113022436-2b1561217fa5 code.gitea.io/gitea-vet v0.2.3-0.20230113022436-2b1561217fa5
github.com/avast/retry-go/v4 v4.3.1 github.com/avast/retry-go/v4 v4.3.1
github.com/bufbuild/connect-go v1.3.1 github.com/bufbuild/connect-go v1.3.1
github.com/docker/docker v20.10.21+incompatible github.com/docker/docker v23.0.1+incompatible
github.com/go-chi/chi/v5 v5.0.8 github.com/go-chi/chi/v5 v5.0.8
github.com/go-chi/render v1.0.2 github.com/go-chi/render v1.0.2
github.com/joho/godotenv v1.4.0 github.com/joho/godotenv v1.5.1
github.com/kelseyhightower/envconfig v1.4.0 github.com/kelseyhightower/envconfig v1.4.0
github.com/mattn/go-isatty v0.0.16 github.com/mattn/go-isatty v0.0.17
github.com/nektos/act v0.0.0 github.com/nektos/act v0.0.0
github.com/sirupsen/logrus v1.9.0 github.com/sirupsen/logrus v1.9.0
github.com/spf13/cobra v1.6.1 github.com/spf13/cobra v1.6.1
golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde golang.org/x/sync v0.1.0
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 golang.org/x/term v0.6.0
google.golang.org/protobuf v1.28.1 google.golang.org/protobuf v1.28.1
modernc.org/sqlite v1.14.2 modernc.org/sqlite v1.14.2
xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978 xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978
@ -25,29 +25,26 @@ require (
) )
require ( require (
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
github.com/Masterminds/semver v1.5.0 // indirect github.com/Masterminds/semver v1.5.0 // indirect
github.com/Microsoft/go-winio v0.5.2 // indirect github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/Microsoft/hcsshim v0.9.3 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20220404123522-616f957b79ad // indirect github.com/ProtonMail/go-crypto v0.0.0-20220404123522-616f957b79ad // indirect
github.com/acomagu/bufpipe v1.0.3 // indirect github.com/acomagu/bufpipe v1.0.3 // indirect
github.com/ajg/form v1.5.1 // indirect github.com/ajg/form v1.5.1 // indirect
github.com/containerd/cgroups v1.0.3 // indirect github.com/containerd/containerd v1.6.18 // indirect
github.com/containerd/containerd v1.6.6 // indirect
github.com/creack/pty v1.1.18 // indirect github.com/creack/pty v1.1.18 // indirect
github.com/docker/cli v20.10.21+incompatible // indirect github.com/docker/cli v23.0.1+incompatible // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/docker-credential-helpers v0.6.4 // indirect github.com/docker/docker-credential-helpers v0.7.0 // indirect
github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.4.0 // indirect github.com/docker/go-units v0.5.0 // indirect
github.com/emirpasic/gods v1.12.0 // indirect github.com/emirpasic/gods v1.12.0 // indirect
github.com/fatih/color v1.13.0 // indirect github.com/fatih/color v1.13.0 // indirect
github.com/go-git/gcfg v1.5.0 // indirect github.com/go-git/gcfg v1.5.0 // indirect
github.com/go-git/go-billy/v5 v5.3.1 // indirect github.com/go-git/go-billy/v5 v5.4.1 // indirect
github.com/go-git/go-git/v5 v5.4.2 // indirect github.com/go-git/go-git/v5 v5.4.2 // indirect
github.com/go-ini/ini v1.67.0 // indirect
github.com/goccy/go-json v0.8.1 // indirect github.com/goccy/go-json v0.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/snappy v0.0.4 // indirect github.com/golang/snappy v0.0.4 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.3.0 // indirect github.com/google/uuid v1.3.0 // indirect
@ -58,23 +55,26 @@ require (
github.com/julienschmidt/httprouter v1.3.0 // indirect github.com/julienschmidt/httprouter v1.3.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/compress v1.15.12 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.1.2 // indirect github.com/mitchellh/mapstructure v1.1.2 // indirect
github.com/moby/buildkit v0.10.6 // indirect github.com/moby/buildkit v0.11.4 // indirect
github.com/moby/sys/mount v0.3.1 // indirect github.com/moby/patternmatcher v0.5.0 // indirect
github.com/moby/sys/mountinfo v0.6.0 // indirect github.com/moby/sys/sequential v0.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/onsi/ginkgo v1.12.1 // indirect
github.com/onsi/gomega v1.10.3 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799 // indirect github.com/opencontainers/image-spec v1.1.0-rc2 // indirect
github.com/opencontainers/runc v1.1.2 // indirect github.com/opencontainers/runc v1.1.3 // indirect
github.com/opencontainers/selinux v1.10.2 // indirect github.com/opencontainers/selinux v1.11.0 // indirect
github.com/pkg/errors v0.9.1 // indirect github.com/pkg/errors v0.9.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
github.com/rhysd/actionlint v1.6.22 // indirect github.com/rhysd/actionlint v1.6.23 // indirect
github.com/rivo/uniseg v0.3.4 // indirect github.com/rivo/uniseg v0.4.3 // indirect
github.com/robfig/cron v1.2.0 // indirect github.com/robfig/cron v1.2.0 // indirect
github.com/sergi/go-diff v1.2.0 // indirect github.com/sergi/go-diff v1.2.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/pflag v1.0.5 // indirect
@ -82,12 +82,11 @@ require (
github.com/xanzy/ssh-agent v0.3.1 // indirect github.com/xanzy/ssh-agent v0.3.1 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v0.0.0-20180618132009-1d523034197f // indirect github.com/xeipuuv/gojsonschema v1.2.0 // indirect
go.opencensus.io v0.23.0 // indirect golang.org/x/crypto v0.2.0 // indirect
golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29 // indirect
golang.org/x/mod v0.4.2 // indirect golang.org/x/mod v0.4.2 // indirect
golang.org/x/net v0.0.0-20220906165146-f3363e06e74c // indirect golang.org/x/net v0.7.0 // indirect
golang.org/x/sys v0.0.0-20220818161305-2296e01440c6 // indirect golang.org/x/sys v0.6.0 // indirect
golang.org/x/tools v0.1.5 // indirect golang.org/x/tools v0.1.5 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect

803
go.sum

File diff suppressed because it is too large Load diff

View file

@ -11,7 +11,6 @@ import (
"time" "time"
runnerv1 "code.gitea.io/actions-proto-go/runner/v1" runnerv1 "code.gitea.io/actions-proto-go/runner/v1"
"github.com/nektos/act/pkg/artifacts"
"github.com/nektos/act/pkg/common" "github.com/nektos/act/pkg/common"
"github.com/nektos/act/pkg/model" "github.com/nektos/act/pkg/model"
"github.com/nektos/act/pkg/runner" "github.com/nektos/act/pkg/runner"
@ -156,7 +155,6 @@ func (t *Task) Run(ctx context.Context, task *runnerv1.Task, runnerName, runnerV
return err return err
} }
var plan *model.Plan
jobIDs := workflow.GetJobIDs() jobIDs := workflow.GetJobIDs()
if len(jobIDs) != 1 { if len(jobIDs) != 1 {
err := fmt.Errorf("multiple jobs found: %v", jobIDs) err := fmt.Errorf("multiple jobs found: %v", jobIDs)
@ -164,7 +162,11 @@ func (t *Task) Run(ctx context.Context, task *runnerv1.Task, runnerName, runnerV
return err return err
} }
jobID := jobIDs[0] jobID := jobIDs[0]
plan = model.CombineWorkflowPlanner(workflow).PlanJob(jobID) plan, err := model.CombineWorkflowPlanner(workflow).PlanJob(jobID)
if err != nil {
lastWords = err.Error()
return err
}
job := workflow.GetJob(jobID) job := workflow.GetJob(jobID)
reporter.ResetSteps(len(job.Steps)) reporter.ResetSteps(len(job.Steps))
@ -243,13 +245,7 @@ func (t *Task) Run(ctx context.Context, task *runnerv1.Task, runnerName, runnerV
return err return err
} }
artifactCancel := artifacts.Serve(ctx, input.artifactServerPath, input.artifactServerPort) executor := r.NewPlanExecutor(plan)
t.log.Debugf("artifacts server started at %s:%s", input.artifactServerPath, input.artifactServerPort)
executor := r.NewPlanExecutor(plan).Finally(func(ctx context.Context) error {
artifactCancel()
return nil
})
t.log.Infof("workflow prepared") t.log.Infof("workflow prepared")
reporter.Logf("workflow prepared") reporter.Logf("workflow prepared")