Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: extract RunContext Executor in JobExecutor #984

Merged
merged 1 commit into from
Feb 8, 2022

Conversation

Poltergeist
Copy link
Contributor

This splits the executor from the RunContext into its own function
called newJobExecutor.
We defined an interface called jobInfo which is implemented by the RunContext.
This enables better unit testing because only a small interface needs to
be mocked.

This is a preparation for implementing pre and post actions.

This splits the executor from the RunContext into its own function
called newJobExecutor.
We defined an interface called jobInfo which is implemented by the RunContext.
This enables better unit testing because only a small interface needs to
be mocked.

This is a preparation for implementing pre and post actions.

Co-authored-by: Björn Brauer <[email protected]>
Co-authored-by: Marcus Noll <[email protected]>
Co-authored-by: Jonas Holland <[email protected]>
Co-authored-by: Robert Kowalski <[email protected]>
Co-authored-by: Markus Wolf <[email protected]>
@Poltergeist Poltergeist requested a review from a team as a code owner February 8, 2022 13:25
@codecov
Copy link

codecov bot commented Feb 8, 2022

Codecov Report

Merging #984 (2379855) into master (4f8da0a) will increase coverage by 0.07%.
The diff coverage is 81.03%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #984      +/-   ##
==========================================
+ Coverage   57.50%   57.58%   +0.07%     
==========================================
  Files          32       33       +1     
  Lines        4594     4612      +18     
==========================================
+ Hits         2642     2656      +14     
- Misses       1729     1732       +3     
- Partials      223      224       +1     
Impacted Files Coverage Δ
pkg/runner/run_context.go 79.34% <76.47%> (-0.31%) ⬇️
pkg/runner/job_executor.go 82.92% <82.92%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b1f5963...2379855. Read the comment docs.

Copy link
Contributor

@ChristopherHX ChristopherHX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to see refactoring like this merged instead of causing unneeded merge conflicts, like with my composite PR.

Comment on lines +120 to +122
jpm.On("stopContainer").Return(func(ctx context.Context) error {
return nil
})
Copy link
Contributor

@ChristopherHX ChristopherHX Feb 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JFI @catthehacker You silently approved a behavior change, in december 2021 PR
This new Test for case stepWithFailure is incompatible with your comment
#694 (comment)
However I like this behavior change, but the next act version should probably be v0.3.0 and not v0.2.26.

Summary:
Container are always stopped and deleted even if the job failed ( since #840, current master and this PR ), they only keep running with cli flag --reuse.

It is possible that the old behavior still happens for failure in setup steps after container creation

@mergify mergify bot merged commit e23223a into nektos:master Feb 8, 2022
ZauberNerd added a commit to ZauberNerd/act that referenced this pull request Feb 9, 2022
mergify bot pushed a commit that referenced this pull request Feb 10, 2022
* 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.

return common.NewPipelineExecutor(steps...).Finally(rc.interpolateOutputs()).Finally(func(ctx context.Context) error {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This issue #758 was closed on November 2021, and from the comments it could be understood that the issue was actually fixed here #894. It seems like the changes introduced in this file might have caused the issue to respawn. I reproduced it in my local environment by creating a simple job with two steps, and it was only possible to set output variables in the first one.
@Poltergeist I would really appreciate it if you could verify that the fix from November 2021 was affected by these changes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @cweckesser, can you create a new issue with a reproducible workflow to show this case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants