fix: always execute closeContainer() executor (#988)

* fix: always execute closeContainer() executor

During our earlier refactoring in #984 we accidentally changed the
behaviour in such a way that the `closeContainer()` executor was never
called.

This commit restores the earlier behaviour.

Ref:
* https://github.com/nektos/act/pull/984/files#diff-c057d66dc9657d8428e290c69871596e2b567bb8fecad62a99cab54398131a84L294
* https://github.com/nektos/act/pull/984/files#diff-ea9d5c93d769ef9b268932dd9990363e97fc3bec8a00114979d049bead5dd718R68

* test: add testcases to ensure job containers are started/stopped

This commit adds tests to ensure that the executors of `startContainer`,
`stopContainer`, `interpolateOutputs` and `closeContainer` are always
called in the correct order.
This commit is contained in:
Björn Brauer
2022-02-10 17:54:58 +01:00
committed by GitHub
parent e4f0080a1e
commit 9abc87b416
2 changed files with 72 additions and 26 deletions

View File

@@ -48,6 +48,7 @@ func newJobExecutor(info jobInfo) common.Executor {
return nil
})
}
steps = append(steps, func(ctx context.Context) error {
err := info.stopContainer()(ctx)
if err != nil {
@@ -64,8 +65,5 @@ func newJobExecutor(info jobInfo) common.Executor {
return nil
})
return common.NewPipelineExecutor(steps...).Finally(info.interpolateOutputs()).Finally(func(ctx context.Context) error {
info.closeContainer()
return nil
})
return common.NewPipelineExecutor(steps...).Finally(info.interpolateOutputs()).Finally(info.closeContainer())
}