Rename ActionCache to ActionsCache

This commit is contained in:
Sergey Dolin 2023-07-04 18:29:58 +02:00
parent 765f3db869
commit a9c16cbf4d
8 changed files with 16 additions and 16 deletions

View File

@ -14,7 +14,7 @@ export class StateMock implements IState {
return Promise.resolve(undefined); return Promise.resolve(undefined);
} }
rehydrate(): Promise<void> { restore(): Promise<void> {
return Promise.resolve(undefined); return Promise.resolve(undefined);
} }

14
dist/index.js vendored
View File

@ -39,7 +39,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
}); });
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.downloadFileFromActionCache = void 0; exports.downloadFileFromActionsCache = void 0;
const http_client_1 = __nccwpck_require__(8661); const http_client_1 = __nccwpck_require__(8661);
const retry_1 = __nccwpck_require__(3910); const retry_1 = __nccwpck_require__(3910);
const http_responses_1 = __nccwpck_require__(7233); const http_responses_1 = __nccwpck_require__(7233);
@ -67,7 +67,7 @@ const getCacheArchiveUrl = (httpClient, cacheKey, cacheVersion) => __awaiter(voi
} }
return cacheDownloadUrl; return cacheDownloadUrl;
}); });
const downloadFileFromActionCache = (destFileName, cacheKey, cacheVersion) => __awaiter(void 0, void 0, void 0, function* () { const downloadFileFromActionsCache = (destFileName, cacheKey, cacheVersion) => __awaiter(void 0, void 0, void 0, function* () {
const httpClient = (0, http_client_1.createHttpClient)(); const httpClient = (0, http_client_1.createHttpClient)();
const archiveUrl = yield getCacheArchiveUrl(httpClient, cacheKey, cacheVersion); const archiveUrl = yield getCacheArchiveUrl(httpClient, cacheKey, cacheVersion);
if (!archiveUrl) { if (!archiveUrl) {
@ -75,7 +75,7 @@ const downloadFileFromActionCache = (destFileName, cacheKey, cacheVersion) => __
} }
yield (0, downloadUtils_1.downloadCacheHttpClient)(archiveUrl, destFileName); yield (0, downloadUtils_1.downloadCacheHttpClient)(archiveUrl, destFileName);
}); });
exports.downloadFileFromActionCache = downloadFileFromActionCache; exports.downloadFileFromActionsCache = downloadFileFromActionsCache;
/***/ }), /***/ }),
@ -2041,9 +2041,9 @@ class StateCacheStorage {
const tmpDir = fs_1.default.mkdtempSync('state-'); const tmpDir = fs_1.default.mkdtempSync('state-');
const fileName = path_1.default.join(tmpDir, STATE_FILE); const fileName = path_1.default.join(tmpDir, STATE_FILE);
try { try {
yield (0, download_1.downloadFileFromActionCache)(fileName, CACHE_KEY, CACHE_VERSION); yield (0, download_1.downloadFileFromActionsCache)(fileName, CACHE_KEY, CACHE_VERSION);
if (!fs_1.default.existsSync(fileName)) { if (!fs_1.default.existsSync(fileName)) {
core.info('There is no state persisted, probably because of the very first run or previous run failed'); core.info('The stored state has not been found, probably because of the very first run or the previous run failed');
return ''; return '';
} }
return fs_1.default.readFileSync(path_1.default.join(tmpDir, STATE_FILE), { return fs_1.default.readFileSync(path_1.default.join(tmpDir, STATE_FILE), {
@ -2143,7 +2143,7 @@ class State {
return this.stateStorage.save(this.serialized); return this.stateStorage.save(this.serialized);
}); });
} }
rehydrate() { restore() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
this.reset(); this.reset();
const serialized = yield this.stateStorage.restore(); const serialized = yield this.stateStorage.restore();
@ -2848,7 +2848,7 @@ function _run() {
try { try {
const args = _getAndValidateArgs(); const args = _getAndValidateArgs();
const state = (0, state_service_1.getStateInstance)(args); const state = (0, state_service_1.getStateInstance)(args);
yield state.rehydrate(); yield state.restore();
const issueProcessor = new issues_processor_1.IssuesProcessor(args, state); const issueProcessor = new issues_processor_1.IssuesProcessor(args, state);
yield issueProcessor.processIssues(); yield issueProcessor.processIssues();
yield state.persist(); yield state.persist();

View File

@ -45,7 +45,7 @@ const getCacheArchiveUrl = async (
return cacheDownloadUrl; return cacheDownloadUrl;
}; };
export const downloadFileFromActionCache = async ( export const downloadFileFromActionsCache = async (
destFileName: string, destFileName: string,
cacheKey: string, cacheKey: string,
cacheVersion: string cacheVersion: string

View File

@ -4,7 +4,7 @@ import path from 'path';
import os from 'os'; import os from 'os';
import * as core from '@actions/core'; import * as core from '@actions/core';
import {uploadFileToActionsCache} from '../actions-cache/upload'; import {uploadFileToActionsCache} from '../actions-cache/upload';
import {downloadFileFromActionCache} from '../actions-cache/download'; import {downloadFileFromActionsCache} from '../actions-cache/download';
const CACHE_KEY = '_state'; const CACHE_KEY = '_state';
const CACHE_VERSION = '1'; const CACHE_VERSION = '1';
@ -30,10 +30,10 @@ export class StateCacheStorage implements IStateStorage {
const tmpDir = fs.mkdtempSync('state-'); const tmpDir = fs.mkdtempSync('state-');
const fileName = path.join(tmpDir, STATE_FILE); const fileName = path.join(tmpDir, STATE_FILE);
try { try {
await downloadFileFromActionCache(fileName, CACHE_KEY, CACHE_VERSION); await downloadFileFromActionsCache(fileName, CACHE_KEY, CACHE_VERSION);
if (!fs.existsSync(fileName)) { if (!fs.existsSync(fileName)) {
core.info( core.info(
'There is no state persisted, probably because of the very first run or previous run failed' 'The stored state has not been found, probably because of the very first run or the previous run failed'
); );
return ''; return '';
} }

View File

@ -114,7 +114,7 @@ describe('State', () => {
mockStorage, mockStorage,
{} as unknown as IIssuesProcessorOptions {} as unknown as IIssuesProcessorOptions
); );
await state.rehydrate(); await state.restore();
const processedIssuesIDs = ( const processedIssuesIDs = (
state as unknown as {processedIssuesIDs: Set<IssueID>} state as unknown as {processedIssuesIDs: Set<IssueID>}
).processedIssuesIDs; ).processedIssuesIDs;

View File

@ -60,7 +60,7 @@ export class State implements IState {
return this.stateStorage.save(this.serialized); return this.stateStorage.save(this.serialized);
} }
async rehydrate(): Promise<void> { async restore(): Promise<void> {
this.reset(); this.reset();
const serialized = await this.stateStorage.restore(); const serialized = await this.stateStorage.restore();
this.deserialize(serialized); this.deserialize(serialized);

View File

@ -5,5 +5,5 @@ export interface IState {
addIssueToProcessed(issue: IIssue): void; addIssueToProcessed(issue: IIssue): void;
reset(): void; reset(): void;
persist(): Promise<void>; persist(): Promise<void>;
rehydrate(): Promise<void>; restore(): Promise<void>;
} }

View File

@ -10,7 +10,7 @@ async function _run(): Promise<void> {
const args = _getAndValidateArgs(); const args = _getAndValidateArgs();
const state = getStateInstance(args); const state = getStateInstance(args);
await state.rehydrate(); await state.restore();
const issueProcessor: IssuesProcessor = new IssuesProcessor(args, state); const issueProcessor: IssuesProcessor = new IssuesProcessor(args, state);
await issueProcessor.processIssues(); await issueProcessor.processIssues();