Skip to content

Commit 9bb7038

Browse files
committed
Initial Import
0 parents  commit 9bb7038

File tree

244 files changed

+22913
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

244 files changed

+22913
-0
lines changed

.github/eslint-compact.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "eslint-compact",
5+
"pattern": [
6+
{
7+
"regexp": "^(.+):\\sline\\s(\\d+),\\scol\\s(\\d+),\\s(Error|Warning|Info)\\s-\\s(.+)\\s\\((.+)\\)$",
8+
"file": 1,
9+
"line": 2,
10+
"column": 3,
11+
"severity": 4,
12+
"message": 5,
13+
"code": 6
14+
}
15+
]
16+
}
17+
]
18+
}

.github/eslint-stylish.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "eslint-stylish",
5+
"pattern": [
6+
{
7+
"regexp": "^([^\\s].*)$",
8+
"file": 1
9+
},
10+
{
11+
"regexp": "^\\s+(\\d+):(\\d+)\\s+(error|warning|info)\\s+(.*)\\s\\s+(.*)$",
12+
"line": 1,
13+
"column": 2,
14+
"severity": 3,
15+
"message": 4,
16+
"code": 5,
17+
"loop": true
18+
}
19+
]
20+
}
21+
]
22+
}

.github/tsc.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "tsc",
5+
"pattern": [
6+
{
7+
"regexp": "^(?:\\s+\\d+\\>)?([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\)\\s*:\\s+(error|warning|info)\\s+(\\w{1,2}\\d+)\\s*:\\s*(.*)$",
8+
"file": 1,
9+
"location": 2,
10+
"severity": 3,
11+
"code": 4,
12+
"message": 5
13+
}
14+
]
15+
}
16+
]
17+
}

.github/workflows/workflow.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Main workflow
2+
on: [push]
3+
jobs:
4+
run:
5+
name: Run
6+
runs-on: ${{ matrix.operating-system }}
7+
strategy:
8+
matrix:
9+
operating-system: [ubuntu-latest, windows-latest]
10+
steps:
11+
- uses: actions/checkout@master
12+
13+
- name: Set Node.js 10.x
14+
uses: actions/setup-node@master
15+
with:
16+
version: 10.x
17+
18+
- name: npm install
19+
run: npm install
20+
21+
- name: Lint
22+
run: npm run format-check
23+
24+
- name: npm test
25+
run: npm test

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
!node_modules/
2+
__tests__/runner/*

.prettierrc.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"printWidth": 80,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": true,
6+
"singleQuote": true,
7+
"trailingComma": "none",
8+
"bracketSpacing": false,
9+
"arrowParens": "avoid",
10+
"parser": "typescript"
11+
}

LICENSE

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2018 GitHub, Inc. and contributors
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
THE SOFTWARE.

README.md

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# setup-node
2+
3+
This action sets by node environment for use in actions by:
4+
5+
- optionally downloading and caching a version of node - npm by version spec and add to PATH
6+
- registering problem matchers for error output
7+
8+
# Usage
9+
10+
See [action.yml](action.yml)
11+
12+
Basic:
13+
```yaml
14+
steps:
15+
- uses: actions/checkout@master
16+
- uses: actions/setup-node@v1
17+
with:
18+
version: '10.x'
19+
- run: npm install
20+
- run: npm test
21+
```
22+
23+
Matrix Testing:
24+
```yaml
25+
jobs:
26+
build:
27+
runs-on: ubuntu-16.04
28+
strategy:
29+
matrix:
30+
node: [ '10', '8' ]
31+
name: Node ${{ matrix.node }} sample
32+
steps:
33+
- uses: actions/checkout@master
34+
- name: Setup node
35+
uses: actions/setup-node@v1
36+
with:
37+
version: ${{ matrix.node }}
38+
- run: npm install
39+
- run: npm test
40+
```
41+
42+
# License
43+
44+
The scripts and documentation in this project are released under the [MIT License](LICENSE)
45+
46+
# Contributions
47+
48+
Contributions are welcome! See [Contributor's Guide](docs/contributors.md)

__tests__/installer.test.ts

+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
import io = require('@actions/io');
2+
import fs = require('fs');
3+
import os = require('os');
4+
import path = require('path');
5+
6+
const toolDir = path.join(
7+
process.cwd(),
8+
'runner',
9+
path.join(
10+
Math.random()
11+
.toString(36)
12+
.substring(7)
13+
),
14+
'tools'
15+
);
16+
const tempDir = path.join(
17+
process.cwd(),
18+
'runner',
19+
path.join(
20+
Math.random()
21+
.toString(36)
22+
.substring(7)
23+
),
24+
'temp'
25+
);
26+
27+
process.env['RUNNER_TOOL_CACHE'] = toolDir;
28+
process.env['RUNNER_TEMP'] = tempDir;
29+
import * as installer from '../src/installer';
30+
31+
const IS_WINDOWS = process.platform === 'win32';
32+
33+
describe('installer tests', () => {
34+
beforeAll(async () => {
35+
await io.rmRF(toolDir);
36+
await io.rmRF(tempDir);
37+
}, 100000);
38+
39+
afterAll(async () => {
40+
try {
41+
await io.rmRF(toolDir);
42+
await io.rmRF(tempDir);
43+
} catch {
44+
console.log('Failed to remove test directories');
45+
}
46+
}, 100000);
47+
48+
it('Acquires version of node if no matching version is installed', async () => {
49+
await installer.getNode('10.16.0');
50+
const nodeDir = path.join(toolDir, 'node', '10.16.0', os.arch());
51+
52+
expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true);
53+
if (IS_WINDOWS) {
54+
expect(fs.existsSync(path.join(nodeDir, 'node.exe'))).toBe(true);
55+
} else {
56+
expect(fs.existsSync(path.join(nodeDir, 'bin', 'node'))).toBe(true);
57+
}
58+
}, 100000);
59+
60+
if (IS_WINDOWS) {
61+
it('Falls back to backup location if first one doesnt contain correct version', async () => {
62+
await installer.getNode('5.10.1');
63+
const nodeDir = path.join(toolDir, 'node', '5.10.1', os.arch());
64+
65+
expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true);
66+
expect(fs.existsSync(path.join(nodeDir, 'node.exe'))).toBe(true);
67+
}, 100000);
68+
69+
it('Falls back to third location if second one doesnt contain correct version', async () => {
70+
await installer.getNode('0.12.18');
71+
const nodeDir = path.join(toolDir, 'node', '0.12.18', os.arch());
72+
73+
expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true);
74+
expect(fs.existsSync(path.join(nodeDir, 'node.exe'))).toBe(true);
75+
}, 100000);
76+
}
77+
78+
it('Throws if no location contains correct node version', async () => {
79+
let thrown = false;
80+
try {
81+
await installer.getNode('1000');
82+
} catch {
83+
thrown = true;
84+
}
85+
expect(thrown).toBe(true);
86+
});
87+
88+
it('Acquires version of node with long paths', async () => {
89+
const toolpath = await installer.getNode('8.8.1');
90+
const nodeDir = path.join(toolDir, 'node', '8.8.1', os.arch());
91+
92+
expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true);
93+
if (IS_WINDOWS) {
94+
expect(fs.existsSync(path.join(nodeDir, 'node.exe'))).toBe(true);
95+
} else {
96+
expect(fs.existsSync(path.join(nodeDir, 'bin', 'node'))).toBe(true);
97+
}
98+
}, 100000);
99+
100+
it('Uses version of node installed in cache', async () => {
101+
const nodeDir: string = path.join(toolDir, 'node', '250.0.0', os.arch());
102+
await io.mkdirP(nodeDir);
103+
fs.writeFileSync(`${nodeDir}.complete`, 'hello');
104+
// This will throw if it doesn't find it in the cache (because no such version exists)
105+
await installer.getNode('250.0.0');
106+
return;
107+
});
108+
109+
it('Doesnt use version of node that was only partially installed in cache', async () => {
110+
const nodeDir: string = path.join(toolDir, 'node', '251.0.0', os.arch());
111+
await io.mkdirP(nodeDir);
112+
let thrown = false;
113+
try {
114+
// This will throw if it doesn't find it in the cache (because no such version exists)
115+
await installer.getNode('251.0.0');
116+
} catch {
117+
thrown = true;
118+
}
119+
expect(thrown).toBe(true);
120+
return;
121+
});
122+
123+
it('Resolves semantic versions of node installed in cache', async () => {
124+
const nodeDir: string = path.join(toolDir, 'node', '252.0.0', os.arch());
125+
await io.mkdirP(nodeDir);
126+
fs.writeFileSync(`${nodeDir}.complete`, 'hello');
127+
// These will throw if it doesn't find it in the cache (because no such version exists)
128+
await installer.getNode('252.0.0');
129+
await installer.getNode('252');
130+
await installer.getNode('252.0');
131+
});
132+
});

action.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: 'Setup Node.js for use with actions'
2+
description: 'Setup a Node.js environment and add it to the PATH, additionally providing proxy support'
3+
author: 'GitHub'
4+
inputs:
5+
version:
6+
description: 'Version Spec of the version to use. Examples: 10.x, 10.15.1, >=10.15.0, lts'
7+
default: '10.x'
8+
runs:
9+
using: 'node12'
10+
main: 'lib/setup-node.js'

docs/contributors.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Contributors
2+
3+
### Checkin
4+
5+
- Do checkin source (src)
6+
- Do checkin build output (lib)
7+
- Do checkin runtime node_modules
8+
- Do not checkin devDependency node_modules (husky can help see below)
9+
10+
### devDependencies
11+
12+
In order to handle correctly checking in node_modules without devDependencies, we run [Husky](https://github.com/typicode/husky) before each commit.
13+
This step ensures that formatting and checkin rules are followed and that devDependencies are excluded. To make sure Husky runs correctly, please use the following workflow:
14+
15+
```
16+
npm install # installs all devDependencies including Husky
17+
git add abc.ext # Add the files you've changed. This should include files in src, lib, and node_modules (see above)
18+
git commit -m "Informative commit message" # Commit. This will run Husky
19+
```
20+
21+
During the commit step, Husky will take care of formatting all files with [Prettier](https://github.com/prettier/prettier) as well as pruning out devDependencies using `npm prune --production`.
22+
It will also make sure these changes are appropriately included in your commit (no further work is needed)

externals/7zr.exe

507 KB
Binary file not shown.

jest.config.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
clearMocks: true,
3+
moduleFileExtensions: ['js', 'ts'],
4+
testEnvironment: 'node',
5+
testMatch: ['**/*.test.ts'],
6+
testRunner: 'jest-circus/runner',
7+
transform: {
8+
'^.+\\.ts$': 'ts-jest'
9+
},
10+
verbose: true
11+
}

0 commit comments

Comments
 (0)