Skip to content

Commit d3d61d9

Browse files
IanButterworthDilumAluthgeomus
authored
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>
1 parent a46a85f commit d3d61d9

File tree

4 files changed

+45
-35
lines changed

4 files changed

+45
-35
lines changed

lib/installer.js

+11-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/setup-julia.js

+11-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/installer.ts

+11-13
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export function getDownloadURL(fileInfo, version: string, arch: string): string
198198
return fileInfo.url
199199
}
200200

201-
export async function installJulia(versionInfo, version: string, arch: string): Promise<string> {
201+
export async function installJulia(dest: string, versionInfo, version: string, arch: string): Promise<string> {
202202
// Download Julia
203203
const fileInfo = getFileInfo(versionInfo, version, arch)
204204
const downloadURL = getDownloadURL(fileInfo, version, arch)
@@ -226,37 +226,35 @@ export async function installJulia(versionInfo, version: string, arch: string):
226226
core.debug('Skipping checksum check for nightly binaries.')
227227
}
228228

229-
const tempInstallDir = fs.mkdtempSync(`julia-${arch}-${version}-`)
230-
231229
// Install it
232230
switch (osPlat) {
233231
case 'linux':
234232
// tc.extractTar doesn't support stripping components, so we have to call tar manually
235-
await exec.exec('tar', ['xf', juliaDownloadPath, '--strip-components=1', '-C', tempInstallDir])
236-
return tempInstallDir
233+
await exec.exec('tar', ['xf', juliaDownloadPath, '--strip-components=1', '-C', dest])
234+
return dest
237235
case 'win32':
238236
if (fileInfo !== null && fileInfo.extension == 'exe') {
239237
if (version.endsWith('nightly') || semver.gtr(version, '1.3', {includePrerelease: true})) {
240238
// The installer changed in 1.4: https://github.com/JuliaLang/julia/blob/ef0c9108b12f3ae177c51037934351ffa703b0b5/NEWS.md#build-system-changes
241-
await exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/SILENT /dir=${path.join(process.cwd(), tempInstallDir)}" -NoNewWindow -Wait`])
239+
await exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/SILENT /dir=${path.join(process.cwd(), dest)}" -NoNewWindow -Wait`])
242240
} else {
243-
await exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/S /D=${path.join(process.cwd(), tempInstallDir)}" -NoNewWindow -Wait`])
241+
await exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/S /D=${path.join(process.cwd(), dest)}" -NoNewWindow -Wait`])
244242
}
245243
} else {
246244
// This is the more common path. Using .tar.gz is much faster
247-
await exec.exec('powershell', ['-Command', `tar xf ${juliaDownloadPath} --strip-components=1 -C ${tempInstallDir}`])
245+
await exec.exec('powershell', ['-Command', `tar xf ${juliaDownloadPath} --strip-components=1 -C ${dest}`])
248246
}
249-
return tempInstallDir
247+
return dest
250248
case 'darwin':
251249
if (fileInfo !== null && fileInfo.extension == 'dmg') {
252250
core.debug(`Support for .dmg files is deprecated and may be removed in a future release`)
253251
await exec.exec('hdiutil', ['attach', juliaDownloadPath])
254-
await exec.exec('/bin/bash', ['-c', `cp -a /Volumes/Julia-*/Julia-*.app/Contents/Resources/julia ${tempInstallDir}`])
255-
return path.join(tempInstallDir, 'julia')
252+
await exec.exec('/bin/bash', ['-c', `cp -a /Volumes/Julia-*/Julia-*.app/Contents/Resources/julia ${dest}`])
253+
return path.join(dest, 'julia')
256254
} else {
257255
// tc.extractTar doesn't support stripping components, so we have to call tar manually
258-
await exec.exec('tar', ['xf', juliaDownloadPath, '--strip-components=1', '-C', tempInstallDir])
259-
return tempInstallDir
256+
await exec.exec('tar', ['xf', juliaDownloadPath, '--strip-components=1', '-C', dest])
257+
return dest
260258
}
261259
default:
262260
throw new Error(`Platform ${osPlat} is not supported`)

src/setup-julia.ts

+12-5
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,21 @@ async function run() {
6969

7070
if (!juliaPath) {
7171
core.debug(`could not find Julia ${arch}/${version} in cache`)
72-
const juliaInstallationPath = await installer.installJulia(versionInfo, version, arch)
7372

74-
// Add it to cache
75-
juliaPath = await tc.cacheDir(juliaInstallationPath, 'julia', version, arch)
73+
// https://github.com/julia-actions/setup-julia/pull/196
74+
// we want julia to be installed with unmodified file mtimes
75+
// but `tc.cacheDir` uses `cp` internally which destroys mtime
76+
// and `tc` provides no API to get the tool directory alone
77+
// so hack it by installing a empty directory then use the path it returns
78+
// and extract the archives directly to that location
79+
const emptyDir = fs.mkdtempSync('empty')
80+
juliaPath = await tc.cacheDir(emptyDir, 'julia', version, arch)
81+
await installer.installJulia(juliaPath, versionInfo, version, arch)
82+
7683
core.debug(`added Julia to cache: ${juliaPath}`)
7784

78-
// Remove temporary dir
79-
fs.rmSync(juliaInstallationPath, {recursive: true})
85+
// Remove empty dir
86+
fs.rmdirSync(emptyDir)
8087
} else {
8188
core.debug(`using cached version of Julia: ${juliaPath}`)
8289
}

0 commit comments

Comments
 (0)