dhadka / ezcache Goto Github PK
View Code? Open in Web Editor NEWEasy to use caching for GitHub Actions
License: MIT License
Easy to use caching for GitHub Actions
License: MIT License
I disabled the local storage tests since I don't always have a self-hosted runner available, causing the tests to fail. I think the best way to handle this is to move the local storage tests to a separate workflow file and use the path filter to only run when the local storage code changes.
First of all, thanks for the great library.
I wonder if we can have a handler for node_module. I know it is kind of against the best practice but we are fine to take it.
basically we just need to use key like hash value of yarn.lock and node version.
To do this in actions/cache@v2, it is like
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache yarn cache
uses: actions/cache@v2
id: cache-yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.node-version }}-nodemodules-
I have self-hosted runner that used this cache action in way described in docs:
name: myworkflow
on:
push:
branches:
- master
jobs:
dependencies:
concurrency:
group: "publish"
cancel-in-progress: true
runs-on: self-hosted
steps:
- uses: actions/checkout@v2
with:
fetch-depth: '0'
- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- uses: actions/setup-node@v2
with:
node-version: 12
# Here we start local cache for yarn
- name: Local cache for yarn
uses: dhadka/ezcache@master
with:
type: yarn
provider: local
# Here we check cache hit
- name: Install
if: steps.cache.outputs.cache-hit != 'true'
run: |
yarn install
# ...other steps...
When jobs finished, the last step with saving cache is failed with error:
Post job cleanup.
Saving cache with Yarn handler
Using LocalStorageProvider
Calling saveCache('/Users/anka/Library/Caches/Yarn/v6', 'macOS--yarn-f2d71935d782918418e11b56a15cb0559fe260de762b383caa47724467a41ebd')
Error: Error: ENOENT: no such file or directory, stat '/Users/anka/Library/Caches/Yarn/v6/npm-node-15.14.0-e7d85644ba65780504dfc7897a6e4a93a5d0e686-integrity/node_modules/node/.bin/node'
Error: Error: ENOENT: no such file or directory, stat '/Users/anka/Library/Caches/Yarn/v6/npm-node-15.14.0-e7d85644ba65780504dfc7897a6e4a93a5d0e686-integrity/node_modules/node/.bin/node'
In docs you say:
Stores caches on the local file system. Please note that caches can only be shared between jobs on the same machine. Therefore, avoid using when multiple self-hosted runners are registered or on hosted runners.
But, if I have 5 self-hosted runner, that can run workflows parallel, I want that each of this machine use its own cache.
For achieve this, we can provide key
value, like it @actions/cache and this problem will gone
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.