improve cache

This commit is contained in:
ruki
2025-01-14 22:59:15 +08:00
Unverified
parent 062033bdfe
commit 0e6e37e867
4 changed files with 48 additions and 30 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ jobs:
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
- uses: xmake-io/github-action-setup-xmake@test - uses: xmake-io/github-action-setup-xmake@cache
with: with:
xmake-version: ${{ matrix.version }} xmake-version: ${{ matrix.version }}
actions-cache-folder: '.xmake-cache' actions-cache-folder: '.xmake-cache'
+1
View File
@@ -32,3 +32,4 @@ inputs:
runs: runs:
using: 'node20' using: 'node20'
main: 'dist/index.js' main: 'dist/index.js'
post: 'dist/index.js'
+15 -8
View File
@@ -87473,10 +87473,7 @@ const versions_1 = __nccwpck_require__(406);
const stateHelper = __nccwpck_require__(8387); const stateHelper = __nccwpck_require__(8387);
const win_install_1 = __nccwpck_require__(1612); const win_install_1 = __nccwpck_require__(1612);
const unix_install_1 = __nccwpck_require__(6689); const unix_install_1 = __nccwpck_require__(6689);
async function cacheBuild() { } async function installXmake() {
async function cachePackages() { }
async function run() {
try {
const version = await (0, versions_1.selectVersion)(); const version = await (0, versions_1.selectVersion)();
if (os.platform() === 'win32' || os.platform() === 'cygwin') { if (os.platform() === 'win32' || os.platform() === 'cygwin') {
const latest = await (0, versions_1.selectVersion)('latest'); const latest = await (0, versions_1.selectVersion)('latest');
@@ -87486,16 +87483,26 @@ async function run() {
await (0, unix_install_1.unixInstall)(version); await (0, unix_install_1.unixInstall)(version);
} }
await (0, exec_1.exec)('xmake --root --version'); await (0, exec_1.exec)('xmake --root --version');
}
async function loadBuildCache() { }
async function loadPackagesCache() { }
async function saveBuildCache() { }
async function savePackagesCache() { }
async function run() {
try {
await installXmake();
await loadBuildCache();
await loadPackagesCache();
} }
catch (error) { catch (error) {
const ex = error; const ex = error;
core.setFailed(ex.message); core.setFailed(ex.message);
} }
} }
async function cleanup() { async function saveCache() {
try { try {
core.info(`cleanup`); await saveBuildCache();
await cacheBuild(); await savePackagesCache();
} }
catch (error) { catch (error) {
const ex = error; const ex = error;
@@ -87506,7 +87513,7 @@ if (!stateHelper.IsPost) {
run().catch((e) => core.error(e)); run().catch((e) => core.error(e));
} }
else { else {
cleanup().catch((e) => core.error(e)); saveCache().catch((e) => core.error(e));
} }
})(); })();
+20 -10
View File
@@ -6,12 +6,7 @@ import * as stateHelper from './state-helper';
import { winInstall } from './win-install'; import { winInstall } from './win-install';
import { unixInstall } from './unix-install'; import { unixInstall } from './unix-install';
async function cacheBuild(): Promise<void> {} async function installXmake(): Promise<void> {
async function cachePackages(): Promise<void> {}
async function run(): Promise<void> {
try {
const version = await selectVersion(); const version = await selectVersion();
if (os.platform() === 'win32' || os.platform() === 'cygwin') { if (os.platform() === 'win32' || os.platform() === 'cygwin') {
const latest = await selectVersion('latest'); const latest = await selectVersion('latest');
@@ -20,16 +15,31 @@ async function run(): Promise<void> {
await unixInstall(version); await unixInstall(version);
} }
await exec('xmake --root --version'); await exec('xmake --root --version');
}
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 {
await installXmake();
await loadBuildCache();
await loadPackagesCache();
} catch (error) { } catch (error) {
const ex = error as Error; const ex = error as Error;
core.setFailed(ex.message); core.setFailed(ex.message);
} }
} }
async function cleanup(): Promise<void> { async function saveCache(): Promise<void> {
try { try {
core.info(`cleanup`); await saveBuildCache();
await cacheBuild(); await savePackagesCache();
} catch (error) { } catch (error) {
const ex = error as Error; const ex = error as Error;
core.setFailed(ex.message); core.setFailed(ex.message);
@@ -39,5 +49,5 @@ async function cleanup(): Promise<void> {
if (!stateHelper.IsPost) { if (!stateHelper.IsPost) {
run().catch((e: Error) => core.error(e)); run().catch((e: Error) => core.error(e));
} else { } else {
cleanup().catch((e: Error) => core.error(e)); saveCache().catch((e: Error) => core.error(e));
} }