mirror of
https://gitea.com/actions/setup-node.git
synced 2024-11-22 18:19:33 +01:00
dra
This commit is contained in:
parent
38d90ce44d
commit
d9aab2aba4
2 changed files with 49 additions and 1 deletions
|
@ -1,7 +1,7 @@
|
||||||
# 0. Caching dependencies
|
# 0. Caching dependencies
|
||||||
Date: 2021-05-21
|
Date: 2021-05-21
|
||||||
|
|
||||||
Status: Proposed
|
Status: Accepted
|
||||||
|
|
||||||
# Context
|
# Context
|
||||||
`actions/setup-node` is the 2nd most popular action in GitHub Actions. A lot of customers use it in conjunction with [actions/cache](https://github.com/actions/cache) to speed up dependencies installation.
|
`actions/setup-node` is the 2nd most popular action in GitHub Actions. A lot of customers use it in conjunction with [actions/cache](https://github.com/actions/cache) to speed up dependencies installation.
|
||||||
|
|
48
docs/adrs/0001-support-caching-deps-for-monorepos.md
Normal file
48
docs/adrs/0001-support-caching-deps-for-monorepos.md
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
# 0. Support caching dependencies for mono repos
|
||||||
|
Date: 2021-07-13
|
||||||
|
|
||||||
|
Status: Proposed
|
||||||
|
|
||||||
|
## Context
|
||||||
|
Currently, `actions/setup-node` supports caching dependencies for Npm and Yarn package managers.
|
||||||
|
For the first iteration, we have decided to not support cases where `package-lock.json` / `yarn.lock` are located outside of repository root.
|
||||||
|
Current implementation searches the following file patterns in the repository root: `package-lock.json`, `yarn.lock` (in order of resolving priorities)
|
||||||
|
|
||||||
|
Obviosly, it made build-in caching unusable for mono-repos and repos with complex structure.
|
||||||
|
We would like to revisit this decision and add customization for dependencies lock file location.
|
||||||
|
|
||||||
|
## Proposal
|
||||||
|
We have the following options:
|
||||||
|
1. Allow to specify directory where `package-lock.json` or `yarn.lock` are located
|
||||||
|
2. Allow to specify path to the dependencies lock file (including directory path and filename)
|
||||||
|
|
||||||
|
The second option looks more generic because it allows to:
|
||||||
|
- specify multiple dependencies files using file patterns like `**/package-lock.json` ([one of recommended approaches in actions/cache](https://github.com/actions/cache/blob/main/examples.md#macos-and-ubuntu))
|
||||||
|
- specify custom dependencies files like `src/npm-shrinkwrap.json`
|
||||||
|
- change default resolving priority if both `yarn.lock` and `package-lock.json` exist in repository
|
||||||
|
|
||||||
|
## Decision
|
||||||
|
|
||||||
|
Add `deps-lock-file` input that will accept path (relative to repository root) to dependencies lock file.
|
||||||
|
If path provided path contains wildcards, the action will search all maching files and calculate common hash like `${{ hashFiles('**/packages.lock.json') }}` YAML construction does.
|
||||||
|
The hash of privided matched files will be used as a part of cache key.
|
||||||
|
|
||||||
|
Yaml examples:
|
||||||
|
```yml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: 14
|
||||||
|
cache: npm
|
||||||
|
deps-lock-file: 'sub-project/package-lock.json'
|
||||||
|
```
|
||||||
|
```yml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: 14
|
||||||
|
cache: yarn
|
||||||
|
deps-lock-file: 'sub-project/**/yarn.lock'
|
||||||
|
```
|
Loading…
Reference in a new issue