mirror of
https://codeberg.org/actions/setup-go.git
synced 2024-01-07 17:16:05 +00:00
Merge pull request #264 from e-korolevskii/258-not-throw-err-no-cache-folders
Not throw err no cache folder
This commit is contained in:
commit
30b9ddff11
|
@ -295,7 +295,6 @@ describe('setup-go', () => {
|
||||||
findSpy.mockImplementation(() => toolPath);
|
findSpy.mockImplementation(() => toolPath);
|
||||||
await main.run();
|
await main.run();
|
||||||
|
|
||||||
let expPath = path.join(toolPath, 'bin');
|
|
||||||
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -462,9 +461,6 @@ describe('setup-go', () => {
|
||||||
inputs['go-version'] = versionSpec;
|
inputs['go-version'] = versionSpec;
|
||||||
inputs['token'] = 'faketoken';
|
inputs['token'] = 'faketoken';
|
||||||
|
|
||||||
let expectedUrl =
|
|
||||||
'https://github.com/actions/go-versions/releases/download/1.12.14-20200616.18/go-1.12.14-linux-x64.tar.gz';
|
|
||||||
|
|
||||||
// ... but not in the local cache
|
// ... but not in the local cache
|
||||||
findSpy.mockImplementation(() => '');
|
findSpy.mockImplementation(() => '');
|
||||||
|
|
||||||
|
@ -526,7 +522,7 @@ describe('setup-go', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
mkdirpSpy.mockImplementation(async () => {});
|
mkdirpSpy.mockImplementation(async () => {});
|
||||||
existsSpy.mockImplementation(path => {
|
existsSpy.mockImplementation(() => {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -707,8 +703,6 @@ describe('setup-go', () => {
|
||||||
const toolPath = path.normalize('/cache/go/1.17.5/x64');
|
const toolPath = path.normalize('/cache/go/1.17.5/x64');
|
||||||
extractTarSpy.mockImplementation(async () => '/some/other/temp/path');
|
extractTarSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
cacheSpy.mockImplementation(async () => toolPath);
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
const expectedUrl =
|
|
||||||
'https://github.com/actions/go-versions/releases/download/1.17.6-1668090892/go-1.17.6-darwin-x64.tar.gz';
|
|
||||||
|
|
||||||
await main.run();
|
await main.run();
|
||||||
|
|
||||||
|
@ -834,7 +828,7 @@ exclude example.com/thismodule v1.3.0
|
||||||
|
|
||||||
it('reads version from go.mod', async () => {
|
it('reads version from go.mod', async () => {
|
||||||
inputs['go-version-file'] = 'go.mod';
|
inputs['go-version-file'] = 'go.mod';
|
||||||
existsSpy.mockImplementation(path => true);
|
existsSpy.mockImplementation(() => true);
|
||||||
readFileSpy.mockImplementation(() => Buffer.from(goModContents));
|
readFileSpy.mockImplementation(() => Buffer.from(goModContents));
|
||||||
|
|
||||||
await main.run();
|
await main.run();
|
||||||
|
@ -846,7 +840,7 @@ exclude example.com/thismodule v1.3.0
|
||||||
|
|
||||||
it('reads version from .go-version', async () => {
|
it('reads version from .go-version', async () => {
|
||||||
inputs['go-version-file'] = '.go-version';
|
inputs['go-version-file'] = '.go-version';
|
||||||
existsSpy.mockImplementation(path => true);
|
existsSpy.mockImplementation(() => true);
|
||||||
readFileSpy.mockImplementation(() => Buffer.from(`1.13.0${osm.EOL}`));
|
readFileSpy.mockImplementation(() => Buffer.from(`1.13.0${osm.EOL}`));
|
||||||
|
|
||||||
await main.run();
|
await main.run();
|
||||||
|
@ -859,7 +853,7 @@ exclude example.com/thismodule v1.3.0
|
||||||
it('is overwritten by go-version', async () => {
|
it('is overwritten by go-version', async () => {
|
||||||
inputs['go-version'] = '1.13.1';
|
inputs['go-version'] = '1.13.1';
|
||||||
inputs['go-version-file'] = 'go.mod';
|
inputs['go-version-file'] = 'go.mod';
|
||||||
existsSpy.mockImplementation(path => true);
|
existsSpy.mockImplementation(() => true);
|
||||||
readFileSpy.mockImplementation(() => Buffer.from(goModContents));
|
readFileSpy.mockImplementation(() => Buffer.from(goModContents));
|
||||||
|
|
||||||
await main.run();
|
await main.run();
|
||||||
|
@ -871,7 +865,7 @@ exclude example.com/thismodule v1.3.0
|
||||||
|
|
||||||
it('reports a read failure', async () => {
|
it('reports a read failure', async () => {
|
||||||
inputs['go-version-file'] = 'go.mod';
|
inputs['go-version-file'] = 'go.mod';
|
||||||
existsSpy.mockImplementation(path => false);
|
existsSpy.mockImplementation(() => false);
|
||||||
|
|
||||||
await main.run();
|
await main.run();
|
||||||
|
|
||||||
|
|
15
dist/cache-save/index.js
vendored
15
dist/cache-save/index.js
vendored
|
@ -59965,7 +59965,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.logWarning = exports.run = void 0;
|
exports.run = void 0;
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const cache = __importStar(__nccwpck_require__(7799));
|
const cache = __importStar(__nccwpck_require__(7799));
|
||||||
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
||||||
|
@ -59984,7 +59984,14 @@ function run() {
|
||||||
yield cachePackages();
|
yield cachePackages();
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(error.message);
|
let message = 'Unknown error!';
|
||||||
|
if (error instanceof Error) {
|
||||||
|
message = error.message;
|
||||||
|
}
|
||||||
|
if (typeof error === 'string') {
|
||||||
|
message = error;
|
||||||
|
}
|
||||||
|
core.setFailed(message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -60001,7 +60008,8 @@ const cachePackages = () => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
const cachePaths = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo);
|
const cachePaths = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo);
|
||||||
const nonExistingPaths = cachePaths.filter(cachePath => !fs_1.default.existsSync(cachePath));
|
const nonExistingPaths = cachePaths.filter(cachePath => !fs_1.default.existsSync(cachePath));
|
||||||
if (nonExistingPaths.length === cachePaths.length) {
|
if (nonExistingPaths.length === cachePaths.length) {
|
||||||
throw new Error(`There are no cache folders on the disk`);
|
core.warning('There are no cache folders on the disk');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (nonExistingPaths.length) {
|
if (nonExistingPaths.length) {
|
||||||
logWarning(`Cache folder path is retrieved but doesn't exist on disk: ${nonExistingPaths.join(', ')}`);
|
logWarning(`Cache folder path is retrieved but doesn't exist on disk: ${nonExistingPaths.join(', ')}`);
|
||||||
|
@ -60020,7 +60028,6 @@ function logWarning(message) {
|
||||||
const warningPrefix = '[warning]';
|
const warningPrefix = '[warning]';
|
||||||
core.info(`${warningPrefix}${message}`);
|
core.info(`${warningPrefix}${message}`);
|
||||||
}
|
}
|
||||||
exports.logWarning = logWarning;
|
|
||||||
run();
|
run();
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,14 @@ export async function run() {
|
||||||
try {
|
try {
|
||||||
await cachePackages();
|
await cachePackages();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
let message = 'Unknown error!';
|
||||||
|
if (error instanceof Error) {
|
||||||
|
message = error.message;
|
||||||
|
}
|
||||||
|
if (typeof error === 'string') {
|
||||||
|
message = error;
|
||||||
|
}
|
||||||
|
core.setFailed(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +47,8 @@ const cachePackages = async () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (nonExistingPaths.length === cachePaths.length) {
|
if (nonExistingPaths.length === cachePaths.length) {
|
||||||
throw new Error(`There are no cache folders on the disk`);
|
core.warning('There are no cache folders on the disk');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nonExistingPaths.length) {
|
if (nonExistingPaths.length) {
|
||||||
|
@ -65,7 +73,7 @@ const cachePackages = async () => {
|
||||||
core.info(`Cache saved with the key: ${primaryKey}`);
|
core.info(`Cache saved with the key: ${primaryKey}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
export function logWarning(message: string): void {
|
function logWarning(message: string): void {
|
||||||
const warningPrefix = '[warning]';
|
const warningPrefix = '[warning]';
|
||||||
core.info(`${warningPrefix}${message}`);
|
core.info(`${warningPrefix}${message}`);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue