Skip to content

Commit b38fc9b

Browse files
change names and remove logs
1 parent 87764b5 commit b38fc9b

File tree

5 files changed

+21
-39
lines changed

5 files changed

+21
-39
lines changed

dist/cleanup/index.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47771,8 +47771,8 @@ exports.isToolSupported = toolName => {
4777147771
exports.getDefaultCacheDirectory = (toolName) => __awaiter(void 0, void 0, void 0, function* () {
4777247772
let stdOut;
4777347773
let stdErr;
47774-
if (exports.isToolSupported(toolName)) {
47775-
core.info(`${toolName} is supported`);
47774+
if (!exports.isToolSupported(toolName)) {
47775+
throw new Error(`${toolName} is not supported`);
4777647776
}
4777747777
const toolVersion = yield getToolVersion(toolName, '--version');
4777847778
const fullToolName = getCmdCommand(toolName, toolVersion);
@@ -47787,7 +47787,7 @@ exports.getDefaultCacheDirectory = (toolName) => __awaiter(void 0, void 0, void
4778747787
throw new Error(stdErr);
4778847788
}
4778947789
if (!stdOut) {
47790-
throw new Error('Could not get version for yarn');
47790+
throw new Error(`Could not get version for ${toolName}`);
4779147791
}
4779247792
return stdOut;
4779347793
});
@@ -50302,21 +50302,18 @@ function run() {
5030250302
const cacheLock = core.getInput(constants_1.Inputs.Cache);
5030350303
if (cacheLock && cache_1.isToolSupported(cacheLock)) {
5030450304
try {
50305-
exports.cachePackages(cacheLock);
50305+
yield cachePackages(cacheLock);
5030650306
}
5030750307
catch (error) {
5030850308
core.setFailed('Failed to remove private key');
5030950309
}
5031050310
}
5031150311
});
5031250312
}
50313-
exports.cachePackages = (toolName) => __awaiter(void 0, void 0, void 0, function* () {
50313+
const cachePackages = (toolName) => __awaiter(void 0, void 0, void 0, function* () {
5031450314
const state = getCacheState();
5031550315
const primaryKey = core.getState(constants_1.State.CachePrimaryKey);
5031650316
const cachePath = yield cache_1.getDefaultCacheDirectory(toolName);
50317-
core.info(`cachePath is ${cachePath}`);
50318-
core.info(`primaryKey is ${primaryKey}`);
50319-
core.info(`state is ${state}`);
5032050317
if (isExactKeyMatch(primaryKey, state)) {
5032150318
core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`);
5032250319
return;
@@ -50346,14 +50343,12 @@ function getCacheState() {
5034650343
}
5034750344
return undefined;
5034850345
}
50349-
exports.getCacheState = getCacheState;
5035050346
function isExactKeyMatch(key, cacheKey) {
5035150347
return !!(cacheKey &&
5035250348
cacheKey.localeCompare(key, undefined, {
5035350349
sensitivity: 'accent'
5035450350
}) === 0);
5035550351
}
50356-
exports.isExactKeyMatch = isExactKeyMatch;
5035750352
run();
5035850353

5035950354

dist/setup/index.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43414,21 +43414,18 @@ const constants_1 = __webpack_require__(694);
4341443414
const cache_1 = __webpack_require__(913);
4341543415
exports.restoreCache = (toolName, version) => __awaiter(void 0, void 0, void 0, function* () {
4341643416
const lockKey = core.getInput(constants_1.Inputs.Key, { required: true });
43417-
const currentOs = process.env.RUNNER_OS;
43417+
const runnerOs = process.env.RUNNER_OS;
4341843418
const fileHash = yield hashFile(lockKey);
43419-
const primaryKey = `${currentOs}-${toolName}-${version}-${fileHash}`;
43419+
const primaryKey = `${runnerOs}-${toolName}-${version}-${fileHash}`;
4342043420
core.saveState(constants_1.State.CachePrimaryKey, primaryKey);
4342143421
const cachePath = yield cache_1.getDefaultCacheDirectory(toolName);
43422-
core.info(`cachePath is ${cachePath}`);
43423-
core.info(`primaryKey is ${primaryKey}`);
4342443422
const cacheKey = yield cache.restoreCache([cachePath], primaryKey);
4342543423
if (!cacheKey) {
43426-
core.info(`Cache not found for input keys: ${primaryKey}`);
43424+
core.warning(`Cache not found for input keys: ${primaryKey}`);
4342743425
return;
4342843426
}
4342943427
core.saveState(constants_1.State.CacheMatchedKey, cacheKey);
4343043428
const isExactMatch = (primaryKey === cacheKey).toString();
43431-
core.debug(`isExactMatch is ${isExactMatch}`);
4343243429
core.setOutput(constants_1.Outputs.CacheHit, isExactMatch);
4343343430
core.info(`Cache restored from key: ${cacheKey}`);
4343443431
});
@@ -43449,11 +43446,9 @@ function hashFile(matchPatterns) {
4344943446
const file = _c.value;
4345043447
console.log(file);
4345143448
if (!file.startsWith(`${githubWorkspace}${path.sep}`)) {
43452-
console.log(`Ignore '${file}' since it is not under GITHUB_WORKSPACE.`);
4345343449
continue;
4345443450
}
4345543451
if (fs.statSync(file).isDirectory()) {
43456-
console.log(`Skip directory '${file}'.`);
4345743452
continue;
4345843453
}
4345943454
const hash = crypto.createHash('sha256');
@@ -64363,8 +64358,8 @@ exports.isToolSupported = toolName => {
6436364358
exports.getDefaultCacheDirectory = (toolName) => __awaiter(void 0, void 0, void 0, function* () {
6436464359
let stdOut;
6436564360
let stdErr;
64366-
if (exports.isToolSupported(toolName)) {
64367-
core.info(`${toolName} is supported`);
64361+
if (!exports.isToolSupported(toolName)) {
64362+
throw new Error(`${toolName} is not supported`);
6436864363
}
6436964364
const toolVersion = yield getToolVersion(toolName, '--version');
6437064365
const fullToolName = getCmdCommand(toolName, toolVersion);
@@ -64379,7 +64374,7 @@ exports.getDefaultCacheDirectory = (toolName) => __awaiter(void 0, void 0, void
6437964374
throw new Error(stdErr);
6438064375
}
6438164376
if (!stdOut) {
64382-
throw new Error('Could not get version for yarn');
64377+
throw new Error(`Could not get version for ${toolName}`);
6438364378
}
6438464379
return stdOut;
6438564380
});

src/cache-restore.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,22 @@ import {getDefaultCacheDirectory} from './cache';
1212

1313
export const restoreCache = async (toolName: string, version: string) => {
1414
const lockKey = core.getInput(Inputs.Key, {required: true});
15-
const currentOs = process.env.RUNNER_OS;
15+
const runnerOs = process.env.RUNNER_OS;
1616
const fileHash = await hashFile(lockKey);
1717

18-
const primaryKey = `${currentOs}-${toolName}-${version}-${fileHash}`;
18+
const primaryKey = `${runnerOs}-${toolName}-${version}-${fileHash}`;
1919
core.saveState(State.CachePrimaryKey, primaryKey);
2020

2121
const cachePath = await getDefaultCacheDirectory(toolName);
22-
core.info(`cachePath is ${cachePath}`);
23-
core.info(`primaryKey is ${primaryKey}`);
2422
const cacheKey = await cache.restoreCache([cachePath], primaryKey);
2523

2624
if (!cacheKey) {
27-
core.info(`Cache not found for input keys: ${primaryKey}`);
25+
core.warning(`Cache not found for input keys: ${primaryKey}`);
2826
return;
2927
}
3028

3129
core.saveState(State.CacheMatchedKey, cacheKey);
3230
const isExactMatch = (primaryKey === cacheKey).toString();
33-
core.debug(`isExactMatch is ${isExactMatch}`);
3431
core.setOutput(Outputs.CacheHit, isExactMatch);
3532
core.info(`Cache restored from key: ${cacheKey}`);
3633
};
@@ -49,11 +46,9 @@ async function hashFile(matchPatterns: string): Promise<string> {
4946
for await (const file of globber.globGenerator()) {
5047
console.log(file);
5148
if (!file.startsWith(`${githubWorkspace}${path.sep}`)) {
52-
console.log(`Ignore '${file}' since it is not under GITHUB_WORKSPACE.`);
5349
continue;
5450
}
5551
if (fs.statSync(file).isDirectory()) {
56-
console.log(`Skip directory '${file}'.`);
5752
continue;
5853
}
5954
const hash = crypto.createHash('sha256');

src/cache-save.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,18 @@ async function run() {
77
const cacheLock = core.getInput(Inputs.Cache);
88
if (cacheLock && isToolSupported(cacheLock)) {
99
try {
10-
cachePackages(cacheLock);
10+
await cachePackages(cacheLock);
1111
} catch (error) {
1212
core.setFailed('Failed to remove private key');
1313
}
1414
}
1515
}
1616

17-
export const cachePackages = async (toolName: string) => {
17+
const cachePackages = async (toolName: string) => {
1818
const state = getCacheState();
1919
const primaryKey = core.getState(State.CachePrimaryKey);
2020

2121
const cachePath = await getDefaultCacheDirectory(toolName);
22-
core.info(`cachePath is ${cachePath}`);
23-
core.info(`primaryKey is ${primaryKey}`);
24-
core.info(`state is ${state}`);
2522
if (isExactKeyMatch(primaryKey, state)) {
2623
core.info(
2724
`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`
@@ -44,7 +41,7 @@ export const cachePackages = async (toolName: string) => {
4441
}
4542
};
4643

47-
export function getCacheState(): string | undefined {
44+
function getCacheState(): string | undefined {
4845
const cacheKey = core.getState(State.CacheMatchedKey);
4946
if (cacheKey) {
5047
core.debug(`Cache state/key: ${cacheKey}`);
@@ -54,7 +51,7 @@ export function getCacheState(): string | undefined {
5451
return undefined;
5552
}
5653

57-
export function isExactKeyMatch(key: string, cacheKey?: string): boolean {
54+
function isExactKeyMatch(key: string, cacheKey?: string): boolean {
5855
return !!(
5956
cacheKey &&
6057
cacheKey.localeCompare(key, undefined, {

src/cache.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ export const getDefaultCacheDirectory = async (toolName: string) => {
6464
let stdOut: string | undefined;
6565
let stdErr: string | undefined;
6666

67-
if (isToolSupported(toolName)) {
68-
core.info(`${toolName} is supported`);
67+
if (!isToolSupported(toolName)) {
68+
throw new Error(`${toolName} is not supported`);
6969
}
7070

7171
const toolVersion = await getToolVersion(toolName, '--version');
@@ -84,7 +84,7 @@ export const getDefaultCacheDirectory = async (toolName: string) => {
8484
}
8585

8686
if (!stdOut) {
87-
throw new Error('Could not get version for yarn');
87+
throw new Error(`Could not get version for ${toolName}`);
8888
}
8989

9090
return stdOut;

0 commit comments

Comments
 (0)