Compare commits

..

14 Commits

Author SHA1 Message Date
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
46071b5c7a Fix TypeScript error line/column (#125)
* Fix TypeScript error line/column

* Adopt official pattern from VS Code

* Minor cleanup

* Add tests for tsc problem matcher

Co-authored-by: Lukas Spieß <lumaxis@github.com>
2021-02-17 10:52:41 -05:00
05f0551dbd chore: operating-system -> os (#184)
Schema validation was flagging the old property name
2021-01-20 14:15:22 -05:00
23bdee16bc Clarifications to the README (#167) (#229)
* Update README.md

* Update README.md

Co-authored-by: Bryan MacFarlane <bryanmacfarlane@github.com>

Co-authored-by: Konrad Pabjan <konradpabjan@github.com>
2021-01-20 11:48:26 -05:00
4257181919 Bump acorn from 5.7.3 to 5.7.4 (#122)
Bumps [acorn](https://github.com/acornjs/acorn) from 5.7.3 to 5.7.4.
- [Release notes](https://github.com/acornjs/acorn/releases)
- [Commits](https://github.com/acornjs/acorn/compare/5.7.3...5.7.4)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-01-20 11:28:06 -05:00
7f4d5225d8 Bump lodash from 4.17.15 to 4.17.19 (#174)
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-01-20 11:26:01 -05:00
68fafecfa4 refactor: use core.info instead of console.log (#185) 2021-01-20 10:28:35 -05:00
c46424eee2 Merge pull request #219 from actions/v-malob/update-readme-v2
Update readme before releasing actions/setup-node V2
2020-12-16 12:47:21 +03:00
10 changed files with 145 additions and 42 deletions

13
.github/tsc.json vendored
View File

@ -4,14 +4,15 @@
"owner": "tsc", "owner": "tsc",
"pattern": [ "pattern": [
{ {
"regexp": "^(?:\\s+\\d+\\>)?([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\)\\s*:\\s+(error|warning|info)\\s+(\\w{1,2}\\d+)\\s*:\\s*(.*)$", "regexp": "^([^\\s].*)[\\(:](\\d+)[,:](\\d+)(?:\\):\\s+|\\s+-\\s+)(error|warning|info)\\s+TS(\\d+)\\s*:\\s*(.*)$",
"file": 1, "file": 1,
"location": 2, "line": 2,
"severity": 3, "column": 3,
"code": 4, "severity": 4,
"message": 5 "code": 5,
"message": 6
} }
] ]
} }
] ]
} }

View File

@ -13,10 +13,10 @@ on:
jobs: jobs:
build: build:
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.os }}
strategy: strategy:
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macos-latest] os: [ubuntu-latest, windows-latest, macos-latest]
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Setup node 12 - name: Setup node 12

View File

@ -13,11 +13,11 @@ on:
jobs: jobs:
local-cache: local-cache:
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.os }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macos-latest] os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [10, 12, 14] node-version: [10, 12, 14]
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
@ -30,11 +30,11 @@ jobs:
shell: bash shell: bash
manifest: manifest:
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.os }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macos-latest] os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [10.15, 12.16.0, 14.2.0] node-version: [10.15, 12.16.0, 14.2.0]
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
@ -47,11 +47,11 @@ jobs:
shell: bash shell: bash
check-latest: check-latest:
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.os }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macos-latest] os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [10, 11, 12, 14] node-version: [10, 11, 12, 14]
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
@ -65,11 +65,11 @@ jobs:
shell: bash shell: bash
node-dist: node-dist:
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.os }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macos-latest] os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [11, 13] node-version: [11, 13]
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
@ -82,11 +82,11 @@ jobs:
shell: bash shell: bash
old-versions: old-versions:
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.os }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macos-latest] os: [ubuntu-latest, windows-latest, macos-latest]
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
# test old versions which didn't have npm and layout different # test old versions which didn't have npm and layout different

View File

@ -19,12 +19,12 @@ steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/setup-node@v2 - uses: actions/setup-node@v2
with: with:
node-version: '12' node-version: '14'
``` ```
It 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. It will pull LTS versions from `main` branch of [node-versions](https://github.com/actions/node-versions/blob/main/versions-manifest.json) repository and on miss or failure, it will fall back to the previous behavior of download directly from [node dist](https://nodejs.org/dist/). 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/).
The `node-version` input is optional. If not supplied, node which is in your PATH will be used. However, this action will still register problem matchers and support auth features. So setting up the node environment is still a valid scenario without downloading and caching versions. The `node-version` input is optional. If not supplied, the node version that is PATH will be used. However, this action will still register problem matchers and support auth features. So setting up the node environment is still a valid scenario without downloading and caching versions.
# Usage # Usage
@ -36,20 +36,25 @@ steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/setup-node@v2 - uses: actions/setup-node@v2
with: with:
node-version: '12' node-version: '14'
- run: npm install - run: npm install
- run: npm test - run: npm test
``` ```
Check latest version: Check latest version:
> In basic example, without `check-latest` flag, the action tries to resolve version from local cache firstly and download only if it is not found. Local cache on image is updated with a couple of weeks latency.
`check-latest` flag forces the action to check if the cached version is the latest one. It reduces latency significantly but it is much more likely to incur version downloading. In the basic example above, the `check-latest` flag defaults to `false`. When set to `false`, the action tries to first resolve a version of node from the local cache. For information regarding locally cached versions of Node on GitHub hosted runners, check out [GitHub Actions Virtual Environments](https://github.com/actions/virtual-environments). The local version of Node in cache gets updated every couple of weeks. If unable to find a specific version in the cache, the action will then attempt to download a version of Node. Use the default or set `check-latest` to `false` if you prefer stability and if you want to ensure a specific version of Node is always used.
If `check-latest` is set to `true`, the action first checks if the cached version is the latest one. If the locally cached version is not the most up-to-date, a version of Node will then be downloaded. Set `check-latest` to `true` it you want the most up-to-date version of Node to always be used.
> Setting `check-latest` to `true` has performance implications as downloading versions of Node is slower than using cached versions
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/setup-node@v2 - uses: actions/setup-node@v2
with: with:
node-version: '12' node-version: '14'
check-latest: true check-latest: true
- run: npm install - run: npm install
- run: npm test - run: npm test
@ -62,7 +67,7 @@ jobs:
runs-on: ubuntu-16.04 runs-on: ubuntu-16.04
strategy: strategy:
matrix: matrix:
node: [ '10', '12' ] node: [ '12', '14' ]
name: Node ${{ matrix.node }} sample name: Node ${{ matrix.node }} sample
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
@ -88,7 +93,7 @@ jobs:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/setup-node@v2 - uses: actions/setup-node@v2
with: with:
node-version: '12' node-version: '14'
architecture: 'x64' # optional, x64 or x86. If not specified, x64 will be used by default architecture: 'x64' # optional, x64 or x86. If not specified, x64 will be used by default
- run: npm install - run: npm install
- run: npm test - run: npm test

View File

@ -8,15 +8,10 @@ import path from 'path';
import * as main from '../src/main'; import * as main from '../src/main';
import * as im from '../src/installer'; import * as im from '../src/installer';
import * as auth from '../src/authutil'; import * as auth from '../src/authutil';
import {context} from '@actions/github';
let nodeTestManifest = require('./data/versions-manifest.json'); let nodeTestManifest = require('./data/versions-manifest.json');
let nodeTestDist = require('./data/node-dist-index.json'); let nodeTestDist = require('./data/node-dist-index.json');
// let matchers = require('../matchers.json');
// let matcherPattern = matchers.problemMatcher[0].pattern[0];
// let matcherRegExp = new RegExp(matcherPattern.regexp);
describe('setup-node', () => { describe('setup-node', () => {
let inputs = {} as any; let inputs = {} as any;
let os = {} as any; let os = {} as any;

View File

@ -0,0 +1,43 @@
describe('problem matcher tests', () => {
it('tsc: matches TypeScript "pretty" error message', () => {
const [
{
pattern: [{regexp}]
}
] = require('../.github/tsc.json').problemMatcher;
const exampleErrorMessage =
"lib/index.js:23:42 - error TS2345: Argument of type 'A' is not assignable to parameter of type 'B'.";
const match = exampleErrorMessage.match(new RegExp(regexp));
expect(match).not.toBeNull();
expect(match![1]).toEqual('lib/index.js');
expect(match![2]).toEqual('23');
expect(match![3]).toEqual('42');
expect(match![4]).toEqual('error');
expect(match![5]).toEqual('2345');
expect(match![6]).toEqual(
"Argument of type 'A' is not assignable to parameter of type 'B'."
);
});
it('tsc: matches TypeScript error message from log file', () => {
const [
{
pattern: [{regexp}]
}
] = require('../.github/tsc.json').problemMatcher;
const exampleErrorMessage =
"lib/index.js(23,42): error TS2345: Argument of type 'A' is not assignable to parameter of type 'B'.";
const match = exampleErrorMessage.match(new RegExp(regexp));
expect(match).not.toBeNull();
expect(match![1]).toEqual('lib/index.js');
expect(match![2]).toEqual('23');
expect(match![3]).toEqual('42');
expect(match![4]).toEqual('error');
expect(match![5]).toEqual('2345');
expect(match![6]).toEqual(
"Argument of type 'A' is not assignable to parameter of type 'B'."
);
});
});

6
dist/index.js vendored
View File

@ -4728,9 +4728,9 @@ function run() {
auth.configAuthentication(registryUrl, alwaysAuth); auth.configAuthentication(registryUrl, alwaysAuth);
} }
const matchersPath = path.join(__dirname, '..', '.github'); const matchersPath = path.join(__dirname, '..', '.github');
console.log(`##[add-matcher]${path.join(matchersPath, 'tsc.json')}`); core.info(`##[add-matcher]${path.join(matchersPath, 'tsc.json')}`);
console.log(`##[add-matcher]${path.join(matchersPath, 'eslint-stylish.json')}`); core.info(`##[add-matcher]${path.join(matchersPath, 'eslint-stylish.json')}`);
console.log(`##[add-matcher]${path.join(matchersPath, 'eslint-compact.json')}`); core.info(`##[add-matcher]${path.join(matchersPath, 'eslint-compact.json')}`);
} }
catch (error) { catch (error) {
core.setFailed(error.message); core.setFailed(error.message);

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).

6
package-lock.json generated
View File

@ -6336,9 +6336,9 @@
} }
}, },
"lodash": { "lodash": {
"version": "4.17.15", "version": "4.17.19",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz",
"integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==",
"dev": true "dev": true
}, },
"lodash.get": { "lodash.get": {

View File

@ -46,11 +46,11 @@ export async function run() {
} }
const matchersPath = path.join(__dirname, '..', '.github'); const matchersPath = path.join(__dirname, '..', '.github');
console.log(`##[add-matcher]${path.join(matchersPath, 'tsc.json')}`); core.info(`##[add-matcher]${path.join(matchersPath, 'tsc.json')}`);
console.log( core.info(
`##[add-matcher]${path.join(matchersPath, 'eslint-stylish.json')}` `##[add-matcher]${path.join(matchersPath, 'eslint-stylish.json')}`
); );
console.log( core.info(
`##[add-matcher]${path.join(matchersPath, 'eslint-compact.json')}` `##[add-matcher]${path.join(matchersPath, 'eslint-compact.json')}`
); );
} catch (error) { } catch (error) {