extract julia directly to tool path to maintain mtimes (#196)

Co-authored-by: Dilum Aluthge <dilum@aluthge.com>
Co-authored-by: Curtis Vogt <curtis.vogt@gmail.com>
This commit is contained in:
Ian Butterworth
2024-01-05 12:49:05 -05:00
committed by GitHub
parent a46a85f797
commit d3d61d99d5
4 changed files with 45 additions and 35 deletions

16
lib/setup-julia.js generated
View File

@@ -91,12 +91,18 @@ function run() {
juliaPath = tc.find('julia', version, arch);
if (!juliaPath) {
core.debug(`could not find Julia ${arch}/${version} in cache`);
const juliaInstallationPath = yield installer.installJulia(versionInfo, version, arch);
// Add it to cache
juliaPath = yield tc.cacheDir(juliaInstallationPath, 'julia', version, arch);
// https://github.com/julia-actions/setup-julia/pull/196
// we want julia to be installed with unmodified file mtimes
// but `tc.cacheDir` uses `cp` internally which destroys mtime
// and `tc` provides no API to get the tool directory alone
// so hack it by installing a empty directory then use the path it returns
// and extract the archives directly to that location
const emptyDir = fs.mkdtempSync('empty');
juliaPath = yield tc.cacheDir(emptyDir, 'julia', version, arch);
yield installer.installJulia(juliaPath, versionInfo, version, arch);
core.debug(`added Julia to cache: ${juliaPath}`);
// Remove temporary dir
fs.rmSync(juliaInstallationPath, { recursive: true });
// Remove empty dir
fs.rmdirSync(emptyDir);
}
else {
core.debug(`using cached version of Julia: ${juliaPath}`);