GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix save-always/post-if with an output by bearfriend · Pull Request #1325 · actions/cache

Conversation

@bearfriend

@bearfriend bearfriend commented Feb 9, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Description

In v4, the save-always input was added. Unfortunately, it doesn't work because the inputs (and most other contexts or their keys) are not available to post-if. Currently, the only thing available to it that can be used to fix this feature is, seemingly, step outputs.

Note: Because outputs require an id, so too will using save-always. However, the feature was never properly documented and never worked, so I might argue this makes the fix not a breaking change

Motivation and Context

The save-always input to control the post-if does not work.
Fixes #1315

How Has This Been Tested?

All relevant tests have been updated and one new test has been added to test the new output specifically.

The changes have also been tested by running the action from this fork on one of my repos, where the job is intentionally failed, but the cache is successfully saved, and then restored in the next run attempt.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (add or update README or docs)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

dlockhart, svanherk, geurts, Mark-Weiss, margaree, QuietNatu, gtxaspec, Nanoseb, risu729, matttbe, and 9 more reacted with thumbs up emoji
All reactions
  • 👍 19 reactions
@bearfriend
bearfriend requested a review from a team as a code owner February 9, 2024 06:24
@bearfriend
bearfriend force-pushed the save-always-output branch from 1603c13 to 2d00cd5 Compare February 9, 2024 06:28
bearfriend
bearfriend commented Feb 9, 2024
View reviewed changes
Comment thread action.yml
main: 'dist/restore/index.js'
post: 'dist/save/index.js'
post-if: "success() || github.event.inputs.save-always"
post-if: "success() || (contains(steps.*.outputs.save-always-d18d746b9, 'true') && !contains(steps.*.outputs.save-always-d18d746b9, 'false'))"

@bearfriend bearfriend Feb 9, 2024

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

We can't know the step id, so check all steps for our unique output, and make sure it has at least one 'true' value and no 'false' values.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread action.yml
outputs:
cache-hit:
description: 'A boolean value to indicate an exact match was found for the primary key'
save-always-d18d746b9:

@bearfriend bearfriend Feb 9, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Give the new output a unique name to eliminate accidental conflicts when checked in post-if.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/restoreImpl.ts
): Promise<string | undefined> {
core.setOutput(
Outputs.SaveAlways,
core.getInput(Inputs.SaveAlways) || "false"

@bearfriend bearfriend Feb 9, 2024

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Always fall back to setting an explicit "false" value to prevent hijacking.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bearfriend
bearfriend force-pushed the save-always-output branch from d96e0a6 to 3e72a6e Compare February 9, 2024 16:26
@ddelange

ddelange commented Mar 11, 2024

Copy link
Copy Markdown

cc @to-s @bethanyj28

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@IanButterworth IanButterworth mentioned this pull request Mar 11, 2024
add overridable save-always option julia-actions/cache#107
Closed
@IanButterworth

IanButterworth commented Mar 13, 2024

Copy link
Copy Markdown

Bump. At least CI should be run here?
Making this new feature actually work would be appreciated.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@IanButterworth

IanButterworth commented Mar 25, 2024

Copy link
Copy Markdown

bump

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@IanButterworth

IanButterworth commented Apr 3, 2024

Copy link
Copy Markdown

bump. Please review this. The feature that the breaking change v4.0 was made for does not work. This purports to fix it.

risu729 reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bearfriend

bearfriend commented Apr 3, 2024

Copy link
Copy Markdown
Author

@bethanyj28 Do you have any idea why we're ok with this feature sitting broken for so long? Can we either get some movement on this PR or just close it? Is there someone else I can reach out to?

Thanks

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ruffsl

ruffsl commented Apr 5, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

@bearfriend , I couldn't get 3e72a6e to work. Must this be merged for action version namespace pinning to take effect?

image

      - name: Cache overlay
        id: cache-overlay
        uses: actions/cache@3e72a6ebe141e2d806ccb28d2696f2680fd84c32
        with:
          save-always: true
          path: tmp
          key: ${{ github.ref }}
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bearfriend

bearfriend commented Apr 5, 2024

Copy link
Copy Markdown
Author

@bearfriend , I couldn't get 3e72a6e to work. Must this be merged for action version namespace pinning to take effect?

It needs to go through the build process. This branch has done that and should be usable, though I haven't checked in a while:
bearfriend/cache@save-always-output-build

ruffsl, DanMawdsleyBA, and IanButterworth reacted with thumbs up emoji
All reactions
  • 👍 3 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Ottapettavan Ottapettavan mentioned this pull request Apr 7, 2024
@actions/cache v4.0.0 availability on npm registry #1313
Closed
@IanButterworth

IanButterworth commented Apr 16, 2024

Copy link
Copy Markdown

Bump

stempler, DilumAluthge, and IsaacSullivan reacted with thumbs up emoji
All reactions
  • 👍 3 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@deemp deemp mentioned this pull request Apr 19, 2024
[BUG] save-always input doesn't work nix-community/cache-nix-action#36
Closed
@IanButterworth

IanButterworth commented Apr 30, 2024

Copy link
Copy Markdown

Bump. Please review.

What's the issue holding this up? Does this action or the actions organization lack active maintainers?

bearfriend, DilumAluthge, sasawatc, and IsaacSullivan reacted with thumbs up emoji risu729 and DilumAluthge reacted with heart emoji
All reactions
  • 👍 4 reactions
  • ❤️ 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@IanButterworth

IanButterworth commented May 1, 2024

Copy link
Copy Markdown

I've opened a community discussion to understand why this is getting no attention https://github.com/orgs/community/discussions/121811

DilumAluthge, bearfriend, gildegoma, deemp, QuietNatu, sasawatc, alexsandrospecht, nathankoop, toxicscum, stempler, and 2 more reacted with thumbs up emoji
All reactions
  • 👍 12 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced May 6, 2024
v4.0 save always not working runs-on/cache#5
Closed
Fix save-always/post-if with an output runs-on/cache#6
Closed
@ruffsl

ruffsl commented Jun 6, 2024

Copy link
Copy Markdown

If there are any urgent bug fixes or security issues, please let me know and I'll make sure they're prioritized.

  • This action is lacking maintenance #1401 (comment)

@joshmgross , this PR could use some love. Thanks!

bearfriend reacted with heart emoji joshmgross reacted with eyes emoji
All reactions
  • ❤️ 1 reaction
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

joshmgross
joshmgross reviewed Jun 6, 2024
View reviewed changes

@joshmgross joshmgross left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks for your contribution!

Would you be up for adding an integration test in a workflow to validate that save-always is working? That would ensure this feature gets fixed and doesn't break in the future.

I'm thinking something along the lines of the actions/github-script integration tests that reference the action with ./ to validate the current branch's version.
https://github.com/actions/github-script/blob/main/.github/workflows/integration.yml

Let me know if you want any help setting that up.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bearfriend

bearfriend commented Jun 6, 2024

Copy link
Copy Markdown
Author

Would you be up for adding an integration test in a workflow to validate that save-always is working? That would ensure this feature gets fixed and doesn't break in the future.

Yeah I can look into that. Looks fairly straightforward. I'll let you know if I run into any issues. Thanks.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bearfriend added 6 commits June 6, 2024 15:15
@bearfriend
Fix save-always/post-if with an output
7214f3c
@bearfriend
Always output explicit "false" to prevent hijacking
f04cc73
@bearfriend
Add save-always inpute/output test
faaa391
@bearfriend
Fix mock name
d776be4
@bearfriend
Add save-always to README
bd94e24
@bearfriend
Add e2e test
3e8104d
@bearfriend
bearfriend force-pushed the save-always-output branch from 34664da to 3e8104d Compare June 7, 2024 01:59
@bearfriend
Remove test branch
8c04f89
@bearfriend
Require build
ed49aa2
@bearfriend

bearfriend commented Jun 7, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Author

@joshmgross Looks like there were already a similar set of tests in .github/workflows/workflow.yml that they're calling e2e tests. I added one there, but I'm getting an odd result. Perhaps it's expected before merging for a reason I'm not seeing, but the post step fails to run on this branch, but works as expected on another branch that has had build run on it.

Even if I add needs: build on this branch it still fails. Any insight into what might be happening?

Never mind! I had been assuming build was automatically run after merging because it's not mentioned in the PR template. After running it myself everything works as expected.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bearfriend
bearfriend force-pushed the save-always-output branch from cdb74e5 to ed49aa2 Compare June 7, 2024 12:25
bearfriend added 4 commits June 7, 2024 08:34
@bearfriend
build
eb5e89c
@bearfriend
Add back test branch
bbec097
@bearfriend
Remove needs: build
edbb703
@bearfriend
Remove test ranch again
286c02b
@IanButterworth IanButterworth mentioned this pull request Jun 7, 2024
This action is lacking maintenance #1401
Closed
@bearfriend
Fix Windows false positive
72831e6
joshmgross
joshmgross reviewed Jun 11, 2024
View reviewed changes
Comment thread .github/workflows/workflow.yml Outdated
Comment on lines +84 to +85
# End to end with save-always
test-save-always:

@joshmgross joshmgross Jun 11, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Suggested change
# End to end with save-always
test-save-always:
# End to end with save-always
test-save-always-with-failure:

What do you think about changing the name here to make it clear that these jobs are expected to fail?

I want to make it clear that the three failing checks are expected

PR Merge box with three failing checks from this job

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@IanButterworth IanButterworth Jun 11, 2024

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Is there any way to do something like a post hook to check that failure occurred and mark as passing? It does seem prone to confusion to have CI marked intentionally as failing

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@bearfriend bearfriend Jun 11, 2024

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Yep, completely agree.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@bearfriend bearfriend Jun 11, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Yeah I'm a little unclear on how this will ultimately look throughout the github UI. The status of the workflow in the Actions tab is is passing, but the indicator above for checks on the commit show failing. Maybe that's technically accurate, but still feels a little weird. Either way that's a bigger issue than this bug or this repo.

I don't think there is a way to force the step conclusions to pass that doesn't also give the post step success, which defeats the purpose of the test. Perhaps Josh knows more, though.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

joshmgross reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@joshmgross joshmgross Jun 11, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Agreed it's confusing - I don't think we support anyway to hide these. If you wanted a step to fail but not fail the job itself, you can add continue-on-error to the step but that wouldn't allow us to test the post-if case where success() is false.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bearfriend reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@bearfriend
Clarify that test is expected to fail
d9536f6
joshmgross
joshmgross reviewed Jun 12, 2024
View reviewed changes
Comment thread action.yml
main: 'dist/restore/index.js'
post: 'dist/save/index.js'
post-if: "success() || github.event.inputs.save-always"
post-if: "success() || (contains(steps.*.outputs.save-always-d18d746b9, 'true') && !contains(steps.*.outputs.save-always-d18d746b9, 'false'))"

@joshmgross joshmgross Jun 12, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

First of all, I want to say thank you for your contributions, patience, and responsiveness to feedback.

As far as I can tell, we only officially support accessing the runner context in post-if as that's what's currently in our documentation:

  post: 'cleanup.js'
  post-if: runner.os == 'linux'

I've chatted a bit internally with some engineers who work in on the Actions runner and other contexts aren't intentionally supported:

 "post-if": "non-empty-string"

https://github.com/actions/runner/blob/edfdbb966118990c9898c6723121f5610188c155/src/Runner.Worker/action_yaml.json#L91

non-empty-string effectively means that the schema is only ensuring that the value provided to post-if is not empty, it doesn't specific any contexts.

The use of a designated output and reading all step outputs in the current job does not feel sustainable and it's relying on undefined behavior, so I'm reluctant to depend on it for this feature. If this breaks in the future due to changes in the runner, we won't have any official alternatives and users will have already begun relying on this feature.

I'm going to start a discussion in #1315 to gather feedback on next steps. For full transparency, I'm leaning towards removing save-always and recommending users switch to using the dedicated actions/cache/save actions with an if: always() to support these scenarios.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@IanButterworth IanButterworth Jun 12, 2024

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

We use actions/cache in a composite action, where we rely on actions/cache injecting the post step after the user's code. Moving to require an explicit actions/cache/save I believe would not be possible with a composite action, requiring the user to change their workflows, which wouldn't be compatible with our needs.

Here is our PR that's lined up for this feature working https://github.com/julia-actions/cache/pull/107/files

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@ruffsl ruffsl Jun 12, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

use actions/cache in a composite action, where we rely on actions/cache injecting the post step

@IanButterworth , I had the same goal, but we may have other issues in common as well:

  • Support pre and post steps in Composite Actions runner#1478 (comment)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@joshmgross joshmgross mentioned this pull request Jun 12, 2024
v4.0 save always not working #1315
Closed
@joshmgross joshmgross mentioned this pull request Aug 13, 2024
fix-save-always #1450
Closed
@joshmgross

joshmgross commented Oct 7, 2024

Copy link
Copy Markdown
Contributor

#1315 (comment)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joshmgross joshmgross closed this Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

3 more reviewers
@IanButterworth IanButterworth IanButterworth left review comments
@ruffsl ruffsl ruffsl left review comments
@joshmgross joshmgross joshmgross left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

v4.0 save always not working

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@bearfriend @ddelange @IanButterworth @ruffsl @joshmgross
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.