Skip to content

Commit 5929471

Browse files
author
Maxim Lobanov
committed
Update 0000-caching-dependencies.md
1 parent 1bf3053 commit 5929471

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

docs/adrs/0000-caching-dependencies.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,27 @@ Integration of caching functionality into `actions/setup-node` action will bring
1313
- Simplify YAML pipelines because no need additional steps to enable caching
1414
- More users will use cache for Node.js so more customers will have fast builds!
1515

16-
As the first stage, we will add support for NPM dependencies caching. We can consider adding the same functionality for Yarn later.
16+
We will add support for NPM and Yarn dependencies caching.
17+
As the first stage, we won't support custom locations for `package-lock.json`, `yarn.lock` files and action will work only when files are located in repository root.
1718

1819
We don't pursue the goal to provide wide customization of caching in scope of `actions/setup-node` action. The purpose of this integration is covering ~90% of basic use-cases. If user needs flexible customization, we should advice them to use `actions/cache` directly.
1920

2021
# Decision
2122
- Add `cache` input parameter to `actions/setup-node`. For now, input will accept the following values:
2223
- `npm` - enable caching for npm dependencies
24+
- `yarn` - enable caching for yarn dependencies
2325
- `''` - disable caching (default value)
24-
- Potentially, we will be able to extend this input to support Yarn
2526
- Cache feature will be disabled by default to make sure that we don't break existing customers. We will consider enabling cache by default in next major release (`v3`)
26-
- Add optional input `package-lock-path` that will allow to specify path to `package-lock.json` file path:
27-
- If input is not defined, action will try to search `package-lock.json` or `yarn.lock` (npm 7.x supports `yarn.lock` files) files in the repository root and throw error if no one is found
28-
- If input contains file path, action will use the specified file
29-
- if input contains wildcards (like `**/package-lock.json`), hash of multiple files will be used
30-
- The hash of file provided in `package-lock-path` input will be used as cache key (the same approach like [actions/cache](https://github.com/actions/cache/blob/main/examples.md#node---npm) recommends)
27+
- Action will try to search `package-lock.json` or `yarn.lock` (npm 7.x supports `yarn.lock` files) files in the repository root and throw error if no one is found
28+
- The hash of found file will be used as cache key (the same approach like [actions/cache](https://github.com/actions/cache/blob/main/examples.md#node---npm) recommends)
3129
- The following key cache will be used `${{ runner.os }}-npm-${{ hashFiles('<package-lock-path>') }}`
32-
- Action will cache global npm cache directory (retrieved via `npm config get cache`)
30+
- Action will cache global cache:
31+
- Npm (retrieved via `npm config get cache`)
32+
- Yarn 1 (retrieved via `yarn cache dir`)
33+
- Yarn 2 (retrieved via `yarn config get cacheFolder`)
3334

3435
# Example of real use-cases
35-
Default use case when `package-lock.json` or `yarn.lock` are located in repository root:
36+
Npm package manager:
3637
```yml
3738
steps:
3839
- uses: actions/checkout@v2
@@ -42,15 +43,14 @@ steps:
4243
cache: npm
4344
```
4445
45-
More flexible solution for monorepos:
46+
Yarn package manager:
4647
```yml
4748
steps:
4849
- uses: actions/checkout@v2
4950
- uses: actions/setup-node@v2
5051
with:
5152
node-version: '14'
52-
cache: npm
53-
package-lock-path: service1/yarn.lock
53+
cache: yarn
5454
```
5555
5656
# Release process

0 commit comments

Comments
 (0)