I want to cache npm dependencies so that I does not do npm install every time I push and instead just load it from cache.
I think github action support this now?: How do I cache steps in GitHub actions?
Here are few cases
- If
package.jsonchanges, which meansyarn.lockorpackage-lock.jsonchanged so do npm install and update cache - Extending my above point, the contributor could be doing both
yarn installandnpm install
From the same above question, I changed my github action to something like this
name: Tsc compilation test
on: [push, pull_request]
jobs:
build:
name: Build
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cache NPM dependencies
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.OS }}-npm-cache-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-npm-cache-
- name: Install dependencies
run: npm install
- name: Test tsc
run: npm run ts-compile-check
This still does npm install and haven't reduced my computation time for installing dependencies (So I am not sure if this is working correctly or not)
Then I did yarn install axios hoping it would update my cache but in post-install I see this as logged
Post job cleanup.
Cache hit occurred on the primary key Linux-npm-cache-, not saving cache.
So here is my questions, Is it possible to achieve
- If
package.jsonchanges, which meansyarn.lockorpackage-lock.jsonchanged so donpm installand update cache - Extending my above point, the contributor could be doing both
yarn installandnpm install
And can someone explain me this
with:
path: ~/.npm
key: ${{ runner.OS }}-npm-cache-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-npm-cache-