geeklearningio / gl-vsts-tasks-yarn

Yarn Package Manager Visual Studio Team Services Build and Release Management extensions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Caching for node_modules based on package.json/yarn.lock?

dotansimha opened this issue · comments

Are you reporting a bug or a feature request ?

  • Bug
  • Feature request

Description

I was wondering if it's possible to add support for caching node_modules according to a hash of either package.json or yarn.lock.
It could make the builds much faster.

Expected behavior

After each sucussful build, add a build task for caching node_modules, and save it with a key created by a hash of package.json or yarn.lock.
When build starts, it should hash it again and look in the cache for a matching file, untar it, and then run yarn install.

CircleCI has a similar solution that could be integrated with Yarn:

System information

VSTS or TFS:

  • VSTS
  • TFS

Agent:

  • Hosted
  • Custom

OS:

  • Windows
  • Mac
  • Linux
commented

This can be achieved with the new CacheBeta pipeline task. It works by running a cache step before the yarn install, which restores / caches the global .yarn cache. So the yarn install still runs, but much faster due to having a pre-primed cache.

https://docs.microsoft.com/en-us/azure/devops/pipelines/caching/?view=azure-devops#yarn

I haven’t had the time to go through the new caching feature. Is there anything the yarn task could do to make it easier in your opinion?

Looks pretty straightforward to me.

commented

Not really, it just worked right out of the box for me. I added the new CacheBeta task, copied the config from the docs, tweaked it around to fit my project, and was good to go.
I guess it would have been easier if your yarn task just had a checkbox to enable and abstracted away CacheBeta :p