mirror of
https://github.com/actions/setup-python.git
synced 2025-04-24 15:32:13 +00:00
Remove PromiseReturnType, add matchedKey == primaryKey check
This commit is contained in:
parent
fa50ad5388
commit
08415fd28f
4 changed files with 9 additions and 24 deletions
7
dist/cache-save/index.js
vendored
7
dist/cache-save/index.js
vendored
|
@ -37234,18 +37234,17 @@ class CacheDistributor {
|
||||||
core.saveState(State.CACHE_PATHS, cachePath);
|
core.saveState(State.CACHE_PATHS, cachePath);
|
||||||
core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
|
core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
|
||||||
const matchedKey = yield cache.restoreCache(cachePath, primaryKey, restoreKey);
|
const matchedKey = yield cache.restoreCache(cachePath, primaryKey, restoreKey);
|
||||||
this.handleMatchResult(matchedKey);
|
this.handleMatchResult(matchedKey, primaryKey);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
handleMatchResult(matchedKey) {
|
handleMatchResult(matchedKey, primaryKey) {
|
||||||
if (matchedKey) {
|
if (matchedKey == primaryKey) {
|
||||||
core.saveState(State.CACHE_MATCHED_KEY, matchedKey);
|
core.saveState(State.CACHE_MATCHED_KEY, matchedKey);
|
||||||
core.info(`Cache restored from key: ${matchedKey}`);
|
core.info(`Cache restored from key: ${matchedKey}`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.info(`${this.packageManager} cache is not found`);
|
core.info(`${this.packageManager} cache is not found`);
|
||||||
}
|
}
|
||||||
core.info('cache was hit');
|
|
||||||
core.setOutput('cache-hit', Boolean(matchedKey));
|
core.setOutput('cache-hit', Boolean(matchedKey));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
7
dist/setup/index.js
vendored
7
dist/setup/index.js
vendored
|
@ -42579,18 +42579,17 @@ class CacheDistributor {
|
||||||
core.saveState(State.CACHE_PATHS, cachePath);
|
core.saveState(State.CACHE_PATHS, cachePath);
|
||||||
core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
|
core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
|
||||||
const matchedKey = yield cache.restoreCache(cachePath, primaryKey, restoreKey);
|
const matchedKey = yield cache.restoreCache(cachePath, primaryKey, restoreKey);
|
||||||
this.handleMatchResult(matchedKey);
|
this.handleMatchResult(matchedKey, primaryKey);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
handleMatchResult(matchedKey) {
|
handleMatchResult(matchedKey, primaryKey) {
|
||||||
if (matchedKey) {
|
if (matchedKey == primaryKey) {
|
||||||
core.saveState(State.CACHE_MATCHED_KEY, matchedKey);
|
core.saveState(State.CACHE_MATCHED_KEY, matchedKey);
|
||||||
core.info(`Cache restored from key: ${matchedKey}`);
|
core.info(`Cache restored from key: ${matchedKey}`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.info(`${this.packageManager} cache is not found`);
|
core.info(`${this.packageManager} cache is not found`);
|
||||||
}
|
}
|
||||||
core.info('cache was hit');
|
|
||||||
core.setOutput('cache-hit', Boolean(matchedKey));
|
core.setOutput('cache-hit', Boolean(matchedKey));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import * as cache from '@actions/cache';
|
import * as cache from '@actions/cache';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import {PromiseReturnType} from '../utils';
|
|
||||||
|
|
||||||
export enum State {
|
export enum State {
|
||||||
STATE_CACHE_PRIMARY_KEY = 'cache-primary-key',
|
STATE_CACHE_PRIMARY_KEY = 'cache-primary-key',
|
||||||
|
@ -42,19 +41,16 @@ abstract class CacheDistributor {
|
||||||
restoreKey
|
restoreKey
|
||||||
);
|
);
|
||||||
|
|
||||||
this.handleMatchResult(matchedKey);
|
this.handleMatchResult(matchedKey, primaryKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public handleMatchResult(
|
public handleMatchResult(matchedKey: string | undefined, primaryKey: string) {
|
||||||
matchedKey: PromiseReturnType<typeof cache.restoreCache>
|
if (matchedKey == primaryKey) {
|
||||||
) {
|
|
||||||
if (matchedKey) {
|
|
||||||
core.saveState(State.CACHE_MATCHED_KEY, matchedKey);
|
core.saveState(State.CACHE_MATCHED_KEY, matchedKey);
|
||||||
core.info(`Cache restored from key: ${matchedKey}`);
|
core.info(`Cache restored from key: ${matchedKey}`);
|
||||||
} else {
|
} else {
|
||||||
core.info(`${this.packageManager} cache is not found`);
|
core.info(`${this.packageManager} cache is not found`);
|
||||||
}
|
}
|
||||||
core.info('cache was hit');
|
|
||||||
core.setOutput('cache-hit', Boolean(matchedKey));
|
core.setOutput('cache-hit', Boolean(matchedKey));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,12 +119,3 @@ export function isCacheFeatureAvailable(): boolean {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Awaited (typescript 4.5+) polyfill. Not ideal, so use with care
|
|
||||||
export type AwaitedPolyfill<T> = T extends PromiseLike<infer U>
|
|
||||||
? AwaitedPolyfill<U>
|
|
||||||
: T;
|
|
||||||
// Extract return type from promise
|
|
||||||
export type PromiseReturnType<
|
|
||||||
T extends (...args: any) => any
|
|
||||||
> = AwaitedPolyfill<ReturnType<T>>;
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue