diff --git a/pkg/container/host_environment.go b/pkg/container/host_environment.go index 4801b2738f7..9781bbb4f32 100644 --- a/pkg/container/host_environment.go +++ b/pkg/container/host_environment.go @@ -40,7 +40,7 @@ func (e *HostEnvironment) Create(_ []string, _ []string) common.Executor { } } -func (e *HostEnvironment) ConnectToNetwork(name string) common.Executor { +func (e *HostEnvironment) ConnectToNetwork(_ string) common.Executor { return func(ctx context.Context) error { return nil } diff --git a/pkg/runner/job_executor.go b/pkg/runner/job_executor.go index 4d0aee432ae..960fe1fbbef 100644 --- a/pkg/runner/job_executor.go +++ b/pkg/runner/job_executor.go @@ -19,6 +19,7 @@ type jobInfo interface { result(result string) } +//nolint:contextcheck,gocyclo func newJobExecutor(info jobInfo, sf stepFactory, rc *RunContext) common.Executor { steps := make([]common.Executor, 0) preSteps := make([]common.Executor, 0) @@ -87,7 +88,7 @@ func newJobExecutor(info jobInfo, sf stepFactory, rc *RunContext) common.Executo postExec := useStepLogger(rc, stepModel, stepStagePost, step.post()) if postExecutor != nil { - // run the post exector in reverse order + // run the post executor in reverse order postExecutor = postExec.Finally(postExecutor) } else { postExecutor = postExec @@ -101,7 +102,6 @@ func newJobExecutor(info jobInfo, sf stepFactory, rc *RunContext) common.Executo // always allow 1 min for stopping and removing the runner, even if we were cancelled ctx, cancel := context.WithTimeout(common.WithLogger(context.Background(), common.Logger(ctx)), time.Minute) defer cancel() - err = info.stopContainer()(ctx) //nolint:contextcheck logger := common.Logger(ctx) logger.Infof("Cleaning up services for job %s", rc.JobName) diff --git a/pkg/runner/run_context.go b/pkg/runner/run_context.go index 19a0d49ca5f..a47e2ffc3d5 100644 --- a/pkg/runner/run_context.go +++ b/pkg/runner/run_context.go @@ -16,14 +16,12 @@ import ( "regexp" "runtime" "strings" - "time" - - "github.com/opencontainers/selinux/go-selinux" "github.com/nektos/act/pkg/common" "github.com/nektos/act/pkg/container" "github.com/nektos/act/pkg/exprparser" "github.com/nektos/act/pkg/model" + "github.com/opencontainers/selinux/go-selinux" ) // RunContext contains info about current job @@ -276,7 +274,7 @@ func (rc *RunContext) startJobContainer() common.Executor { } // add service containers - for serviceId, spec := range rc.Run.Job().Services { + for serviceID, spec := range rc.Run.Job().Services { // interpolate env interpolatedEnvs := make(map[string]string, len(spec.Env)) for k, v := range spec.Env { @@ -288,10 +286,10 @@ func (rc *RunContext) startJobContainer() common.Executor { } username, password, err = rc.handleServiceCredentials(ctx, spec.Credentials) if err != nil { - return fmt.Errorf("failed to handle service %s credentials: %w", serviceId, err) + return fmt.Errorf("failed to handle service %s credentials: %w", serviceID, err) } serviceBinds, serviceMounts := rc.GetServiceBindsAndMounts(spec.Volumes) - serviceContainerName := createContainerName(rc.jobContainerName(), serviceId) + serviceContainerName := createContainerName(rc.jobContainerName(), serviceID) c := container.NewContainer(&container.NewContainerInput{ Name: serviceContainerName, WorkingDir: ext.ToContainerPath(rc.Config.Workdir), @@ -308,7 +306,7 @@ func (rc *RunContext) startJobContainer() common.Executor { Platform: rc.Config.ContainerArchitecture, Options: spec.Options, NetworkMode: networkName, - NetworkAliases: []string{serviceId}, + NetworkAliases: []string{serviceID}, ValidVolumes: rc.Config.ValidVolumes, }) rc.ServiceContainers = append(rc.ServiceContainers, c) @@ -325,7 +323,7 @@ func (rc *RunContext) startJobContainer() common.Executor { rc.JobContainer = container.NewContainer(&container.NewContainerInput{ Cmd: nil, - Entrypoint: []string{"/bin/sleep", fmt.Sprint(rc.Config.ContainerMaxLifetime.Round(time.Second).Seconds())}, + Entrypoint: []string{"/usr/bin/tail", "-f", "/dev/null"}, WorkingDir: ext.ToContainerPath(rc.Config.Workdir), Image: image, Username: username, @@ -460,7 +458,7 @@ func (rc *RunContext) pullServicesImages(forcePull bool) common.Executor { } } -func (rc *RunContext) startServiceContainers(networkName string) common.Executor { +func (rc *RunContext) startServiceContainers(_ string) common.Executor { return func(ctx context.Context) error { execs := []common.Executor{} for _, c := range rc.ServiceContainers { diff --git a/pkg/runner/runner.go b/pkg/runner/runner.go index 2271ffce2f8..75b29f5e767 100644 --- a/pkg/runner/runner.go +++ b/pkg/runner/runner.go @@ -6,13 +6,11 @@ import ( "fmt" "os" "runtime" - "time" - - log "github.com/sirupsen/logrus" docker_container "github.com/docker/docker/api/types/container" "github.com/nektos/act/pkg/common" "github.com/nektos/act/pkg/model" + log "github.com/sirupsen/logrus" ) // Runner provides capabilities to run GitHub actions @@ -60,7 +58,6 @@ type Config struct { ReplaceGheActionWithGithubCom []string // Use actions from GitHub Enterprise instance to GitHub ReplaceGheActionTokenWithGithubCom string // Token of private action repo on GitHub. Matrix map[string]map[string]bool // Matrix config to run - ContainerMaxLifetime time.Duration // the max lifetime of job containers ContainerNetworkMode docker_container.NetworkMode // the network mode of job containers (the value of --network) ValidVolumes []string // only volumes (and bind mounts) in this slice can be mounted on the job container or service containers }