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

Alllow Actions to have post-run steps that run even after an earlier failure #987

Closed
robtaylor opened this issue Feb 14, 2021 · 5 comments
Closed
Labels
enhancement New feature or request

Comments

@robtaylor
Copy link

Describe the enhancement
For some classes of Action, it would be helpful if the post run Step would be run even if an earlier Step has failed.

The concrete use case I have in mind here is for action/cache - For many classes of cache (e.g. ccache, package installation), you still want to store the cache, even if failure has occurred. This would allow subsequent runs of the step with the issue to fail or success more quickly.

Code Snippet
A possible design here is to add apost-always: key.
e.g.

name: 'Cache'
description: 'Cache artefacts like dependencies and build outputs to improve workflow execution time'
author: 'GitHub'
...
runs:
  using: 'node12'
  main: 'dist/restore/index.js'
  post-always: 'dist/save/index.js'
  post-if: 'success()'
...

This could be implemented in the runner codebase by adding an Always getter to IStep and behaving appropriately in StepsRunner in the case of runner shutdown.

NOTE: if the feature request has been agreed upon then the assignee will create an ADR. See docs/adrs/README.md

@robtaylor robtaylor added the enhancement New feature or request label Feb 14, 2021
@rr-nick-tan
Copy link

i'm looking for something similar for Composite Action, i'd like to have Java try/finally logic that i can clean up resources in post-run (aka, finally)

@hross
Copy link
Contributor

hross commented Mar 30, 2021

This should work already if you provide always() to the post-if condition, like:

runs:
  using: 'node12'
  main: 'dist/restore/index.js'
  post: 'dist/save/index.js'
  post-if: 'always()'

@hross
Copy link
Contributor

hross commented Mar 30, 2021

Closing since I think this is answered, will re-open if I'm missing something.

@hross hross closed this as completed Mar 30, 2021
@robtaylor
Copy link
Author

@hross I'm not sure this works as you want two separate post steps - one that always runs and one that only runs on success.

Does the post step have a way to find out whether the run was successful?

@hross
Copy link
Contributor

hross commented Mar 31, 2021

mpdude added a commit to webfactory/ssh-agent that referenced this issue Jun 2, 2021
According to actions/runner#987, this should run the post step (cleanup.js) also when a workflow fails.

Probably most important on self-hosted runners that are not ephemeral, to terminate SSH agents from failed jobs as well.
mpdude added a commit to webfactory/ssh-agent that referenced this issue Jun 2, 2021
According to actions/runner#987, this should run the post step (cleanup.js) also when a workflow fails.

Probably most important on self-hosted runners that are not ephemeral, to terminate SSH agents from failed jobs as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants