Skip to content

Commit 1db1d57

Browse files
committed
Do not include node version
1 parent e8f15a5 commit 1db1d57

File tree

6 files changed

+76
-136
lines changed

6 files changed

+76
-136
lines changed

dist/cache-save/index.js

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -60578,7 +60578,7 @@ const getCacheDirectories = (packageManagerInfo, cacheDependencyPath) => __await
6057860578
});
6057960579
exports.getCacheDirectories = getCacheDirectories;
6058060580
/**
60581-
* Utility function check if the directory is a yarn project configured to manage
60581+
* A function to check if the directory is a yarn project configured to manage
6058260582
* obsolete dependencies in the local cache
6058360583
* @param directory - a path to the folder
6058460584
* @return - true if the directory's project is yarn managed
@@ -60599,18 +60599,11 @@ const isCacheManagedByYarn3 = (directory) => __awaiter(void 0, void 0, void 0, f
6059960599
return enableGlobalCache === 'false';
6060060600
});
6060160601
/**
60602-
* Memoization to avoid expensive walking through the directories tree
60603-
*/
60604-
let hasYarn3ManagedCacheMemoized = null;
60605-
/**
60606-
* Main function to report either the repo contains at least one Yarn managed directory
60602+
* A function to report either the repo contains at least one Yarn managed directory
6060760603
* @param packageManagerInfo - used to make sure current package manager is yarn
60608-
* @return - true if there's at least one Yarn managed directory in the report
60604+
* @return - true if there's at least one Yarn managed directory in the repo
6060960605
*/
6061060606
const repoHasYarn3ManagedCache = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () {
60611-
if (hasYarn3ManagedCacheMemoized !== null)
60612-
return hasYarn3ManagedCacheMemoized;
60613-
hasYarn3ManagedCacheMemoized = false;
6061460607
if (packageManagerInfo.name !== 'yarn')
6061560608
return false;
6061660609
const cacheDependencyPath = core.getInput('cache-dependency-path');
@@ -60619,11 +60612,10 @@ const repoHasYarn3ManagedCache = (packageManagerInfo) => __awaiter(void 0, void
6061960612
: [''];
6062060613
for (const dir of yarnDirs.length === 0 ? [''] : yarnDirs) {
6062160614
if (yield isCacheManagedByYarn3(dir)) {
60622-
hasYarn3ManagedCacheMemoized = true;
60623-
break;
60615+
return true;
6062460616
}
6062560617
}
60626-
return hasYarn3ManagedCacheMemoized;
60618+
return false;
6062760619
});
6062860620
exports.repoHasYarn3ManagedCache = repoHasYarn3ManagedCache;
6062960621
function isGhes() {
@@ -60706,15 +60698,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
6070660698
step((generator = generator.apply(thisArg, _arguments || [])).next());
6070760699
});
6070860700
};
60709-
var __importDefault = (this && this.__importDefault) || function (mod) {
60710-
return (mod && mod.__esModule) ? mod : { "default": mod };
60711-
};
6071260701
Object.defineProperty(exports, "__esModule", ({ value: true }));
60713-
exports.resolveVersionInput = exports.unique = exports.printEnvDetailsAndSetOutput = exports.parseNodeVersionFile = void 0;
60702+
exports.unique = exports.printEnvDetailsAndSetOutput = exports.parseNodeVersionFile = void 0;
6071460703
const core = __importStar(__nccwpck_require__(2186));
6071560704
const exec = __importStar(__nccwpck_require__(1514));
60716-
const path_1 = __importDefault(__nccwpck_require__(1017));
60717-
const fs_1 = __importDefault(__nccwpck_require__(7147));
6071860705
function parseNodeVersionFile(contents) {
6071960706
var _a, _b, _c;
6072060707
let nodeVersion;
@@ -60784,26 +60771,6 @@ const unique = () => {
6078460771
};
6078560772
};
6078660773
exports.unique = unique;
60787-
function resolveVersionInput() {
60788-
let version = core.getInput('node-version');
60789-
const versionFileInput = core.getInput('node-version-file');
60790-
if (version && versionFileInput) {
60791-
core.warning('Both node-version and node-version-file inputs are specified, only node-version will be used');
60792-
}
60793-
if (version) {
60794-
return version;
60795-
}
60796-
if (versionFileInput) {
60797-
const versionFilePath = path_1.default.join(process.env.GITHUB_WORKSPACE, versionFileInput);
60798-
if (!fs_1.default.existsSync(versionFilePath)) {
60799-
throw new Error(`The specified node version file at: ${versionFilePath} does not exist`);
60800-
}
60801-
version = parseNodeVersionFile(fs_1.default.readFileSync(versionFilePath, 'utf8'));
60802-
core.info(`Resolved ${versionFileInput} as ${version}`);
60803-
}
60804-
return version;
60805-
}
60806-
exports.resolveVersionInput = resolveVersionInput;
6080760774

6080860775

6080960776
/***/ }),

dist/setup/index.js

Lines changed: 28 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -71138,14 +71138,12 @@ const path_1 = __importDefault(__nccwpck_require__(1017));
7113871138
const fs_1 = __importDefault(__nccwpck_require__(7147));
7113971139
const constants_1 = __nccwpck_require__(9042);
7114071140
const cache_utils_1 = __nccwpck_require__(1678);
71141-
const util_1 = __nccwpck_require__(2629);
7114271141
const restoreCache = (packageManager, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
7114371142
const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager);
7114471143
if (!packageManagerInfo) {
7114571144
throw new Error(`Caching for '${packageManager}' is not supported`);
7114671145
}
7114771146
const platform = process.env.RUNNER_OS;
71148-
const nodeVersion = util_1.resolveVersionInput();
7114971147
const cachePaths = yield cache_utils_1.getCacheDirectories(packageManagerInfo, cacheDependencyPath);
7115071148
core.saveState(constants_1.State.CachePaths, cachePaths);
7115171149
const lockFilePath = cacheDependencyPath
@@ -71155,7 +71153,7 @@ const restoreCache = (packageManager, cacheDependencyPath) => __awaiter(void 0,
7115571153
if (!fileHash) {
7115671154
throw new Error('Some specified paths were not resolved, unable to cache dependencies.');
7115771155
}
71158-
const keyPrefix = `node-cache-${platform}-${packageManager}-v2-${nodeVersion}`;
71156+
const keyPrefix = `node-cache-${platform}-${packageManager}`;
7115971157
const primaryKey = `${keyPrefix}-${fileHash}`;
7116071158
core.debug(`primary key is ${primaryKey}`);
7116171159
core.saveState(constants_1.State.CachePrimaryKey, primaryKey);
@@ -71366,7 +71364,7 @@ const getCacheDirectories = (packageManagerInfo, cacheDependencyPath) => __await
7136671364
});
7136771365
exports.getCacheDirectories = getCacheDirectories;
7136871366
/**
71369-
* Utility function check if the directory is a yarn project configured to manage
71367+
* A function to check if the directory is a yarn project configured to manage
7137071368
* obsolete dependencies in the local cache
7137171369
* @param directory - a path to the folder
7137271370
* @return - true if the directory's project is yarn managed
@@ -71387,18 +71385,11 @@ const isCacheManagedByYarn3 = (directory) => __awaiter(void 0, void 0, void 0, f
7138771385
return enableGlobalCache === 'false';
7138871386
});
7138971387
/**
71390-
* Memoization to avoid expensive walking through the directories tree
71391-
*/
71392-
let hasYarn3ManagedCacheMemoized = null;
71393-
/**
71394-
* Main function to report either the repo contains at least one Yarn managed directory
71388+
* A function to report either the repo contains at least one Yarn managed directory
7139571389
* @param packageManagerInfo - used to make sure current package manager is yarn
71396-
* @return - true if there's at least one Yarn managed directory in the report
71390+
* @return - true if there's at least one Yarn managed directory in the repo
7139771391
*/
7139871392
const repoHasYarn3ManagedCache = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () {
71399-
if (hasYarn3ManagedCacheMemoized !== null)
71400-
return hasYarn3ManagedCacheMemoized;
71401-
hasYarn3ManagedCacheMemoized = false;
7140271393
if (packageManagerInfo.name !== 'yarn')
7140371394
return false;
7140471395
const cacheDependencyPath = core.getInput('cache-dependency-path');
@@ -71407,11 +71398,10 @@ const repoHasYarn3ManagedCache = (packageManagerInfo) => __awaiter(void 0, void
7140771398
: [''];
7140871399
for (const dir of yarnDirs.length === 0 ? [''] : yarnDirs) {
7140971400
if (yield isCacheManagedByYarn3(dir)) {
71410-
hasYarn3ManagedCacheMemoized = true;
71411-
break;
71401+
return true;
7141271402
}
7141371403
}
71414-
return hasYarn3ManagedCacheMemoized;
71404+
return false;
7141571405
});
7141671406
exports.repoHasYarn3ManagedCache = repoHasYarn3ManagedCache;
7141771407
function isGhes() {
@@ -72171,6 +72161,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
7217172161
Object.defineProperty(exports, "__esModule", ({ value: true }));
7217272162
exports.run = void 0;
7217372163
const core = __importStar(__nccwpck_require__(2186));
72164+
const fs_1 = __importDefault(__nccwpck_require__(7147));
7217472165
const os_1 = __importDefault(__nccwpck_require__(2037));
7217572166
const auth = __importStar(__nccwpck_require__(7573));
7217672167
const path = __importStar(__nccwpck_require__(1017));
@@ -72185,7 +72176,7 @@ function run() {
7218572176
// Version is optional. If supplied, install / use from the tool cache
7218672177
// If not supplied then task is still used to setup proxy, auth, etc...
7218772178
//
72188-
const version = util_1.resolveVersionInput();
72179+
const version = resolveVersionInput();
7218972180
let arch = core.getInput('architecture');
7219072181
const cache = core.getInput('cache');
7219172182
// if architecture supplied but node-version is not
@@ -72232,6 +72223,25 @@ function run() {
7223272223
});
7223372224
}
7223472225
exports.run = run;
72226+
function resolveVersionInput() {
72227+
let version = core.getInput('node-version');
72228+
const versionFileInput = core.getInput('node-version-file');
72229+
if (version && versionFileInput) {
72230+
core.warning('Both node-version and node-version-file inputs are specified, only node-version will be used');
72231+
}
72232+
if (version) {
72233+
return version;
72234+
}
72235+
if (versionFileInput) {
72236+
const versionFilePath = path.join(process.env.GITHUB_WORKSPACE, versionFileInput);
72237+
if (!fs_1.default.existsSync(versionFilePath)) {
72238+
throw new Error(`The specified node version file at: ${versionFilePath} does not exist`);
72239+
}
72240+
version = util_1.parseNodeVersionFile(fs_1.default.readFileSync(versionFilePath, 'utf8'));
72241+
core.info(`Resolved ${versionFileInput} as ${version}`);
72242+
}
72243+
return version;
72244+
}
7223572245

7223672246

7223772247
/***/ }),
@@ -72269,15 +72279,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7226972279
step((generator = generator.apply(thisArg, _arguments || [])).next());
7227072280
});
7227172281
};
72272-
var __importDefault = (this && this.__importDefault) || function (mod) {
72273-
return (mod && mod.__esModule) ? mod : { "default": mod };
72274-
};
7227572282
Object.defineProperty(exports, "__esModule", ({ value: true }));
72276-
exports.resolveVersionInput = exports.unique = exports.printEnvDetailsAndSetOutput = exports.parseNodeVersionFile = void 0;
72283+
exports.unique = exports.printEnvDetailsAndSetOutput = exports.parseNodeVersionFile = void 0;
7227772284
const core = __importStar(__nccwpck_require__(2186));
7227872285
const exec = __importStar(__nccwpck_require__(1514));
72279-
const path_1 = __importDefault(__nccwpck_require__(1017));
72280-
const fs_1 = __importDefault(__nccwpck_require__(7147));
7228172286
function parseNodeVersionFile(contents) {
7228272287
var _a, _b, _c;
7228372288
let nodeVersion;
@@ -72347,26 +72352,6 @@ const unique = () => {
7234772352
};
7234872353
};
7234972354
exports.unique = unique;
72350-
function resolveVersionInput() {
72351-
let version = core.getInput('node-version');
72352-
const versionFileInput = core.getInput('node-version-file');
72353-
if (version && versionFileInput) {
72354-
core.warning('Both node-version and node-version-file inputs are specified, only node-version will be used');
72355-
}
72356-
if (version) {
72357-
return version;
72358-
}
72359-
if (versionFileInput) {
72360-
const versionFilePath = path_1.default.join(process.env.GITHUB_WORKSPACE, versionFileInput);
72361-
if (!fs_1.default.existsSync(versionFilePath)) {
72362-
throw new Error(`The specified node version file at: ${versionFilePath} does not exist`);
72363-
}
72364-
version = parseNodeVersionFile(fs_1.default.readFileSync(versionFilePath, 'utf8'));
72365-
core.info(`Resolved ${versionFileInput} as ${version}`);
72366-
}
72367-
return version;
72368-
}
72369-
exports.resolveVersionInput = resolveVersionInput;
7237072355

7237172356

7237272357
/***/ }),

src/cache-restore.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
repoHasYarn3ManagedCache,
1212
PackageManagerInfo
1313
} from './cache-utils';
14-
import {resolveVersionInput} from './util';
1514

1615
export const restoreCache = async (
1716
packageManager: string,
@@ -22,7 +21,6 @@ export const restoreCache = async (
2221
throw new Error(`Caching for '${packageManager}' is not supported`);
2322
}
2423
const platform = process.env.RUNNER_OS;
25-
const nodeVersion = resolveVersionInput();
2624

2725
const cachePaths = await getCacheDirectories(
2826
packageManagerInfo,
@@ -40,7 +38,7 @@ export const restoreCache = async (
4038
);
4139
}
4240

43-
const keyPrefix = `node-cache-${platform}-${packageManager}-v2-${nodeVersion}`;
41+
const keyPrefix = `node-cache-${platform}-${packageManager}`;
4442
const primaryKey = `${keyPrefix}-${fileHash}`;
4543
core.debug(`primary key is ${primaryKey}`);
4644

src/cache-utils.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ export const getCacheDirectories = async (
217217
};
218218

219219
/**
220-
* Utility function check if the directory is a yarn project configured to manage
220+
* A function to check if the directory is a yarn project configured to manage
221221
* obsolete dependencies in the local cache
222222
* @param directory - a path to the folder
223223
* @return - true if the directory's project is yarn managed
@@ -244,22 +244,13 @@ const isCacheManagedByYarn3 = async (directory: string): Promise<boolean> => {
244244
};
245245

246246
/**
247-
* Memoization to avoid expensive walking through the directories tree
248-
*/
249-
let hasYarn3ManagedCacheMemoized: boolean | null = null;
250-
/**
251-
* Main function to report either the repo contains at least one Yarn managed directory
247+
* A function to report either the repo contains at least one Yarn managed directory
252248
* @param packageManagerInfo - used to make sure current package manager is yarn
253-
* @return - true if there's at least one Yarn managed directory in the report
249+
* @return - true if there's at least one Yarn managed directory in the repo
254250
*/
255251
export const repoHasYarn3ManagedCache = async (
256252
packageManagerInfo: PackageManagerInfo
257253
): Promise<boolean> => {
258-
if (hasYarn3ManagedCacheMemoized !== null)
259-
return hasYarn3ManagedCacheMemoized;
260-
261-
hasYarn3ManagedCacheMemoized = false;
262-
263254
if (packageManagerInfo.name !== 'yarn') return false;
264255

265256
const cacheDependencyPath = core.getInput('cache-dependency-path');
@@ -270,12 +261,11 @@ export const repoHasYarn3ManagedCache = async (
270261

271262
for (const dir of yarnDirs.length === 0 ? [''] : yarnDirs) {
272263
if (await isCacheManagedByYarn3(dir)) {
273-
hasYarn3ManagedCacheMemoized = true;
274-
break;
264+
return true;
275265
}
276266
}
277267

278-
return hasYarn3ManagedCacheMemoized;
268+
return false;
279269
};
280270

281271
export function isGhes(): boolean {

src/main.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import * as core from '@actions/core';
22

3+
import fs from 'fs';
34
import os from 'os';
45

56
import * as auth from './authutil';
67
import * as path from 'path';
78
import {restoreCache} from './cache-restore';
89
import {isCacheFeatureAvailable} from './cache-utils';
910
import {getNodejsDistribution} from './distributions/installer-factory';
10-
import {printEnvDetailsAndSetOutput, resolveVersionInput} from './util';
11+
import {parseNodeVersionFile, printEnvDetailsAndSetOutput} from './util';
1112

1213
export async function run() {
1314
try {
@@ -75,3 +76,37 @@ export async function run() {
7576
core.setFailed(err.message);
7677
}
7778
}
79+
80+
function resolveVersionInput(): string {
81+
let version = core.getInput('node-version');
82+
const versionFileInput = core.getInput('node-version-file');
83+
84+
if (version && versionFileInput) {
85+
core.warning(
86+
'Both node-version and node-version-file inputs are specified, only node-version will be used'
87+
);
88+
}
89+
90+
if (version) {
91+
return version;
92+
}
93+
94+
if (versionFileInput) {
95+
const versionFilePath = path.join(
96+
process.env.GITHUB_WORKSPACE!,
97+
versionFileInput
98+
);
99+
100+
if (!fs.existsSync(versionFilePath)) {
101+
throw new Error(
102+
`The specified node version file at: ${versionFilePath} does not exist`
103+
);
104+
}
105+
106+
version = parseNodeVersionFile(fs.readFileSync(versionFilePath, 'utf8'));
107+
108+
core.info(`Resolved ${versionFileInput} as ${version}`);
109+
}
110+
111+
return version;
112+
}

0 commit comments

Comments
 (0)