cache packages

This commit is contained in:
ruki
2025-01-15 22:50:05 +08:00
Unverified
parent 797cb16346
commit 34c67d4e2d
2 changed files with 9 additions and 12 deletions
+5 -8
View File
@@ -12,9 +12,7 @@ function getBuildCacheKey(): string {
if (!buildCacheKey) {
buildCacheKey = '';
}
return `xmake-build-cache-${buildCacheKey}-${os.arch()}-${os.platform()}-${
process.env.RUNNER_OS ?? 'unknown'
}`;
return `xmake-build-cache-${buildCacheKey}-${os.arch()}-${os.platform()}-${process.env.RUNNER_OS ?? 'unknown'}`;
}
function getBuildCachePath(): string {
@@ -29,7 +27,6 @@ function getBuildCacheFolder(): string {
return '.xmake-build-cache';
}
export async function loadBuildCache(): Promise<void> {
const buildCache = core.getBooleanInput('build-cache');
if (!buildCache) {
@@ -40,8 +37,8 @@ export async function loadBuildCache(): Promise<void> {
core.exportVariable('XMAKE_ACTION_BUILD_CACHE', 'true');
const buildCacheFolder = getBuildCacheFolder();
const buildCacheKey = getBuildCacheKey();
const buildCachePath = getBuildCachePath();
const buildCacheKey = getBuildCacheKey();
const buildCachePath = getBuildCachePath();
if (buildCacheFolder && process.env.GITHUB_WORKSPACE) {
const fullCachePath = path.join(process.env.GITHUB_WORKSPACE, buildCacheFolder);
@@ -68,8 +65,8 @@ export async function saveBuildCache(): Promise<void> {
}
const buildCacheFolder = getBuildCacheFolder();
const buildCacheKey = getBuildCacheKey();
const buildCachePath = getBuildCachePath();
const buildCacheKey = getBuildCacheKey();
const buildCachePath = getBuildCachePath();
if (buildCacheFolder && process.env.GITHUB_WORKSPACE && fsutils.isDir(buildCachePath)) {
const fullCachePath = path.join(process.env.GITHUB_WORKSPACE, buildCacheFolder);
+4 -4
View File
@@ -17,9 +17,9 @@ function getPackageCacheKey(): string {
}`;
}
function getPackageCachePath(): string {
async function getPackageCachePath(): Promise<string> {
let packageCachePath = "";
await exec('xmake', ['l', 'core.package.package.installdir'], (error: Error | null, stdout: string, stderr: string) => {
await exec('xmake l core.package.package.installdir', (error: Error | null, stdout: string, stderr: string) => {
if (error) {
core.info(`exec error: ${error}`);
return;
@@ -42,7 +42,7 @@ export async function loadPackageCache(): Promise<void> {
const packageCacheFolder = getPackageCacheFolder();
const packageCacheKey = getPackageCacheKey();
const packageCachePath = getPackageCachePath();
const packageCachePath = await getPackageCachePath();
if (!packageCachePath || packageCachePath === '') {
return;
}
@@ -73,7 +73,7 @@ export async function savePackageCache(): Promise<void> {
const packageCacheFolder = getPackageCacheFolder();
const packageCacheKey = getPackageCacheKey();
const packageCachePath = getPackageCachePath();
const packageCachePath = await getPackageCachePath();
if (!packageCachePath || packageCachePath === '') {
return;
}