mirror of
https://git.studyfor.work/actions/gitea-tool-cache.git
synced 2026-01-14 01:06:02 +08:00
适配runner 0.2.7
This commit is contained in:
parent
39251b9be0
commit
9034def559
@ -47,33 +47,33 @@ describe('gitea-tool-cache', () => {
|
|||||||
}, 200000);
|
}, 200000);
|
||||||
|
|
||||||
// 测试时需要把别的注释掉
|
// 测试时需要把别的注释掉
|
||||||
// it('installs windows', async () => {
|
it('installs windows', async () => {
|
||||||
// rmSync('./cache', { recursive: true, force: true });
|
// rmSync('./cache', { recursive: true, force: true });
|
||||||
// os['platform'] = 'win32';
|
os['platform'] = 'win32';
|
||||||
// os['arch'] = 'x64';
|
|
||||||
// // node
|
|
||||||
// inputs['node-version'] = '18';
|
|
||||||
// await nodeInstall();
|
|
||||||
// // // go
|
|
||||||
// // inputs['go-version'] = '1.21.1';
|
|
||||||
// // await goInstall();
|
|
||||||
// // dotnet
|
|
||||||
// // inputs['dotnet-version'] = '6.0.100';
|
|
||||||
// // await dotnetInstall();
|
|
||||||
// });
|
|
||||||
|
|
||||||
it('installs linux', async () => {
|
|
||||||
rmSync('./cache', { recursive: true, force: true });
|
|
||||||
os['platform'] = 'linux';
|
|
||||||
os['arch'] = 'x64';
|
os['arch'] = 'x64';
|
||||||
|
// node
|
||||||
inputs['node-version'] = '18';
|
inputs['node-version'] = '18';
|
||||||
await nodeInstall();
|
await nodeInstall();
|
||||||
|
// // go
|
||||||
// inputs['go-version'] = '1.21.1';
|
// inputs['go-version'] = '1.21.1';
|
||||||
// await goInstall();
|
// await goInstall();
|
||||||
// inputs['dotnet-version'] = '5.0.401';
|
// dotnet
|
||||||
|
// inputs['dotnet-version'] = '6.0.100';
|
||||||
// await dotnetInstall();
|
// await dotnetInstall();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// it('installs linux', async () => {
|
||||||
|
// // rmSync('./cache', { recursive: true, force: true });
|
||||||
|
// os['platform'] = 'linux';
|
||||||
|
// os['arch'] = 'x64';
|
||||||
|
// inputs['node-version'] = '18';
|
||||||
|
// await nodeInstall();
|
||||||
|
// inputs['go-version'] = '1.21.1';
|
||||||
|
// await goInstall();
|
||||||
|
// inputs['dotnet-version'] = '5.0.401';
|
||||||
|
// await dotnetInstall();
|
||||||
|
// });
|
||||||
|
|
||||||
// it('installs darwin', async () => {
|
// it('installs darwin', async () => {
|
||||||
// os['platform'] = 'darwin';
|
// os['platform'] = 'darwin';
|
||||||
// os['arch'] = 'x64';
|
// os['arch'] = 'x64';
|
||||||
|
|||||||
@ -1,8 +1,14 @@
|
|||||||
import { join } from 'path';
|
import {
|
||||||
import { downloadTool, extractZip, extractTar, extractXar, cacheDir } from '@actions/tool-cache';
|
downloadTool,
|
||||||
|
extractZip,
|
||||||
|
extractTar,
|
||||||
|
extractXar,
|
||||||
|
cacheDir,
|
||||||
|
find
|
||||||
|
} from '@actions/tool-cache';
|
||||||
import { addPath, getInput, setOutput, info, setFailed, error } from '@actions/core';
|
import { addPath, getInput, setOutput, info, setFailed, error } from '@actions/core';
|
||||||
import { arch, platform as Platform } from 'os';
|
import { arch, platform as Platform } from 'os';
|
||||||
import { existsSync, renameSync } from 'fs';
|
import { renameSync } from 'fs';
|
||||||
import { get } from 'axios';
|
import { get } from 'axios';
|
||||||
|
|
||||||
// 安装dotnet
|
// 安装dotnet
|
||||||
@ -14,15 +20,11 @@ export async function dotnetInstall() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
const dotnetPath = find('dotnet', dotnetVersion, arch());
|
||||||
process.env['RUNNER_TOOL_CACHE'] &&
|
|
||||||
existsSync(join(process.env['RUNNER_TOOL_CACHE'], 'dotnet', dotnetVersion, arch()))
|
if (dotnetPath) {
|
||||||
) {
|
|
||||||
info('dotnet已经安装过了');
|
info('dotnet已经安装过了');
|
||||||
return setOutput(
|
return setOutput('dotnet-path', dotnetPath);
|
||||||
'dotnet-path',
|
|
||||||
join(process.env['RUNNER_TOOL_CACHE'], 'dotnet', dotnetVersion, arch())
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
const versionList = dotnetVersion.split('.');
|
const versionList = dotnetVersion.split('.');
|
||||||
const channelVersion = `${versionList[0]}.${versionList[1]}`;
|
const channelVersion = `${versionList[0]}.${versionList[1]}`;
|
||||||
|
|||||||
@ -1,8 +1,15 @@
|
|||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { downloadTool, extractZip, extractTar, extractXar, cacheDir } from '@actions/tool-cache';
|
import {
|
||||||
|
downloadTool,
|
||||||
|
extractZip,
|
||||||
|
extractTar,
|
||||||
|
extractXar,
|
||||||
|
cacheDir,
|
||||||
|
find
|
||||||
|
} from '@actions/tool-cache';
|
||||||
import { addPath, getInput, info, setFailed } from '@actions/core';
|
import { addPath, getInput, info, setFailed } from '@actions/core';
|
||||||
import { arch, platform as Platform } from 'os';
|
import { arch, platform as Platform } from 'os';
|
||||||
import { existsSync, renameSync } from 'fs';
|
import { renameSync } from 'fs';
|
||||||
|
|
||||||
// 安装golang
|
// 安装golang
|
||||||
export async function goInstall() {
|
export async function goInstall() {
|
||||||
@ -12,12 +19,11 @@ export async function goInstall() {
|
|||||||
info('没有go-version,跳过go安装');
|
info('没有go-version,跳过go安装');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (
|
|
||||||
process.env['RUNNER_TOOL_CACHE'] &&
|
|
||||||
existsSync(join(process.env['RUNNER_TOOL_CACHE'], 'go', goVersion, arch()))
|
|
||||||
) {
|
|
||||||
info('go已经安装过了');
|
|
||||||
|
|
||||||
|
const goPath = find('go', goVersion, arch());
|
||||||
|
|
||||||
|
if (goPath) {
|
||||||
|
info('go已经安装过了');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,15 @@
|
|||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { downloadTool, extractZip, extractTar, extractXar, cacheDir } from '@actions/tool-cache';
|
import {
|
||||||
|
downloadTool,
|
||||||
|
extractZip,
|
||||||
|
extractTar,
|
||||||
|
extractXar,
|
||||||
|
cacheDir,
|
||||||
|
find
|
||||||
|
} from '@actions/tool-cache';
|
||||||
import { addPath, getInput, setOutput, setFailed, info } from '@actions/core';
|
import { addPath, getInput, setOutput, setFailed, info } from '@actions/core';
|
||||||
import { arch, platform as Platform } from 'os';
|
import { arch, platform as Platform } from 'os';
|
||||||
import { existsSync, renameSync } from 'fs';
|
import { renameSync } from 'fs';
|
||||||
import { nodeVersionAlias } from 'gitea-tool-cache-version-alias';
|
import { nodeVersionAlias } from 'gitea-tool-cache-version-alias';
|
||||||
|
|
||||||
// 安装node
|
// 安装node
|
||||||
@ -22,11 +29,9 @@ export async function nodeInstall() {
|
|||||||
setFailed('node版本错误: ' + version);
|
setFailed('node版本错误: ' + version);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const NodePath = find('node', version, arch());
|
||||||
|
|
||||||
if (
|
if (NodePath) {
|
||||||
process.env['RUNNER_TOOL_CACHE'] &&
|
|
||||||
existsSync(join(process.env['RUNNER_TOOL_CACHE'], 'node', version, arch()))
|
|
||||||
) {
|
|
||||||
info('node已经安装过了');
|
info('node已经安装过了');
|
||||||
|
|
||||||
return setOutput('node-version', version);
|
return setOutput('node-version', version);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user