Compare commits

..

9 Commits

Author SHA1 Message Date
87a21fa69e Automate releasing new action versions 2021-06-29 12:33:36 +03:00
e79375d669 Merge pull request #266 from actions/malob/cache-adr
Create ADR for integrating cache functionality to setup-node action
2021-06-29 09:50:06 +03:00
5929471019 Update 0000-caching-dependencies.md 2021-06-02 15:52:17 +03:00
1bf30534fd Update docs/adrs/0000-caching-dependencies.md
Co-authored-by: Alejandro Pauly <alepauly@github.com>
2021-05-26 17:29:27 +03:00
ae26aaf1b5 Update 0000-caching-dependencies.md 2021-05-26 17:27:14 +03:00
5fddb2d510 Update 0000-caching-dependencies.md 2021-05-24 17:35:10 +03:00
8c35c6c880 Update 0000-caching-dependencies.md 2021-05-21 18:28:06 +03:00
24265e14d4 Create 0000-caching-dependencies.md 2021-05-21 18:16:14 +03:00
5c355be170 use 14 instead of 12 in README beacuse peoply copy (#235) 2021-02-23 23:21:23 -05:00
6 changed files with 14967 additions and 9536 deletions

View File

@ -0,0 +1,27 @@
name: Release new action version
on:
release:
types: [released]
workflow_dispatch:
inputs:
TAG_NAME:
description: 'Tag name that the major tag will point to'
required: true
env:
TAG_NAME: ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }}
permissions:
contents: write
jobs:
update_tag:
name: Update the major tag to include the ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }} changes
environment:
name: releaseNewActionVersion
runs-on: ubuntu-latest
steps:
- name: Update the ${{ env.TAG_NAME }} tag
uses: actions/publish-action@v0.1.0
with:
source-tag: ${{ env.TAG_NAME }}
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}

View File

@ -19,7 +19,7 @@ steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '12'
node-version: '14'
```
The action will first check the local cache for a semver match. The hosted images have been updated with the latest of each LTS from v8, v10, v12, and v14. `self-hosted` machines will benefit from the cache as well only downloading once. The action will pull LTS versions from [node-versions releases](https://github.com/actions/node-versions/releases) and on miss or failure will fall back to the previous behavior of downloading directly from [node dist](https://nodejs.org/dist/).
@ -36,7 +36,7 @@ steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '12'
node-version: '14'
- run: npm install
- run: npm test
```
@ -54,7 +54,7 @@ steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '12'
node-version: '14'
check-latest: true
- run: npm install
- run: npm test
@ -67,7 +67,7 @@ jobs:
runs-on: ubuntu-16.04
strategy:
matrix:
node: [ '10', '12' ]
node: [ '12', '14' ]
name: Node ${{ matrix.node }} sample
steps:
- uses: actions/checkout@v2
@ -93,7 +93,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '12'
node-version: '14'
architecture: 'x64' # optional, x64 or x86. If not specified, x64 will be used by default
- run: npm install
- run: npm test

23454
dist/index.js vendored

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,59 @@
# 0. Caching dependencies
Date: 2021-05-21
Status: Proposed
# 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.
See more examples on proper usage in [actions/cache documentation](https://github.com/actions/cache/blob/main/examples.md#node---npm).
# Goals & Anti-Goals
Integration of caching functionality into `actions/setup-node` action will bring the following benefits for action users:
- Decrease the entry threshold for using the cache for Node.js dependencies and simplify initial configuration
- 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!
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.
# Decision
- Add `cache` input parameter to `actions/setup-node`. For now, input will accept the following values:
- `npm` - enable caching for npm dependencies
- `yarn` - enable caching for yarn dependencies
- `''` - disable caching (default value)
- 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`)
- 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)
- The following key cache will be used `${{ runner.os }}-npm-${{ hashFiles('<package-lock-path>') }}`
- 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
Npm package manager:
```yml
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
cache: npm
```
Yarn package manager:
```yml
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
cache: yarn
```
# Release process
As soon as functionality is implemented, we will release minor update of action. No need to bump major version since there are no breaking changes for existing users.
After that, we will update [starter-workflows](https://github.com/actions/starter-workflows/blob/main/ci/node.js.yml) and [GitHub Action documentation](https://docs.github.com/en/actions/guides/building-and-testing-nodejs#example-caching-dependencies).

945
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -25,21 +25,21 @@
"dependencies": {
"@actions/core": "^1.2.6",
"@actions/exec": "^1.0.3",
"@actions/github": "^4.0.0",
"@actions/github": "^1.1.0",
"@actions/http-client": "^1.0.6",
"@actions/io": "^1.0.2",
"@actions/tool-cache": "^1.5.4",
"semver": "^6.1.1"
},
"devDependencies": {
"@types/jest": "^24.9.1",
"@types/jest": "^24.0.13",
"@types/node": "^12.0.4",
"@types/semver": "^6.0.0",
"@vercel/ncc": "^0.27.0",
"@zeit/ncc": "^0.21.0",
"jest": "^24.9.0",
"jest-circus": "^24.7.1",
"prettier": "^1.19.1",
"ts-jest": "^24.3.0",
"typescript": "^3.9.9"
"typescript": "^3.8.3"
}
}