Skip to content

Do not save cache if files are empty #624

Description

@finalburn

Even if the target files are not present or empty, a cache key is saved:

Post job cleanup.
/usr/bin/tar --posix --use-compress-program zstd -T0 -cf cache.tzst -P -C /home/runner/work/boardfish/project --files-from manifest.txt
Cache Size: ~0 MB (22 B)
Cache saved successfully
Cache saved with key: Linux-project-data-17007abbc08...

I'd prefer not to register a key or save a cache in this particular instance.

For now, I'll need to check whether the file exists manually. But I'd rather not have to do that and check against a cache hit instead.

- name: TEST  | Check crystalball map is available
  id: check_crystalball_map_exists
  uses: andstor/file-existence-action@v1
  with:
    files: "tmp/crystalball_data.yml"

Activity

  1. PaulRBerg commented on Aug 17, 2021

    @PaulRBerg

    Yes it would be great if we could disable the saving of cache in this circumstance.

    This issue seems related to #489 though.

  2. github-actions commented on May 5, 2022

    @github-actions

    This issue is stale because it has been open for 200 days with no activity. Leave a comment to avoid closing this issue in 5 days.

  3. cderv commented on May 5, 2022

    @cderv

    I would still like to this possible.

  4. self-assigned this
    on May 5, 2022
  5. added
    bugSomething isn't working
    and removed on May 5, 2022
  6. linked a pull request that will close this issueUpgraded @actions/cache to 2.0.5 #808on May 31, 2022
  7. kotewar commented on May 31, 2022

    @kotewar
    Contributor

    The issue has been fixed and released in v3.0.3
    Cache action will now check if at least one path/file/folder exists for the given path in the action. If nothing is found, no cache will be saved.

    Note: We are not checking for the size as the compressed tar/zip might still be a few bytes in size. So it is not possible to tell if the cache is empty or not just by the size of the compressed file.

  8. Kurt-von-Laven commented on Sep 17, 2023

    @Kurt-von-Laven

    Now that the lookup-only parameter has been added, the drawback of not saving empty caches is that it forces you to create an empty file if you just want to cache whether something has happened. For example, when vendoring dependencies, such as with Yarn Zero-installs, it's important to check the correctness of committed dependencies against the package registry, but this only needs to be done once per dependency bump.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions