mirror of
				https://github.com/actions/setup-node.git
				synced 2025-10-31 23:43:33 +00:00 
			
		
		
		
	Update 0000-caching-dependencies.md
This commit is contained in:
		
							parent
							
								
									1bf30534fd
								
							
						
					
					
						commit
						5929471019
					
				| @ -13,26 +13,27 @@ Integration of caching functionality into `actions/setup-node` action will bring | |||||||
| - Simplify YAML pipelines because no need additional steps to enable caching | - Simplify YAML pipelines because no need additional steps to enable caching | ||||||
| - More users will use cache for Node.js so more customers will have fast builds! | - More users will use cache for Node.js so more customers will have fast builds! | ||||||
| 
 | 
 | ||||||
| As the first stage, we will add support for NPM dependencies caching. We can consider adding the same functionality for Yarn later. | We will add support for NPM and Yarn dependencies caching.   | ||||||
|  | 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.  | ||||||
| 
 | 
 | ||||||
| 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. | 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. | ||||||
| 
 | 
 | ||||||
| # Decision | # Decision | ||||||
| - Add `cache` input parameter to `actions/setup-node`. For now, input will accept the following values:  | - Add `cache` input parameter to `actions/setup-node`. For now, input will accept the following values:  | ||||||
|   - `npm` - enable caching for npm dependencies |   - `npm` - enable caching for npm dependencies | ||||||
|  |   - `yarn` - enable caching for yarn dependencies | ||||||
|   - `''` - disable caching (default value) |   - `''` - disable caching (default value) | ||||||
|   - Potentially, we will be able to extend this input to support Yarn |  | ||||||
| - 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`) | - 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`) | ||||||
| - Add optional input `package-lock-path` that will allow to specify path to `package-lock.json` file path: | - 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 | ||||||
|   - 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 | - 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) | ||||||
|   - If input contains file path, action will use the specified file |  | ||||||
|   - if input contains wildcards (like `**/package-lock.json`), hash of multiple files will be used |  | ||||||
| - 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) |  | ||||||
| - The following key cache will be used `${{ runner.os }}-npm-${{ hashFiles('<package-lock-path>') }}` | - The following key cache will be used `${{ runner.os }}-npm-${{ hashFiles('<package-lock-path>') }}` | ||||||
| - Action will cache global npm cache directory (retrieved via `npm config get cache`) | - Action will cache global cache: | ||||||
|  |   - Npm (retrieved via `npm config get cache`) | ||||||
|  |   - Yarn 1 (retrieved via `yarn cache dir`) | ||||||
|  |   - Yarn 2 (retrieved via `yarn config get cacheFolder`) | ||||||
| 
 | 
 | ||||||
| # Example of real use-cases | # Example of real use-cases | ||||||
| Default use case when `package-lock.json` or `yarn.lock` are located in repository root: | Npm package manager: | ||||||
| ```yml | ```yml | ||||||
| steps: | steps: | ||||||
| - uses: actions/checkout@v2 | - uses: actions/checkout@v2 | ||||||
| @ -42,15 +43,14 @@ steps: | |||||||
|     cache: npm |     cache: npm | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| More flexible solution for monorepos: | Yarn package manager: | ||||||
| ```yml | ```yml | ||||||
| steps: | steps: | ||||||
| - uses: actions/checkout@v2 | - uses: actions/checkout@v2 | ||||||
| - uses: actions/setup-node@v2 | - uses: actions/setup-node@v2 | ||||||
|   with: |   with: | ||||||
|     node-version: '14' |     node-version: '14' | ||||||
|     cache: npm |     cache: yarn | ||||||
|     package-lock-path: service1/yarn.lock |  | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| # Release process | # Release process | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user