improve cache
This commit is contained in:
+24
-14
@@ -6,30 +6,40 @@ import * as stateHelper from './state-helper';
|
||||
import { winInstall } from './win-install';
|
||||
import { unixInstall } from './unix-install';
|
||||
|
||||
async function cacheBuild(): Promise<void> {}
|
||||
async function installXmake(): Promise<void> {
|
||||
const version = await selectVersion();
|
||||
if (os.platform() === 'win32' || os.platform() === 'cygwin') {
|
||||
const latest = await selectVersion('latest');
|
||||
await winInstall(version, latest);
|
||||
} else {
|
||||
await unixInstall(version);
|
||||
}
|
||||
await exec('xmake --root --version');
|
||||
}
|
||||
|
||||
async function cachePackages(): Promise<void> {}
|
||||
async function loadBuildCache(): Promise<void> {}
|
||||
|
||||
async function loadPackagesCache(): Promise<void> {}
|
||||
|
||||
async function saveBuildCache(): Promise<void> {}
|
||||
|
||||
async function savePackagesCache(): Promise<void> {}
|
||||
|
||||
async function run(): Promise<void> {
|
||||
try {
|
||||
const version = await selectVersion();
|
||||
if (os.platform() === 'win32' || os.platform() === 'cygwin') {
|
||||
const latest = await selectVersion('latest');
|
||||
await winInstall(version, latest);
|
||||
} else {
|
||||
await unixInstall(version);
|
||||
}
|
||||
await exec('xmake --root --version');
|
||||
await installXmake();
|
||||
await loadBuildCache();
|
||||
await loadPackagesCache();
|
||||
} catch (error) {
|
||||
const ex = error as Error;
|
||||
core.setFailed(ex.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function cleanup(): Promise<void> {
|
||||
async function saveCache(): Promise<void> {
|
||||
try {
|
||||
core.info(`cleanup`);
|
||||
await cacheBuild();
|
||||
await saveBuildCache();
|
||||
await savePackagesCache();
|
||||
} catch (error) {
|
||||
const ex = error as Error;
|
||||
core.setFailed(ex.message);
|
||||
@@ -39,5 +49,5 @@ async function cleanup(): Promise<void> {
|
||||
if (!stateHelper.IsPost) {
|
||||
run().catch((e: Error) => core.error(e));
|
||||
} else {
|
||||
cleanup().catch((e: Error) => core.error(e));
|
||||
saveCache().catch((e: Error) => core.error(e));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user