Skip to content

Commit

Permalink
extract julia directly to tool path
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Jan 4, 2024
1 parent 67c6198 commit 672e081
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 33 deletions.
23 changes: 11 additions & 12 deletions lib/installer.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 13 additions & 4 deletions lib/setup-julia.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 11 additions & 13 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> {
export async function installJulia(dest: string, versionInfo, version: string, arch: string): Promise<string> {
// Download Julia
const fileInfo = getFileInfo(versionInfo, version, arch)
const downloadURL = getDownloadURL(fileInfo, version, arch)
Expand Down Expand Up @@ -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`)
Expand Down
19 changes: 15 additions & 4 deletions src/setup-julia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,25 @@ async function run() {

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

// we want julia to be installed with unmodified file mtimes
// but tc.cacheDir uses `cp` which destroys mtime
// and `tc` provides no API to get the tool directory alone
// so hack it by installing a dummy julia file then use the path it returns
// and extract the archives directly to that location
const tempDummyDir = fs.mkdtempSync(`julia-dummy`)
fs.writeFileSync(path.join(tempDummyDir, "julia"), "empty");
const juliaPath = await tc.cacheDir(tempDummyDir, 'julia', version, arch)
fs.rmSync(juliaPath)
const dest = path.dirname(juliaPath)
await installer.installJulia(dest, versionInfo, version, arch)

// Add it to cache
juliaPath = await tc.cacheDir(juliaInstallationPath, 'julia', version, arch)

core.debug(`added Julia to cache: ${juliaPath}`)

// Remove temporary dir
fs.rmSync(juliaInstallationPath, {recursive: true})
// Remove temporary dummy dir
fs.rmSync(tempDummyDir, {recursive: true})
} else {
core.debug(`using cached version of Julia: ${juliaPath}`)
}
Expand Down

0 comments on commit 672e081

Please sign in to comment.