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 — Skip download option (allow only to check if cache exists for the given key) · Issue #901 · actions/cache

Skip download option (allow only to check if cache exists for the given key) #901

New issue
Copy link
New issue
Copy link
Closed
#1041
Closed
Skip download option (allow only to check if cache exists for the given key)#901
#1041
Copy link
Assignees
tanuj077kotewar
Labels
area:granular-controlIssues related to granular control in saving or restoring cache

Description

@DaSchTour
DaSchTour
opened on Aug 19, 2022
Issue body actions

I have some jobs that do actions if cache there is a cache hit or not or add stuff to the cache, but they actually do not care about the content of the cache. I think it would be convenient to have an option not download the content of the cache.

Reacted by Bogdan Drutu, Shon Diaz, Nadav Zingerman, Marc Mueller and John Shaffer

Activity

  1. github-actions
    assigned
    bishal-pdMSFT
    on Aug 19, 2022
  2. bogdandrutu commented on Sep 1, 2022

    @bogdandrutu
    bogdandrutu
    on Sep 1, 2022
    More actions

    I would like this as well.

  3. Wambosa commented on Sep 1, 2022

    @Wambosa
    Wambosa
    on Sep 1, 2022
    More actions

    I am running into an issue that might just be related to this.
    Its unclear to me if I can just explicit set the cache.

    The docs say key is required :/
    In my case, I want to set the cache and not try to download it.
    Perhaps it would be nice if key became optional and was used to flag explicit set behavior?

    setupJob:
        steps:
        - uses: actions/checkout@v2
    
        - name: Restore Workspace if its there
          id: try-restore
          uses: actions/cache@v3
          with:
            path: ${{ github.workspace }}
            key: restore-${{ hashFiles('package-lock.json', 'Makefile') }}
          
      ... (other logic) ...
          
        - name: Cache Workspace
          if: steps.try-restore.outputs.cache-hit != 'true'
          uses: actions/cache@v3
          with:
            path: ${{ github.workspace }}
            restore-keys: |
              restore-${{ hashFiles('package-lock.json', 'Makefile', 'src/', 'infra/') }}
              other-job-can-get-my-workspace-with-const-key
    

    other job

    otherjob:
        steps:
        - name: Get working directory 
          uses: actions/cache@v3
          with:
            path: ${{ github.workspace }}
            key: other-job-can-get-my-workspace-with-const-key
    
  4. bishal-pdMSFT commented on Sep 11, 2022

    @bishal-pdMSFT
    bishal-pdMSFT
    on Sep 11, 2022
    More actions

    @DaSchTour @bogdandrutu not sure I understand the rationale here of just checking existence of cache but not use it. Could you please share some use cases.
    Please note that now we have GitHub REST API and gh CLI extension to get a cache metadata by key. You can use these for such cases instead.

    Reacted by no-yan and Nadav Zingerman
  5. bishal-pdMSFT
    added
    area:granular-controlIssues related to granular control in saving or restoring cache
    on Sep 11, 2022
  6. DaSchTour commented on Sep 12, 2022

    @DaSchTour
    DaSchTour
    on Sep 12, 2022
    Author
    More actions

    @bishal-pdMSFT well it's not really just existence, it's also to "initialize" the cache if needed. The workflow simplfied looks like this.

    1. action/cache
    2. do something if cache is not hit adding stuff to the cache

    If there is a cache hit I skip the second step, if not I add something to the cache. So if the cache is hit I don't care what's actually in the cache. But if cache is not hit I need to have it to be able to put something in there.

  7. cdce8p commented on Oct 23, 2022

    @cdce8p
    cdce8p
    on Oct 23, 2022
    Contributor
    More actions

    Could you please share some use cases.

    To expand one what has already been said. In some the workflows I've seen, the dependency install and tests happen in separate jobs. I.e.

    • Job 1: Check if cache exists, if not download / build dependencies and create new cache entry
    • Job 2 - X: Different test runners. Restore environment from cache. If restore failed, fail test. Run tests, linters, etc.

    If for Job 1 a useable cache already exists, there is no point in spending the extra time restoring it as it won't get used anyway.

    Please note that now we have GitHub REST API and gh CLI extension to get a cache metadata by key. You can use these for such cases instead.

    True, although that's probably more complicate. It isn't enough to check if a specific key exists, due to the way restore works it must be from the same or base ref. The action does this check already. I imagine it's much easier to add a simple switch to skip restore.

    --
    Note: There is also #831 proposing something similar.

    Reacted by Nadav Zingerman and Daniel Schuba
  8. bogdandrutu commented on Oct 23, 2022

    @bogdandrutu
    bogdandrutu
    on Oct 23, 2022
    More actions

    We have the same use case, since we have a large repo, we want to run tests in multiple jobs, hence we cache all go dependencies initially then run tests in separate jobs.

    Reacted by Shon Diaz
  9. kotewar
    assigned
    tanuj077
    and
    kotewar
    and unassigned
    bishal-pdMSFT
    on Nov 10, 2022
  10. kotewar commented on Dec 7, 2022

    @kotewar
    kotewar
    on Dec 7, 2022
    Contributor
    More actions

    Hey all, 👋🏽

    We have created a discussion with a proposal that we feel will solve this problem, do let us know your feedback, thanks 😊

  11. bogdandrutu commented on Dec 8, 2022

    @bogdandrutu
    bogdandrutu
    on Dec 8, 2022
    More actions

    @kotewar unfortunately that discussion completely ignores this use case :)

  12. Wambosa commented on Dec 8, 2022

    @Wambosa
    Wambosa
    on Dec 8, 2022
    More actions

    We have the same use case, since we have a large repo, we want to run tests in multiple jobs, hence we cache all go dependencies initially then run tests in separate jobs.

    @bogdandrutu, yes we do this same exact thing. For reference to everyone else here. It looks something like this:
    image

    The very first job is responsible for loading all the deps into the cache.

    This currently works, however it is somewhat wasteful and could be better if we could control explicit set on cache-key invalidation.

  13. cdce8p commented on Dec 23, 2022

    @cdce8p
    cdce8p
    on Dec 23, 2022
    Contributor
    More actions

    I've implemented a possible solution with #1041. A dry-run: true option would work well from my initial testing.
    If someone else wants to test it

          - uses: cdce8p/cache@restore-dry-run
            with:
              ...
              dry-run: true
    Reacted by Sankalp
  14. kotewar
    changed the title [-]Skip download option[/-] [+]Skip download option (allow only to check if cache exists for the given key)[/+] on Dec 27, 2022
  15. kotewar
    closed this as completedin #1041on Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @kotewar
    kotewar
  • @tanuj077
    tanuj077

Labels

area:granular-controlIssues related to granular control in saving or restoring cache

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    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.