cache packages
This commit is contained in:
Vendored
+87747
File diff suppressed because one or more lines are too long
+15
-17
@@ -1,5 +1,5 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import { exec } from '@actions/exec';
|
import { exec, ExecOptions } from '@actions/exec';
|
||||||
import * as io from '@actions/io';
|
import * as io from '@actions/io';
|
||||||
import * as cache from '@actions/cache';
|
import * as cache from '@actions/cache';
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
@@ -12,20 +12,19 @@ function getPackageCacheKey(): string {
|
|||||||
if (!packageCacheKey) {
|
if (!packageCacheKey) {
|
||||||
packageCacheKey = '';
|
packageCacheKey = '';
|
||||||
}
|
}
|
||||||
return `xmake-package-cache-${packageCacheKey}-${os.arch()}-${os.platform()}-${
|
return `xmake-package-cache-${packageCacheKey}-${os.arch()}-${os.platform()}-${process.env.RUNNER_OS ?? 'unknown'}`;
|
||||||
process.env.RUNNER_OS ?? 'unknown'
|
|
||||||
}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getPackageCachePath(): Promise<string> {
|
async function getPackageCachePath(): Promise<string> {
|
||||||
let packageCachePath = "";
|
let packageCachePath = '';
|
||||||
await exec('xmake l core.package.package.installdir', (error: Error | null, stdout: string, stderr: string) => {
|
const options: ExecOptions = {};
|
||||||
if (error) {
|
options.listeners = {
|
||||||
core.info(`exec error: ${error}`);
|
stdout: (data: Buffer) => {
|
||||||
return;
|
packageCachePath += data.toString();
|
||||||
}
|
},
|
||||||
packageCachePath = stdout;
|
stderr: (data: Buffer) => {},
|
||||||
});
|
};
|
||||||
|
await exec('xmake', ['l', 'core.package.package.installdir'], options);
|
||||||
core.info(`packageCachePath: ${packageCachePath}`);
|
core.info(`packageCachePath: ${packageCachePath}`);
|
||||||
return packageCachePath;
|
return packageCachePath;
|
||||||
}
|
}
|
||||||
@@ -41,8 +40,8 @@ export async function loadPackageCache(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const packageCacheFolder = getPackageCacheFolder();
|
const packageCacheFolder = getPackageCacheFolder();
|
||||||
const packageCacheKey = getPackageCacheKey();
|
const packageCacheKey = getPackageCacheKey();
|
||||||
const packageCachePath = await getPackageCachePath();
|
const packageCachePath = await getPackageCachePath();
|
||||||
if (!packageCachePath || packageCachePath === '') {
|
if (!packageCachePath || packageCachePath === '') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -72,8 +71,8 @@ export async function savePackageCache(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const packageCacheFolder = getPackageCacheFolder();
|
const packageCacheFolder = getPackageCacheFolder();
|
||||||
const packageCacheKey = getPackageCacheKey();
|
const packageCacheKey = getPackageCacheKey();
|
||||||
const packageCachePath = await getPackageCachePath();
|
const packageCachePath = await getPackageCachePath();
|
||||||
if (!packageCachePath || packageCachePath === '') {
|
if (!packageCachePath || packageCachePath === '') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -88,4 +87,3 @@ export async function savePackageCache(): Promise<void> {
|
|||||||
await cache.saveCache([packageCacheFolder], packageCacheKey);
|
await cache.saveCache([packageCacheFolder], packageCacheKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user