@@ -82464,6 +82464,17 @@ const cache = __nccwpck_require__(6878);
82464
82464
const os = __nccwpck_require__(2037);
82465
82465
const path = __nccwpck_require__(1017);
82466
82466
const fsutils = __nccwpck_require__(4295);
82467
+ function getProjectRootPath() {
82468
+ let projectRootPath = core.getInput('project-path');
82469
+ if (!projectRootPath) {
82470
+ projectRootPath = process.cwd();
82471
+ }
82472
+ projectRootPath = projectRootPath.trim();
82473
+ if (projectRootPath && projectRootPath !== '' && !path.isAbsolute(projectRootPath)) {
82474
+ projectRootPath = path.join(process.cwd(), projectRootPath);
82475
+ }
82476
+ return projectRootPath;
82477
+ }
82467
82478
function getBuildCacheKey() {
82468
82479
var _a;
82469
82480
let buildCacheKey = core.getInput('build-cache-key');
@@ -82472,10 +82483,32 @@ function getBuildCacheKey() {
82472
82483
}
82473
82484
return `xmake-build-cache-${buildCacheKey}-${os.arch()}-${os.platform()}-${(_a = process.env.RUNNER_OS) !== null && _a !== void 0 ? _a : 'unknown'}`;
82474
82485
}
82475
- function getBuildCachePath() {
82486
+ async function getBuildCachePath() {
82476
82487
let buildCachePath = core.getInput('build-cache-path');
82477
82488
if (!buildCachePath) {
82478
- buildCachePath = 'build/.build_cache';
82489
+ buildCachePath = '';
82490
+ const projectRootPath = getProjectRootPath();
82491
+ if (projectRootPath && projectRootPath !== '' && fsutils.isDir(projectRootPath)) {
82492
+ const options = {};
82493
+ options.cwd = projectRootPath;
82494
+ options.listeners = {
82495
+ stdout: (data) => {
82496
+ buildCachePath += data.toString();
82497
+ },
82498
+ };
82499
+ await (0, exec_1.exec)('xmake', [
82500
+ 'l',
82501
+ '-c',
82502
+ 'import("core.project.config"); import("private.cache.build_cache"); config.load(); print(build_cache.rootdir())',
82503
+ ], options);
82504
+ buildCachePath = buildCachePath.trim();
82505
+ if (buildCachePath !== '' && !path.isAbsolute(buildCachePath)) {
82506
+ buildCachePath = path.join(projectRootPath, buildCachePath);
82507
+ }
82508
+ }
82509
+ else {
82510
+ buildCachePath = 'build/.build_cache';
82511
+ }
82479
82512
}
82480
82513
return buildCachePath;
82481
82514
}
@@ -82491,7 +82524,7 @@ async function loadBuildCache() {
82491
82524
core.exportVariable('XMAKE_ACTION_BUILD_CACHE', 'true');
82492
82525
const buildCacheFolder = getBuildCacheFolder();
82493
82526
const buildCacheKey = getBuildCacheKey();
82494
- const buildCachePath = getBuildCachePath();
82527
+ const buildCachePath = await getBuildCachePath();
82495
82528
if (buildCacheFolder && process.env.GITHUB_WORKSPACE) {
82496
82529
const fullCachePath = path.join(process.env.GITHUB_WORKSPACE, buildCacheFolder);
82497
82530
const filepath = path.join(fullCachePath, 'build_cache_saved.txt');
@@ -82500,6 +82533,9 @@ async function loadBuildCache() {
82500
82533
await cache.restoreCache([buildCacheFolder], buildCacheKey);
82501
82534
}
82502
82535
if (fsutils.isFile(filepath)) {
82536
+ if (fsutils.isDir(buildCachePath)) {
82537
+ await io.rmRF(buildCachePath);
82538
+ }
82503
82539
await io.cp(fullCachePath, buildCachePath, {
82504
82540
recursive: true,
82505
82541
});
@@ -82518,7 +82554,7 @@ async function saveBuildCache() {
82518
82554
}
82519
82555
const buildCacheFolder = getBuildCacheFolder();
82520
82556
const buildCacheKey = getBuildCacheKey();
82521
- const buildCachePath = getBuildCachePath();
82557
+ const buildCachePath = await getBuildCachePath();
82522
82558
if (buildCacheFolder && process.env.GITHUB_WORKSPACE && fsutils.isDir(buildCachePath)) {
82523
82559
const fullCachePath = path.join(process.env.GITHUB_WORKSPACE, buildCacheFolder);
82524
82560
core.info(`Save build cache path: ${buildCachePath} to ${fullCachePath}, key: ${buildCacheKey}`);
@@ -82706,13 +82742,38 @@ const cache = __nccwpck_require__(6878);
82706
82742
const os = __nccwpck_require__(2037);
82707
82743
const path = __nccwpck_require__(1017);
82708
82744
const fsutils = __nccwpck_require__(4295);
82709
- function getPackageCacheKey() {
82745
+ function getProjectRootPath() {
82746
+ let projectRootPath = core.getInput('project-path');
82747
+ if (!projectRootPath) {
82748
+ projectRootPath = process.cwd();
82749
+ }
82750
+ projectRootPath = projectRootPath.trim();
82751
+ if (projectRootPath && projectRootPath !== '' && !path.isAbsolute(projectRootPath)) {
82752
+ projectRootPath = path.join(process.cwd(), projectRootPath);
82753
+ }
82754
+ return projectRootPath;
82755
+ }
82756
+ async function getPackageCacheKey() {
82710
82757
var _a;
82711
82758
let packageCacheKey = core.getInput('package-cache-key');
82712
82759
if (!packageCacheKey) {
82713
82760
packageCacheKey = '';
82714
82761
}
82715
- return `xmake-package-cache-${packageCacheKey}-${os.arch()}-${os.platform()}-${(_a = process.env.RUNNER_OS) !== null && _a !== void 0 ? _a : 'unknown'}`;
82762
+ let packageCacheHash = '';
82763
+ const projectRootPath = getProjectRootPath();
82764
+ if (projectRootPath && projectRootPath !== '' && fsutils.isDir(projectRootPath)) {
82765
+ const options = {};
82766
+ options.cwd = projectRootPath;
82767
+ options.listeners = {
82768
+ stdout: (data) => {
82769
+ packageCacheHash += data.toString();
82770
+ },
82771
+ };
82772
+ await (0, exec_1.exec)('xmake', ['repo', '--update']);
82773
+ await (0, exec_1.exec)('xmake', ['l', 'utils.ci.packageskey'], options);
82774
+ packageCacheHash = packageCacheHash.trim();
82775
+ }
82776
+ return `xmake-package-cache-${packageCacheKey}-${packageCacheHash}-${os.arch()}-${os.platform()}-${(_a = process.env.RUNNER_OS) !== null && _a !== void 0 ? _a : 'unknown'}`;
82716
82777
}
82717
82778
async function getPackageCachePath() {
82718
82779
let packageCachePath = '';
@@ -82724,7 +82785,6 @@ async function getPackageCachePath() {
82724
82785
};
82725
82786
await (0, exec_1.exec)('xmake', ['l', '-c', 'import("core.package.package"); print(package.installdir())'], options);
82726
82787
packageCachePath = packageCachePath.trim();
82727
- core.info(`packageCachePath: ${packageCachePath}`);
82728
82788
return packageCachePath;
82729
82789
}
82730
82790
function getPackageCacheFolder() {
@@ -82736,7 +82796,7 @@ async function loadPackageCache() {
82736
82796
return;
82737
82797
}
82738
82798
const packageCacheFolder = getPackageCacheFolder();
82739
- const packageCacheKey = getPackageCacheKey();
82799
+ const packageCacheKey = await getPackageCacheKey();
82740
82800
const packageCachePath = await getPackageCachePath();
82741
82801
if (!packageCachePath || packageCachePath === '') {
82742
82802
return;
@@ -82749,9 +82809,13 @@ async function loadPackageCache() {
82749
82809
await cache.restoreCache([packageCacheFolder], packageCacheKey);
82750
82810
}
82751
82811
if (fsutils.isFile(filepath)) {
82812
+ if (fsutils.isDir(packageCachePath)) {
82813
+ await io.rmRF(packageCachePath);
82814
+ }
82752
82815
await io.cp(fullCachePath, packageCachePath, {
82753
82816
recursive: true,
82754
82817
});
82818
+ core.saveState('hitCache', 'true');
82755
82819
}
82756
82820
else {
82757
82821
core.warning(`No cached files found at path "${fullCachePath}".`);
@@ -82766,18 +82830,18 @@ async function savePackageCache() {
82766
82830
return;
82767
82831
}
82768
82832
const packageCacheFolder = getPackageCacheFolder();
82769
- const packageCacheKey = getPackageCacheKey();
82833
+ const packageCacheKey = await getPackageCacheKey();
82770
82834
const packageCachePath = await getPackageCachePath();
82771
82835
if (!packageCachePath || packageCachePath === '') {
82772
82836
return;
82773
82837
}
82774
- if (packageCacheFolder && process.env.GITHUB_WORKSPACE && fsutils.isDir(packageCachePath)) {
82838
+ const hitCache = !!core.getState('hitCache');
82839
+ if (!hitCache && packageCacheFolder && process.env.GITHUB_WORKSPACE && fsutils.isDir(packageCachePath)) {
82775
82840
const fullCachePath = path.join(process.env.GITHUB_WORKSPACE, packageCacheFolder);
82776
82841
core.info(`Save package cache path: ${packageCachePath} to ${fullCachePath}, key: ${packageCacheKey}`);
82777
82842
await io.cp(packageCachePath, fullCachePath, {
82778
82843
recursive: true,
82779
82844
});
82780
- await (0, exec_1.exec)('xmake', ['l', 'os.touch', path.join(fullCachePath, 'package_cache_saved.txt')]);
82781
82845
await cache.saveCache([packageCacheFolder], packageCacheKey);
82782
82846
}
82783
82847
}
@@ -82792,28 +82856,12 @@ exports.savePackageCache = savePackageCache;
82792
82856
"use strict";
82793
82857
82794
82858
Object.defineProperty(exports, "__esModule", ({ value: true }));
82795
- exports.SshKnownHostsPath = exports.SshKeyPath = exports.PostSetSafeDirectory = exports.RepositoryPath = exports. IsPost = void 0;
82859
+ exports.IsPost = void 0;
82796
82860
const core = __nccwpck_require__(9093);
82797
82861
/**
82798
82862
* Indicates whether the POST action is running
82799
82863
*/
82800
82864
exports.IsPost = !!core.getState('isPost');
82801
- /**
82802
- * The repository path for the POST action. The value is empty during the MAIN action.
82803
- */
82804
- exports.RepositoryPath = core.getState('repositoryPath');
82805
- /**
82806
- * The set-safe-directory for the POST action. The value is set if input: 'safe-directory' is set during the MAIN action.
82807
- */
82808
- exports.PostSetSafeDirectory = core.getState('setSafeDirectory') === 'true';
82809
- /**
82810
- * The SSH key path for the POST action. The value is empty during the MAIN action.
82811
- */
82812
- exports.SshKeyPath = core.getState('sshKeyPath');
82813
- /**
82814
- * The SSH known hosts path for the POST action. The value is empty during the MAIN action.
82815
- */
82816
- exports.SshKnownHostsPath = core.getState('sshKnownHostsPath');
82817
82865
// Publish a variable so that when the POST action runs, it can determine it should run the cleanup logic.
82818
82866
// This is necessary since we don't have a separate entry point.
82819
82867
if (!exports.IsPost) {
0 commit comments