diff --git a/lib/installer.js b/lib/installer.js index 47f62784..f1aba02b 100644 --- a/lib/installer.js +++ b/lib/installer.js @@ -216,7 +216,7 @@ function getDownloadURL(fileInfo, version, arch) { return fileInfo.url; } exports.getDownloadURL = getDownloadURL; -function installJulia(versionInfo, version, arch) { +function installJulia(dest, versionInfo, version, arch) { return __awaiter(this, void 0, void 0, function* () { // Download Julia const fileInfo = getFileInfo(versionInfo, version, arch); @@ -243,39 +243,38 @@ function installJulia(versionInfo, version, arch) { else { core.debug('Skipping checksum check for nightly binaries.'); } - const tempInstallDir = fs.mkdtempSync(`julia-${arch}-${version}-`); // Install it switch (osPlat) { case 'linux': // tc.extractTar doesn't support stripping components, so we have to call tar manually - yield exec.exec('tar', ['xf', juliaDownloadPath, '--strip-components=1', '-C', tempInstallDir]); - return tempInstallDir; + yield exec.exec('tar', ['xf', juliaDownloadPath, '--strip-components=1', '-C', dest]); + return dest; case 'win32': if (fileInfo !== null && fileInfo.extension == 'exe') { if (version.endsWith('nightly') || semver.gtr(version, '1.3', { includePrerelease: true })) { // The installer changed in 1.4: https://github.com/JuliaLang/julia/blob/ef0c9108b12f3ae177c51037934351ffa703b0b5/NEWS.md#build-system-changes - yield exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/SILENT /dir=${path.join(process.cwd(), tempInstallDir)}" -NoNewWindow -Wait`]); + yield exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/SILENT /dir=${path.join(process.cwd(), dest)}" -NoNewWindow -Wait`]); } else { - yield exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/S /D=${path.join(process.cwd(), tempInstallDir)}" -NoNewWindow -Wait`]); + yield exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/S /D=${path.join(process.cwd(), dest)}" -NoNewWindow -Wait`]); } } else { // This is the more common path. Using .tar.gz is much faster - yield exec.exec('powershell', ['-Command', `tar xf ${juliaDownloadPath} --strip-components=1 -C ${tempInstallDir}`]); + yield exec.exec('powershell', ['-Command', `tar xf ${juliaDownloadPath} --strip-components=1 -C ${dest}`]); } - return tempInstallDir; + return dest; case 'darwin': if (fileInfo !== null && fileInfo.extension == 'dmg') { core.debug(`Support for .dmg files is deprecated and may be removed in a future release`); yield exec.exec('hdiutil', ['attach', juliaDownloadPath]); - yield exec.exec('/bin/bash', ['-c', `cp -a /Volumes/Julia-*/Julia-*.app/Contents/Resources/julia ${tempInstallDir}`]); - return path.join(tempInstallDir, 'julia'); + yield exec.exec('/bin/bash', ['-c', `cp -a /Volumes/Julia-*/Julia-*.app/Contents/Resources/julia ${dest}`]); + return path.join(dest, 'julia'); } else { // tc.extractTar doesn't support stripping components, so we have to call tar manually - yield exec.exec('tar', ['xf', juliaDownloadPath, '--strip-components=1', '-C', tempInstallDir]); - return tempInstallDir; + yield exec.exec('tar', ['xf', juliaDownloadPath, '--strip-components=1', '-C', dest]); + return dest; } default: throw new Error(`Platform ${osPlat} is not supported`); diff --git a/lib/setup-julia.js b/lib/setup-julia.js index eb81dfa3..2b967b3b 100644 --- a/lib/setup-julia.js +++ b/lib/setup-julia.js @@ -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}`); diff --git a/src/installer.ts b/src/installer.ts index 83756d51..25aede59 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -198,7 +198,7 @@ export function getDownloadURL(fileInfo, version: string, arch: string): string return fileInfo.url } -export async function installJulia(versionInfo, version: string, arch: string): Promise { +export async function installJulia(dest: string, versionInfo, version: string, arch: string): Promise { // Download Julia const fileInfo = getFileInfo(versionInfo, version, arch) const downloadURL = getDownloadURL(fileInfo, version, arch) @@ -226,37 +226,35 @@ export async function installJulia(versionInfo, version: string, arch: string): core.debug('Skipping checksum check for nightly binaries.') } - const tempInstallDir = fs.mkdtempSync(`julia-${arch}-${version}-`) - // Install it switch (osPlat) { case 'linux': // tc.extractTar doesn't support stripping components, so we have to call tar manually - await exec.exec('tar', ['xf', juliaDownloadPath, '--strip-components=1', '-C', tempInstallDir]) - return tempInstallDir + await exec.exec('tar', ['xf', juliaDownloadPath, '--strip-components=1', '-C', dest]) + return dest case 'win32': if (fileInfo !== null && fileInfo.extension == 'exe') { if (version.endsWith('nightly') || semver.gtr(version, '1.3', {includePrerelease: true})) { // The installer changed in 1.4: https://github.com/JuliaLang/julia/blob/ef0c9108b12f3ae177c51037934351ffa703b0b5/NEWS.md#build-system-changes - await exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/SILENT /dir=${path.join(process.cwd(), tempInstallDir)}" -NoNewWindow -Wait`]) + await exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/SILENT /dir=${path.join(process.cwd(), dest)}" -NoNewWindow -Wait`]) } else { - await exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/S /D=${path.join(process.cwd(), tempInstallDir)}" -NoNewWindow -Wait`]) + await exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/S /D=${path.join(process.cwd(), dest)}" -NoNewWindow -Wait`]) } } else { // This is the more common path. Using .tar.gz is much faster - await exec.exec('powershell', ['-Command', `tar xf ${juliaDownloadPath} --strip-components=1 -C ${tempInstallDir}`]) + await exec.exec('powershell', ['-Command', `tar xf ${juliaDownloadPath} --strip-components=1 -C ${dest}`]) } - return tempInstallDir + return dest case 'darwin': if (fileInfo !== null && fileInfo.extension == 'dmg') { core.debug(`Support for .dmg files is deprecated and may be removed in a future release`) await exec.exec('hdiutil', ['attach', juliaDownloadPath]) - await exec.exec('/bin/bash', ['-c', `cp -a /Volumes/Julia-*/Julia-*.app/Contents/Resources/julia ${tempInstallDir}`]) - return path.join(tempInstallDir, 'julia') + await exec.exec('/bin/bash', ['-c', `cp -a /Volumes/Julia-*/Julia-*.app/Contents/Resources/julia ${dest}`]) + return path.join(dest, 'julia') } else { // tc.extractTar doesn't support stripping components, so we have to call tar manually - await exec.exec('tar', ['xf', juliaDownloadPath, '--strip-components=1', '-C', tempInstallDir]) - return tempInstallDir + await exec.exec('tar', ['xf', juliaDownloadPath, '--strip-components=1', '-C', dest]) + return dest } default: throw new Error(`Platform ${osPlat} is not supported`) diff --git a/src/setup-julia.ts b/src/setup-julia.ts index 9982df38..1f309232 100644 --- a/src/setup-julia.ts +++ b/src/setup-julia.ts @@ -69,14 +69,21 @@ async function run() { if (!juliaPath) { core.debug(`could not find Julia ${arch}/${version} in cache`) - const juliaInstallationPath = await installer.installJulia(versionInfo, version, arch) - // Add it to cache - juliaPath = await 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 = await tc.cacheDir(emptyDir, 'julia', version, arch) + await 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}`) }