setup-deno icon indicating copy to clipboard operation
setup-deno copied to clipboard

Cache deno modules

Open jacque006 opened this issue 2 years ago • 2 comments

It would be nice if this action had a way to cache deno modules that had been downloaded in previous runs, similarly to https://github.com/actions/setup-node#caching-global-packages-data

The cache looks like it is easy enough to find https://deno.land/manual/linking_to_external_code#linking-to-third-party-code . However, I'm unsure what the key/hash for lookup and download would be to:

  • Determine if a module had changed in any file.
  • Lookup existing module caches.

This part is easier with a NodeJS package manager such as npm or yarn as you can just use a hash of the lockfile.

jacque006 avatar Jun 09 '22 20:06 jacque006

I bet there's some way to do this using https://github.com/actions/cache, but I'm not sure what would be the right paths for hashFiles() and path

jespertheend avatar Aug 09 '22 17:08 jespertheend

I bet there's some way to do this using https://github.com/actions/cache, but I'm not sure what would be the right paths for hashFiles() and path

It can be achieved by pointing path to the location of DENO_DIR and calling hashFiles() on the lockfile that is written with deno cache --lock=<file> --lock-write. For example:

env:
  DENO_DIR: my_cache_directory

steps:
  - name: Cache Deno dependencies 
    uses: actions/cache@v2
    with:
      path: ${{ env.DENO_DIR }}
      key: ${{ hashFiles('lock.json') }}

Having an option in setup_deno to cache could be useful, although there is perhaps more diversity in what lockfile names people use compared to Node where it is almost always package-lock.json, npm-shrinkwrap.json or yarn.lock.

GJZwiers avatar Aug 09 '22 19:08 GJZwiers