Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extract julia directly to tool path to maintain mtimes #196

Merged
merged 18 commits into from Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.

16 changes: 11 additions & 5 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
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
17 changes: 12 additions & 5 deletions src/setup-julia.ts
Expand Up @@ -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
IanButterworth marked this conversation as resolved.
Show resolved Hide resolved
// 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}`)
}
Expand Down