适配runner 0.2.7

This commit is contained in:
空巷一人 2024-03-27 16:13:38 +08:00
parent 39251b9be0
commit 9034def559
4 changed files with 56 additions and 43 deletions

View File

@ -47,32 +47,32 @@ describe('gitea-tool-cache', () => {
}, 200000);
// 测试时需要把别的注释掉
// it('installs windows', async () => {
it('installs windows', async () => {
// rmSync('./cache', { recursive: true, force: true });
// 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['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';
// 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 () => {
// os['platform'] = 'darwin';

View File

@ -1,8 +1,14 @@
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, info, setFailed, error } from '@actions/core';
import { arch, platform as Platform } from 'os';
import { existsSync, renameSync } from 'fs';
import { renameSync } from 'fs';
import { get } from 'axios';
// 安装dotnet
@ -14,15 +20,11 @@ export async function dotnetInstall() {
return;
}
if (
process.env['RUNNER_TOOL_CACHE'] &&
existsSync(join(process.env['RUNNER_TOOL_CACHE'], 'dotnet', dotnetVersion, arch()))
) {
const dotnetPath = find('dotnet', dotnetVersion, arch());
if (dotnetPath) {
info('dotnet已经安装过了');
return setOutput(
'dotnet-path',
join(process.env['RUNNER_TOOL_CACHE'], 'dotnet', dotnetVersion, arch())
);
return setOutput('dotnet-path', dotnetPath);
}
const versionList = dotnetVersion.split('.');
const channelVersion = `${versionList[0]}.${versionList[1]}`;

View File

@ -1,8 +1,15 @@
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 { arch, platform as Platform } from 'os';
import { existsSync, renameSync } from 'fs';
import { renameSync } from 'fs';
// 安装golang
export async function goInstall() {
@ -12,12 +19,11 @@ export async function goInstall() {
info('没有go-version,跳过go安装');
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;
}

View File

@ -1,8 +1,15 @@
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 { arch, platform as Platform } from 'os';
import { existsSync, renameSync } from 'fs';
import { renameSync } from 'fs';
import { nodeVersionAlias } from 'gitea-tool-cache-version-alias';
// 安装node
@ -22,11 +29,9 @@ export async function nodeInstall() {
setFailed('node版本错误: ' + version);
return;
}
const NodePath = find('node', version, arch());
if (
process.env['RUNNER_TOOL_CACHE'] &&
existsSync(join(process.env['RUNNER_TOOL_CACHE'], 'node', version, arch()))
) {
if (NodePath) {
info('node已经安装过了');
return setOutput('node-version', version);