Add tests

This commit is contained in:
OpportunityLiu
2020-03-31 18:38:26 +08:00
Unverified
parent a46e0b8b8a
commit b54ee46fac
24 changed files with 1290 additions and 809 deletions
+31
View File
@@ -0,0 +1,31 @@
import * as core from '@actions/core';
import { exec } from '@actions/exec';
import * as io from '@actions/io';
import * as toolCache from '@actions/tool-cache';
import * as os from 'os';
import * as path from 'path';
import * as semver from 'semver';
import * as git from './git';
import { Version } from './versions';
export async function unixInstall(version: Version): Promise<void> {
let toolDir = toolCache.find('xmake', version.version);
if (!toolDir) {
const sourceDir = await core.group(`download xmake ${version}`, () => git.create(version.sha));
toolDir = await core.group(`install xmake ${version}`, async () => {
await exec('make', ['build'], { cwd: sourceDir });
const binDir = path.join(os.tmpdir(), `xmake-${version.sha}`);
await exec('make', ['install', `prefix=${binDir}`], { cwd: sourceDir });
const cacheDir = await toolCache.cacheDir(binDir, 'xmake', version.version);
await io.rmRF(binDir);
await git.cleanup(version.sha);
return cacheDir;
});
}
// for versions 2.3.2 and above, xmake will be installed directly into the bin directory, and no script will be used to wrap it.
if (version.type !== 'tags' || semver.gt(version.version, '2.3.1')) {
core.addPath(path.join(toolDir, 'bin'));
} else {
core.addPath(path.join(toolDir, 'share', 'xmake')); // only for <= 2.3.1
}
}