Code Monkey home page Code Monkey logo

Comments (8)

DanTup avatar DanTup commented on June 3, 2024 1

Aha, interesting. I tried to come up with something clever like that, but failed :-)

Really I'd like to include the caching inside the action (as discussed on another issue), but this should work in the meantime, I'll give it a go. Thanks!

from cache.

joshmgross avatar joshmgross commented on June 3, 2024

@DanTup you could incorporate the date into your key, to ensure that every day you create a new cache. Unused caches will already be evicted after 7 days, so you don't need to worry about that (see docs)

Example:

# http://man7.org/linux/man-pages/man1/date.1.html
- name: Get Date
  id: get-date
  run: |
    echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
  shell: bash # For Windows, Linux and macOS default to bash already

- uses: actions/cache@v1
  with:
    path: ~/.cache/directory
    key: ${{ runner.OS }}-build-${{ steps.get-date.outputs.date }}

Leaving off restore-key if you don't want any other caches from previous dates.

from cache.

joshmgross avatar joshmgross commented on June 3, 2024

Really I'd like to include the caching inside the action

Yep I think that would be an ideal scenario for any setup action where you knew explicitly what you could cache

from cache.

chrispat avatar chrispat commented on June 3, 2024

@DanTup in the case of something like Dart that is already hosted on a very fast CDN like google I very much doubt you are going to gain a huge amount in terms of time. The file still needs to be downloaded to the VM for each job you are just choosing to download from Azure storage vs Google storage at that point.

from cache.

DanTup avatar DanTup commented on June 3, 2024

@chrispat you're right - I used that as an example because it was easy to explain. In reality it's only around 8 seconds to download and extract Dart so it's not worth caching. the VS Code install and Flutter downloads are much slower though. Flutter comes as either a zip file (which is quite large) or a git clone which downloads some bits on-demand. It currently takes several minutes so I'd like to try and speed that up (doing it inside the setup-flutter action would be more flexible though - for ex. we can read the engine hash from a local file to use as a cache key).

from cache.

Cyberbeni avatar Cyberbeni commented on June 3, 2024

https://dart.dev/tools/sdk/archive sends this query to get info about the latest version (copied from chrome developer tools):

curl 'https://storage.googleapis.com/dart-archive/channels/stable/release/latest/VERSION' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Referer: https://dart.dev/tools/sdk/archive' -H 'Origin: https://dart.dev' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36' --compressed

You can use the revision field inside response for the cache key, this way you will only need to redownload it when it's actually necessary

from cache.

DanTup avatar DanTup commented on June 3, 2024

Yeah, though doing all that in a single command inside the yaml file is rather messy to save a few seconds. It'd be much better with #55 :)

from cache.

joshmgross avatar joshmgross commented on June 3, 2024

Including the date in your cache key is a way to achieve time-based expiration.

It'd be much better with #55 :)

#55 is now closed, see https://github.com/actions/toolkit/tree/master/packages/cache for the @actions/cache package.

from cache.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.