Skip to content

Commit a8106dc

Browse files
remove primary key field
1 parent cf8ada0 commit a8106dc

File tree

8 files changed

+106
-121
lines changed

8 files changed

+106
-121
lines changed

action.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ inputs:
2121
default: ${{ github.token }}
2222
cache:
2323
description: 'Used to specify supported package manager to cache in its default directory'
24-
key:
25-
description: 'primary key to restore and save modules'
2624
# TODO: add input to control forcing to pull from cloud or dist.
2725
# escape valve for someone having issues or needing the absolute latest which isn't cached yet
2826
# Deprecated option, do not use. Will not be supported after October 1, 2019

dist/saveCache/index.js

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5878,21 +5878,6 @@ module.exports = v1;
58785878
"use strict";
58795879

58805880
Object.defineProperty(exports, "__esModule", { value: true });
5881-
var Inputs;
5882-
(function (Inputs) {
5883-
Inputs["Cache"] = "cache";
5884-
Inputs["Key"] = "key";
5885-
Inputs["RestoreKeys"] = "restore-keys";
5886-
Inputs["NodeVersion"] = "node-version";
5887-
Inputs["Version"] = "version";
5888-
Inputs["Architecture"] = "architecture";
5889-
Inputs["Token"] = "token";
5890-
Inputs["Stable"] = "stable";
5891-
Inputs["CheckLatest"] = "check-latest";
5892-
Inputs["RegistryUrl"] = "registry-url";
5893-
Inputs["AlwaysAuth"] = "always-auth";
5894-
Inputs["Scope"] = "scope";
5895-
})(Inputs = exports.Inputs || (exports.Inputs = {}));
58965881
var LockType;
58975882
(function (LockType) {
58985883
LockType["Npm"] = "npm";
@@ -50335,7 +50320,7 @@ const constants_1 = __webpack_require__(196);
5033550320
const cache_utils_1 = __webpack_require__(452);
5033650321
function run() {
5033750322
return __awaiter(this, void 0, void 0, function* () {
50338-
const cacheLock = core.getInput(constants_1.Inputs.Cache);
50323+
const cacheLock = core.getInput('cache');
5033950324
try {
5034050325
yield cachePackages(cacheLock);
5034150326
}

dist/setup/index.js

Lines changed: 72 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -6567,30 +6567,7 @@ module.exports.default = macosRelease;
65676567
/* 121 */,
65686568
/* 122 */,
65696569
/* 123 */,
6570-
/* 124 */
6571-
/***/ (function(__unusedmodule, exports) {
6572-
6573-
"use strict";
6574-
6575-
/*
6576-
* Copyright The OpenTelemetry Authors
6577-
*
6578-
* Licensed under the Apache License, Version 2.0 (the "License");
6579-
* you may not use this file except in compliance with the License.
6580-
* You may obtain a copy of the License at
6581-
*
6582-
* https://www.apache.org/licenses/LICENSE-2.0
6583-
*
6584-
* Unless required by applicable law or agreed to in writing, software
6585-
* distributed under the License is distributed on an "AS IS" BASIS,
6586-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6587-
* See the License for the specific language governing permissions and
6588-
* limitations under the License.
6589-
*/
6590-
Object.defineProperty(exports, "__esModule", { value: true });
6591-
//# sourceMappingURL=tracer_provider.js.map
6592-
6593-
/***/ }),
6570+
/* 124 */,
65946571
/* 125 */,
65956572
/* 126 */
65966573
/***/ (function(module) {
@@ -7530,7 +7507,6 @@ const installer = __importStar(__webpack_require__(923));
75307507
const auth = __importStar(__webpack_require__(749));
75317508
const path = __importStar(__webpack_require__(622));
75327509
const cache_restore_1 = __webpack_require__(409);
7533-
const constants_1 = __webpack_require__(694);
75347510
const url_1 = __webpack_require__(835);
75357511
const os = __webpack_require__(87);
75367512
function run() {
@@ -7540,12 +7516,12 @@ function run() {
75407516
// Version is optional. If supplied, install / use from the tool cache
75417517
// If not supplied then task is still used to setup proxy, auth, etc...
75427518
//
7543-
let version = core.getInput(constants_1.Inputs.NodeVersion);
7519+
let version = core.getInput('node-version');
75447520
if (!version) {
7545-
version = core.getInput(constants_1.Inputs.Version);
7521+
version = core.getInput('version');
75467522
}
7547-
let arch = core.getInput(constants_1.Inputs.Architecture);
7548-
const cache = core.getInput(constants_1.Inputs.Cache);
7523+
let arch = core.getInput('architecture');
7524+
const cache = core.getInput('cache');
75497525
core.info(`cache is ${cache}`);
75507526
// if architecture supplied but node-version is not
75517527
// if we don't throw a warning, the already installed x64 node will be used which is not probably what user meant.
@@ -7556,14 +7532,14 @@ function run() {
75567532
arch = os.arch();
75577533
}
75587534
if (version) {
7559-
let token = core.getInput(constants_1.Inputs.Token);
7535+
let token = core.getInput('token');
75607536
let auth = !token || isGhes() ? undefined : `token ${token}`;
7561-
let stable = (core.getInput(constants_1.Inputs.Stable) || 'true').toUpperCase() === 'TRUE';
7562-
const checkLatest = (core.getInput(constants_1.Inputs.CheckLatest) || 'false').toUpperCase() === 'TRUE';
7537+
let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
7538+
const checkLatest = (core.getInput('check-latest') || 'false').toUpperCase() === 'TRUE';
75637539
yield installer.getNode(version, stable, checkLatest, auth, arch);
75647540
}
7565-
const registryUrl = core.getInput(constants_1.Inputs.RegistryUrl);
7566-
const alwaysAuth = core.getInput(constants_1.Inputs.AlwaysAuth);
7541+
const registryUrl = core.getInput('registry-url');
7542+
const alwaysAuth = core.getInput('always-auth');
75677543
if (registryUrl) {
75687544
auth.configAuthentication(registryUrl, alwaysAuth);
75697545
}
@@ -9304,7 +9280,29 @@ function authenticationPlugin(octokit, options) {
93049280
/* 193 */,
93059281
/* 194 */,
93069282
/* 195 */,
9307-
/* 196 */,
9283+
/* 196 */
9284+
/***/ (function(__unusedmodule, exports) {
9285+
9286+
"use strict";
9287+
9288+
Object.defineProperty(exports, "__esModule", { value: true });
9289+
var LockType;
9290+
(function (LockType) {
9291+
LockType["Npm"] = "npm";
9292+
LockType["Yarn"] = "yarn";
9293+
})(LockType = exports.LockType || (exports.LockType = {}));
9294+
var State;
9295+
(function (State) {
9296+
State["CachePrimaryKey"] = "CACHE_KEY";
9297+
State["CacheMatchedKey"] = "CACHE_RESULT";
9298+
})(State = exports.State || (exports.State = {}));
9299+
var Outputs;
9300+
(function (Outputs) {
9301+
Outputs["CacheHit"] = "cache-hit";
9302+
})(Outputs = exports.Outputs || (exports.Outputs = {}));
9303+
9304+
9305+
/***/ }),
93089306
/* 197 */
93099307
/***/ (function(module, __unusedexports, __webpack_require__) {
93109308

@@ -43394,16 +43392,21 @@ var __importStar = (this && this.__importStar) || function (mod) {
4339443392
result["default"] = mod;
4339543393
return result;
4339643394
};
43395+
var __importDefault = (this && this.__importDefault) || function (mod) {
43396+
return (mod && mod.__esModule) ? mod : { "default": mod };
43397+
};
4339743398
Object.defineProperty(exports, "__esModule", { value: true });
4339843399
const cache = __importStar(__webpack_require__(638));
4339943400
const core = __importStar(__webpack_require__(470));
43400-
const constants_1 = __webpack_require__(694);
43401+
const path_1 = __importDefault(__webpack_require__(622));
43402+
const fs_1 = __importDefault(__webpack_require__(747));
43403+
const constants_1 = __webpack_require__(196);
4340143404
const cache_utils_1 = __webpack_require__(452);
4340243405
exports.restoreCache = (toolName, version) => __awaiter(void 0, void 0, void 0, function* () {
4340343406
if (!cache_utils_1.isPackageManagerCacheSupported(toolName)) {
4340443407
throw new Error(`${toolName} is not supported`);
4340543408
}
43406-
const lockKey = core.getInput(constants_1.Inputs.Key, { required: true });
43409+
const lockKey = getLockFile(toolName);
4340743410
const platform = process.env.RUNNER_OS;
4340843411
const fileHash = yield cache_utils_1.hashFile(lockKey);
4340943412
const primaryKey = `${platform}-${toolName}-${version}-${fileHash}`;
@@ -43419,6 +43422,19 @@ exports.restoreCache = (toolName, version) => __awaiter(void 0, void 0, void 0,
4341943422
core.setOutput(constants_1.Outputs.CacheHit, isExactMatch);
4342043423
core.info(`Cache restored from key: ${cacheKey}`);
4342143424
});
43425+
const getLockFile = (cacheType) => {
43426+
let lockFile = 'package-lock.json';
43427+
const workspace = process.env.GITHUB_WORKSPACE;
43428+
const rootContent = fs_1.default.readdirSync(workspace);
43429+
if (cacheType === 'yarn') {
43430+
lockFile = 'yarn.lock';
43431+
}
43432+
const fullLockFile = rootContent.find(item => lockFile === item);
43433+
if (!fullLockFile) {
43434+
throw new Error('No package-lock.json or yarn.lock were found');
43435+
}
43436+
return path_1.default.resolve(fullLockFile);
43437+
};
4342243438

4342343439

4342443440
/***/ }),
@@ -44470,7 +44486,7 @@ __exportStar(__webpack_require__(932), exports);
4447044486
__exportStar(__webpack_require__(839), exports);
4447144487
__exportStar(__webpack_require__(975), exports);
4447244488
__exportStar(__webpack_require__(70), exports);
44473-
__exportStar(__webpack_require__(124), exports);
44489+
__exportStar(__webpack_require__(694), exports);
4447444490
__exportStar(__webpack_require__(695), exports);
4447544491
var context_base_1 = __webpack_require__(995);
4447644492
Object.defineProperty(exports, "Context", { enumerable: true, get: function () { return context_base_1.Context; } });
@@ -44661,7 +44677,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
4466144677
};
4466244678
Object.defineProperty(exports, "__esModule", { value: true });
4466344679
const exec = __importStar(__webpack_require__(986));
44664-
const constants_1 = __webpack_require__(694);
44680+
const constants_1 = __webpack_require__(196);
4466544681
const glob = __importStar(__webpack_require__(281));
4466644682
const crypto = __importStar(__webpack_require__(417));
4466744683
const fs = __importStar(__webpack_require__(747));
@@ -55450,37 +55466,23 @@ exports.Deprecation = Deprecation;
5545055466

5545155467
"use strict";
5545255468

55469+
/*
55470+
* Copyright The OpenTelemetry Authors
55471+
*
55472+
* Licensed under the Apache License, Version 2.0 (the "License");
55473+
* you may not use this file except in compliance with the License.
55474+
* You may obtain a copy of the License at
55475+
*
55476+
* https://www.apache.org/licenses/LICENSE-2.0
55477+
*
55478+
* Unless required by applicable law or agreed to in writing, software
55479+
* distributed under the License is distributed on an "AS IS" BASIS,
55480+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
55481+
* See the License for the specific language governing permissions and
55482+
* limitations under the License.
55483+
*/
5545355484
Object.defineProperty(exports, "__esModule", { value: true });
55454-
var Inputs;
55455-
(function (Inputs) {
55456-
Inputs["Cache"] = "cache";
55457-
Inputs["Key"] = "key";
55458-
Inputs["RestoreKeys"] = "restore-keys";
55459-
Inputs["NodeVersion"] = "node-version";
55460-
Inputs["Version"] = "version";
55461-
Inputs["Architecture"] = "architecture";
55462-
Inputs["Token"] = "token";
55463-
Inputs["Stable"] = "stable";
55464-
Inputs["CheckLatest"] = "check-latest";
55465-
Inputs["RegistryUrl"] = "registry-url";
55466-
Inputs["AlwaysAuth"] = "always-auth";
55467-
Inputs["Scope"] = "scope";
55468-
})(Inputs = exports.Inputs || (exports.Inputs = {}));
55469-
var LockType;
55470-
(function (LockType) {
55471-
LockType["Npm"] = "npm";
55472-
LockType["Yarn"] = "yarn";
55473-
})(LockType = exports.LockType || (exports.LockType = {}));
55474-
var State;
55475-
(function (State) {
55476-
State["CachePrimaryKey"] = "CACHE_KEY";
55477-
State["CacheMatchedKey"] = "CACHE_RESULT";
55478-
})(State = exports.State || (exports.State = {}));
55479-
var Outputs;
55480-
(function (Outputs) {
55481-
Outputs["CacheHit"] = "cache-hit";
55482-
})(Outputs = exports.Outputs || (exports.Outputs = {}));
55483-
55485+
//# sourceMappingURL=tracer_provider.js.map
5548455486

5548555487
/***/ }),
5548655488
/* 695 */
@@ -56711,7 +56713,6 @@ const os = __importStar(__webpack_require__(87));
5671156713
const path = __importStar(__webpack_require__(622));
5671256714
const core = __importStar(__webpack_require__(470));
5671356715
const github = __importStar(__webpack_require__(469));
56714-
const constants_1 = __webpack_require__(694);
5671556716
function configAuthentication(registryUrl, alwaysAuth) {
5671656717
const npmrc = path.resolve(process.env['RUNNER_TEMP'] || process.cwd(), '.npmrc');
5671756718
if (!registryUrl.endsWith('/')) {
@@ -56721,7 +56722,7 @@ function configAuthentication(registryUrl, alwaysAuth) {
5672156722
}
5672256723
exports.configAuthentication = configAuthentication;
5672356724
function writeRegistryToFile(registryUrl, fileLocation, alwaysAuth) {
56724-
let scope = core.getInput(constants_1.Inputs.Scope);
56725+
let scope = core.getInput('scope');
5672556726
if (!scope && registryUrl.indexOf('npm.pkg.github.com') > -1) {
5672656727
scope = github.context.repo.owner;
5672756728
}

src/authutil.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as os from 'os';
33
import * as path from 'path';
44
import * as core from '@actions/core';
55
import * as github from '@actions/github';
6-
import {Inputs} from './constants';
76

87
export function configAuthentication(registryUrl: string, alwaysAuth: string) {
98
const npmrc: string = path.resolve(
@@ -22,7 +21,7 @@ function writeRegistryToFile(
2221
fileLocation: string,
2322
alwaysAuth: string
2423
) {
25-
let scope: string = core.getInput(Inputs.Scope);
24+
let scope: string = core.getInput('scope');
2625
if (!scope && registryUrl.indexOf('npm.pkg.github.com') > -1) {
2726
scope = github.context.repo.owner;
2827
}

src/cache-restore.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import * as cache from '@actions/cache';
22
import * as core from '@actions/core';
3+
import path from 'path';
4+
import fs from 'fs';
35

4-
import {State, Inputs, Outputs} from './constants';
6+
import {State, Outputs} from './constants';
57
import {
68
getCacheDirectoryPath,
79
hashFile,
@@ -12,7 +14,8 @@ export const restoreCache = async (toolName: string, version: string) => {
1214
if (!isPackageManagerCacheSupported(toolName)) {
1315
throw new Error(`${toolName} is not supported`);
1416
}
15-
const lockKey = core.getInput(Inputs.Key, {required: true});
17+
const lockKey = getLockFile(toolName);
18+
1619
const platform = process.env.RUNNER_OS;
1720
const fileHash = await hashFile(lockKey);
1821

@@ -32,3 +35,19 @@ export const restoreCache = async (toolName: string, version: string) => {
3235
core.setOutput(Outputs.CacheHit, isExactMatch);
3336
core.info(`Cache restored from key: ${cacheKey}`);
3437
};
38+
39+
const getLockFile = (cacheType: string) => {
40+
let lockFile = 'package-lock.json';
41+
const workspace = process.env.GITHUB_WORKSPACE!;
42+
const rootContent = fs.readdirSync(workspace);
43+
if (cacheType === 'yarn') {
44+
lockFile = 'yarn.lock';
45+
}
46+
47+
const fullLockFile = rootContent.find(item => lockFile === item);
48+
if (!fullLockFile) {
49+
throw new Error('No package-lock.json or yarn.lock were found');
50+
}
51+
52+
return path.resolve(fullLockFile);
53+
};

src/cache-save.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import * as core from '@actions/core';
22
import * as cache from '@actions/cache';
3-
import {Inputs, State} from './constants';
3+
import {State} from './constants';
44
import {getCacheDirectoryPath} from './cache-utils';
55

66
async function run() {
7-
const cacheLock = core.getInput(Inputs.Cache);
7+
const cacheLock = core.getInput('cache');
88
try {
99
await cachePackages(cacheLock);
1010
} catch (error) {

src/constants.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
1-
export enum Inputs {
2-
Cache = 'cache',
3-
Key = 'key',
4-
RestoreKeys = 'restore-keys',
5-
NodeVersion = 'node-version',
6-
Version = 'version',
7-
Architecture = 'architecture',
8-
Token = 'token',
9-
Stable = 'stable',
10-
CheckLatest = 'check-latest',
11-
RegistryUrl = 'registry-url',
12-
AlwaysAuth = 'always-auth',
13-
Scope = 'scope'
14-
}
15-
161
export enum LockType {
172
Npm = 'npm',
183
Yarn = 'yarn'

0 commit comments

Comments
 (0)