Skip to content

Commit aebf9af

Browse files
committed
chore: Cache node modules in CI workflow
This commit adds a step to the CI workflow to cache node modules. Caching the node modules will improve the build time by reusing the cached dependencies instead of downloading them every time. The cache is stored in `~/.npm` on Linux/macOS and is keyed based on the operating system, build type, and the hash of the `package-lock.json` file. This ensures that the cache is specific to the project and can be restored when needed. see: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#example-using-the-cache-action
1 parent d8e684d commit aebf9af

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

.github/workflows/ci.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,20 @@ jobs:
2424
with:
2525
fetch-depth: 0
2626

27+
- name: Cache node modules
28+
id: cache-npm
29+
uses: actions/cache@v3
30+
env:
31+
cache-name: cache-node-modules
32+
with:
33+
# npm cache files are stored in `~/.npm` on Linux/macOS
34+
path: ~/.npm
35+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
36+
restore-keys: |
37+
${{ runner.os }}-build-${{ env.cache-name }}-
38+
${{ runner.os }}-build-
39+
${{ runner.os }}-
40+
2741
- name: Setup Node
2842
uses: actions/setup-node@v3
2943
with:

0 commit comments

Comments
 (0)