mirror of
https://github.com/actions/setup-node.git
synced 2025-04-23 20:10:48 +00:00
removed unnessary test
* added fail-fast to strategy in versions.yml * refactored logic in main that was causing test to fail
This commit is contained in:
parent
7fb46efb66
commit
ec979d0561
4 changed files with 98 additions and 138 deletions
3
.github/workflows/versions.yml
vendored
3
.github/workflows/versions.yml
vendored
|
@ -81,6 +81,7 @@ jobs:
|
||||||
version-file:
|
version-file:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
steps:
|
steps:
|
||||||
|
@ -88,7 +89,7 @@ jobs:
|
||||||
- name: Setup node test
|
- name: Setup node test
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
node-version-file: '.nvmrc'
|
node-version-file: './.nvmrc'
|
||||||
node-dist:
|
node-dist:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
|
|
|
@ -575,7 +575,7 @@ describe('setup-node', () => {
|
||||||
it('Reads node-version-file if provided', async () => {
|
it('Reads node-version-file if provided', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const versionSpec = 'v12';
|
const versionSpec = 'v12';
|
||||||
const versionFile = '.immrc';
|
const versionFile = '.nvmrc';
|
||||||
const expectedVersionSpec = '12';
|
const expectedVersionSpec = '12';
|
||||||
|
|
||||||
inputs['node-version-file'] = versionFile;
|
inputs['node-version-file'] = versionFile;
|
||||||
|
@ -597,6 +597,7 @@ describe('setup-node', () => {
|
||||||
`Resolved ${versionFile} as ${expectedVersionSpec}`
|
`Resolved ${versionFile} as ${expectedVersionSpec}`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('LTS version', () => {
|
describe('LTS version', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
os.platform = 'linux';
|
os.platform = 'linux';
|
||||||
|
@ -815,46 +816,4 @@ describe('setup-node', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('node-version-file', () => {
|
|
||||||
let getVersionsFromDist: jest.SpyInstance;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
// @actions/core
|
|
||||||
console.log('::stop-commands::stoptoken'); // Disable executing of runner commands when running tests in actions
|
|
||||||
|
|
||||||
getVersionsFromDist = jest.spyOn(im, 'getVersionsFromDist');
|
|
||||||
|
|
||||||
// gets
|
|
||||||
getVersionsFromDist.mockImplementation(
|
|
||||||
() => <im.INodeVersion>nodeTestDist
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
jest.resetAllMocks();
|
|
||||||
jest.clearAllMocks();
|
|
||||||
//jest.restoreAllMocks();
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(async () => {
|
|
||||||
console.log('::stoptoken::'); // Re-enable executing of runner commands when running tests in actions
|
|
||||||
}, 100000);
|
|
||||||
|
|
||||||
//--------------------------------------------------
|
|
||||||
// Manifest find tests
|
|
||||||
//--------------------------------------------------
|
|
||||||
describe('parseNodeVersionFile', () => {
|
|
||||||
it('without `v` prefix', async () => {
|
|
||||||
// Arrange
|
|
||||||
const versionSpec = '12';
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const result = await im.parseNodeVersionFile(versionSpec);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(result).toBe(versionSpec);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
80
dist/setup/index.js
vendored
80
dist/setup/index.js
vendored
|
@ -6852,8 +6852,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const core = __importStar(__webpack_require__(470));
|
const core = __importStar(__webpack_require__(470));
|
||||||
const installer = __importStar(__webpack_require__(923));
|
const installer = __importStar(__webpack_require__(923));
|
||||||
const auth = __importStar(__webpack_require__(749));
|
|
||||||
const fs = __webpack_require__(747);
|
const fs = __webpack_require__(747);
|
||||||
|
const auth = __importStar(__webpack_require__(749));
|
||||||
const path = __importStar(__webpack_require__(622));
|
const path = __importStar(__webpack_require__(622));
|
||||||
const cache_restore_1 = __webpack_require__(409);
|
const cache_restore_1 = __webpack_require__(409);
|
||||||
const url_1 = __webpack_require__(835);
|
const url_1 = __webpack_require__(835);
|
||||||
|
@ -6868,48 +6868,48 @@ function run() {
|
||||||
let version = core.getInput('node-version');
|
let version = core.getInput('node-version');
|
||||||
if (!version) {
|
if (!version) {
|
||||||
version = core.getInput('version');
|
version = core.getInput('version');
|
||||||
}
|
if (!version) {
|
||||||
if (!version) {
|
const versionFile = core.getInput('node-version-file');
|
||||||
const versionFile = core.getInput('node-version-file');
|
if (!!versionFile) {
|
||||||
if (!!versionFile) {
|
const versionFilePath = path.join(__dirname, '..', versionFile);
|
||||||
const versionFilePath = path.join(__dirname, '..', versionFile);
|
version = yield installer.parseNodeVersionFile(fs.readFileSync(versionFilePath, 'utf8'));
|
||||||
version = yield installer.parseNodeVersionFile(fs.readFileSync(versionFilePath, 'utf8'));
|
core.info(`Resolved ${versionFile} as ${version}`);
|
||||||
core.info(`Resolved ${versionFile} as ${version}`);
|
|
||||||
}
|
|
||||||
let arch = core.getInput('architecture');
|
|
||||||
const cache = core.getInput('cache');
|
|
||||||
// if architecture supplied but node-version is not
|
|
||||||
// if we don't throw a warning, the already installed x64 node will be used which is not probably what user meant.
|
|
||||||
if (arch && !version) {
|
|
||||||
core.warning('`architecture` is provided but `node-version` is missing. In this configuration, the version/architecture of Node will not be changed. To fix this, provide `architecture` in combination with `node-version`');
|
|
||||||
}
|
|
||||||
if (!arch) {
|
|
||||||
arch = os.arch();
|
|
||||||
}
|
|
||||||
if (version) {
|
|
||||||
let token = core.getInput('token');
|
|
||||||
let auth = !token || isGhes() ? undefined : `token ${token}`;
|
|
||||||
let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
|
|
||||||
const checkLatest = (core.getInput('check-latest') || 'false').toUpperCase() === 'TRUE';
|
|
||||||
yield installer.getNode(version, stable, checkLatest, auth, arch);
|
|
||||||
}
|
|
||||||
const registryUrl = core.getInput('registry-url');
|
|
||||||
const alwaysAuth = core.getInput('always-auth');
|
|
||||||
if (registryUrl) {
|
|
||||||
auth.configAuthentication(registryUrl, alwaysAuth);
|
|
||||||
}
|
|
||||||
if (cache) {
|
|
||||||
if (isGhes()) {
|
|
||||||
throw new Error('Caching is not supported on GHES');
|
|
||||||
}
|
}
|
||||||
const cacheDependencyPath = core.getInput('cache-dependency-path');
|
|
||||||
yield cache_restore_1.restoreCache(cache, cacheDependencyPath);
|
|
||||||
}
|
}
|
||||||
const matchersPath = path.join(__dirname, '../..', '.github');
|
|
||||||
core.info(`##[add-matcher]${path.join(matchersPath, 'tsc.json')}`);
|
|
||||||
core.info(`##[add-matcher]${path.join(matchersPath, 'eslint-stylish.json')}`);
|
|
||||||
core.info(`##[add-matcher]${path.join(matchersPath, 'eslint-compact.json')}`);
|
|
||||||
}
|
}
|
||||||
|
let arch = core.getInput('architecture');
|
||||||
|
const cache = core.getInput('cache');
|
||||||
|
// if architecture supplied but node-version is not
|
||||||
|
// if we don't throw a warning, the already installed x64 node will be used which is not probably what user meant.
|
||||||
|
if (arch && !version) {
|
||||||
|
core.warning('`architecture` is provided but `node-version` is missing. In this configuration, the version/architecture of Node will not be changed. To fix this, provide `architecture` in combination with `node-version`');
|
||||||
|
}
|
||||||
|
if (!arch) {
|
||||||
|
arch = os.arch();
|
||||||
|
}
|
||||||
|
if (version) {
|
||||||
|
let token = core.getInput('token');
|
||||||
|
let auth = !token || isGhes() ? undefined : `token ${token}`;
|
||||||
|
let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
|
||||||
|
const checkLatest = (core.getInput('check-latest') || 'false').toUpperCase() === 'TRUE';
|
||||||
|
yield installer.getNode(version, stable, checkLatest, auth, arch);
|
||||||
|
}
|
||||||
|
const registryUrl = core.getInput('registry-url');
|
||||||
|
const alwaysAuth = core.getInput('always-auth');
|
||||||
|
if (registryUrl) {
|
||||||
|
auth.configAuthentication(registryUrl, alwaysAuth);
|
||||||
|
}
|
||||||
|
if (cache) {
|
||||||
|
if (isGhes()) {
|
||||||
|
throw new Error('Caching is not supported on GHES');
|
||||||
|
}
|
||||||
|
const cacheDependencyPath = core.getInput('cache-dependency-path');
|
||||||
|
yield cache_restore_1.restoreCache(cache, cacheDependencyPath);
|
||||||
|
}
|
||||||
|
const matchersPath = path.join(__dirname, '../..', '.github');
|
||||||
|
core.info(`##[add-matcher]${path.join(matchersPath, 'tsc.json')}`);
|
||||||
|
core.info(`##[add-matcher]${path.join(matchersPath, 'eslint-stylish.json')}`);
|
||||||
|
core.info(`##[add-matcher]${path.join(matchersPath, 'eslint-compact.json')}`);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
|
|
108
src/main.ts
108
src/main.ts
|
@ -1,7 +1,7 @@
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as installer from './installer';
|
import * as installer from './installer';
|
||||||
import * as auth from './authutil';
|
|
||||||
import fs = require('fs');
|
import fs = require('fs');
|
||||||
|
import * as auth from './authutil';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import {restoreCache} from './cache-restore';
|
import {restoreCache} from './cache-restore';
|
||||||
import {URL} from 'url';
|
import {URL} from 'url';
|
||||||
|
@ -16,66 +16,66 @@ export async function run() {
|
||||||
let version = core.getInput('node-version');
|
let version = core.getInput('node-version');
|
||||||
if (!version) {
|
if (!version) {
|
||||||
version = core.getInput('version');
|
version = core.getInput('version');
|
||||||
}
|
|
||||||
|
|
||||||
if (!version) {
|
if (!version) {
|
||||||
const versionFile = core.getInput('node-version-file');
|
const versionFile = core.getInput('node-version-file');
|
||||||
|
|
||||||
if (!!versionFile) {
|
if (!!versionFile) {
|
||||||
const versionFilePath = path.join(__dirname, '..', versionFile);
|
const versionFilePath = path.join(__dirname, '..', versionFile);
|
||||||
version = await installer.parseNodeVersionFile(
|
version = await installer.parseNodeVersionFile(
|
||||||
fs.readFileSync(versionFilePath, 'utf8')
|
fs.readFileSync(versionFilePath, 'utf8')
|
||||||
);
|
);
|
||||||
core.info(`Resolved ${versionFile} as ${version}`);
|
core.info(`Resolved ${versionFile} as ${version}`);
|
||||||
}
|
|
||||||
let arch = core.getInput('architecture');
|
|
||||||
const cache = core.getInput('cache');
|
|
||||||
|
|
||||||
// if architecture supplied but node-version is not
|
|
||||||
// if we don't throw a warning, the already installed x64 node will be used which is not probably what user meant.
|
|
||||||
if (arch && !version) {
|
|
||||||
core.warning(
|
|
||||||
'`architecture` is provided but `node-version` is missing. In this configuration, the version/architecture of Node will not be changed. To fix this, provide `architecture` in combination with `node-version`'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!arch) {
|
|
||||||
arch = os.arch();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (version) {
|
|
||||||
let token = core.getInput('token');
|
|
||||||
let auth = !token || isGhes() ? undefined : `token ${token}`;
|
|
||||||
let stable =
|
|
||||||
(core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
|
|
||||||
const checkLatest =
|
|
||||||
(core.getInput('check-latest') || 'false').toUpperCase() === 'TRUE';
|
|
||||||
await installer.getNode(version, stable, checkLatest, auth, arch);
|
|
||||||
}
|
|
||||||
|
|
||||||
const registryUrl: string = core.getInput('registry-url');
|
|
||||||
const alwaysAuth: string = core.getInput('always-auth');
|
|
||||||
if (registryUrl) {
|
|
||||||
auth.configAuthentication(registryUrl, alwaysAuth);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cache) {
|
|
||||||
if (isGhes()) {
|
|
||||||
throw new Error('Caching is not supported on GHES');
|
|
||||||
}
|
}
|
||||||
const cacheDependencyPath = core.getInput('cache-dependency-path');
|
|
||||||
await restoreCache(cache, cacheDependencyPath);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const matchersPath = path.join(__dirname, '../..', '.github');
|
let arch = core.getInput('architecture');
|
||||||
core.info(`##[add-matcher]${path.join(matchersPath, 'tsc.json')}`);
|
const cache = core.getInput('cache');
|
||||||
core.info(
|
|
||||||
`##[add-matcher]${path.join(matchersPath, 'eslint-stylish.json')}`
|
// if architecture supplied but node-version is not
|
||||||
);
|
// if we don't throw a warning, the already installed x64 node will be used which is not probably what user meant.
|
||||||
core.info(
|
if (arch && !version) {
|
||||||
`##[add-matcher]${path.join(matchersPath, 'eslint-compact.json')}`
|
core.warning(
|
||||||
|
'`architecture` is provided but `node-version` is missing. In this configuration, the version/architecture of Node will not be changed. To fix this, provide `architecture` in combination with `node-version`'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!arch) {
|
||||||
|
arch = os.arch();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (version) {
|
||||||
|
let token = core.getInput('token');
|
||||||
|
let auth = !token || isGhes() ? undefined : `token ${token}`;
|
||||||
|
let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
|
||||||
|
const checkLatest =
|
||||||
|
(core.getInput('check-latest') || 'false').toUpperCase() === 'TRUE';
|
||||||
|
await installer.getNode(version, stable, checkLatest, auth, arch);
|
||||||
|
}
|
||||||
|
|
||||||
|
const registryUrl: string = core.getInput('registry-url');
|
||||||
|
const alwaysAuth: string = core.getInput('always-auth');
|
||||||
|
if (registryUrl) {
|
||||||
|
auth.configAuthentication(registryUrl, alwaysAuth);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cache) {
|
||||||
|
if (isGhes()) {
|
||||||
|
throw new Error('Caching is not supported on GHES');
|
||||||
|
}
|
||||||
|
const cacheDependencyPath = core.getInput('cache-dependency-path');
|
||||||
|
await restoreCache(cache, cacheDependencyPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
const matchersPath = path.join(__dirname, '../..', '.github');
|
||||||
|
core.info(`##[add-matcher]${path.join(matchersPath, 'tsc.json')}`);
|
||||||
|
core.info(
|
||||||
|
`##[add-matcher]${path.join(matchersPath, 'eslint-stylish.json')}`
|
||||||
|
);
|
||||||
|
core.info(
|
||||||
|
`##[add-matcher]${path.join(matchersPath, 'eslint-compact.json')}`
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue