Skip to content

Commit

Permalink
Handle install directories using tool-cache (#46)
Browse files Browse the repository at this point in the history
* Make test builds more verbose

* Handle install directories using tool-cache

* Bump version to 1.3.0-DEV
  • Loading branch information
SaschaMann authored Sep 26, 2020
1 parent b469b93 commit c639390
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 22 deletions.
1 change: 1 addition & 0 deletions .github/workflows/example-builds-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ jobs:
with:
version: nightly
arch: ${{ matrix.julia-arch }}
show-versioninfo: 'true'
- run: julia --version
2 changes: 2 additions & 0 deletions .github/workflows/example-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ jobs:
npm run pack
- name: "Set up Julia"
id: setup-julia
uses: ./
with:
version: ${{ matrix.julia-version }}
arch: ${{ matrix.julia-arch }}
show-versioninfo: 'true'
- run: julia --version
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ inputs:
description: 'Display InteractiveUtils.versioninfo() after installing'
required: false
default: 'false'
outputs:
julia-bindir:
description: 'Path to the directory containing the Julia executable. Equivalent to JULIA_BINDIR: https://docs.julialang.org/en/v1/manual/environment-variables/#JULIA_BINDIR'
runs:
using: 'node12'
main: 'dist/index.js'
Expand Down
19 changes: 9 additions & 10 deletions lib/installer.js

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

5 changes: 5 additions & 0 deletions lib/setup-julia.js

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

2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "setup-julia",
"version": "1.2.2",
"version": "1.3.0-DEV",
"private": true,
"description": "setup Julia action",
"main": "lib/setup-julia.js",
Expand Down
20 changes: 10 additions & 10 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as core from '@actions/core'
import * as exec from '@actions/exec'
import * as tc from '@actions/tool-cache'

import * as fs from 'fs'
import * as os from 'os'
import * as path from 'path'

Expand Down Expand Up @@ -102,27 +103,26 @@ export async function installJulia(version: string, arch: string): Promise<strin
core.debug(`downloading Julia from ${downloadURL}`)
const juliaDownloadPath = await tc.downloadTool(downloadURL)

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('mkdir', [`${process.env.HOME}/julia`])
await exec.exec('tar', ['xf', juliaDownloadPath, '--strip-components=1', '-C', `${process.env.HOME}/julia`])
return `${process.env.HOME}/julia`
await exec.exec('tar', ['xf', juliaDownloadPath, '--strip-components=1', '-C', tempInstallDir])
return tempInstallDir
case 'win32':
const juliaInstallationPath = path.join('C:', 'Julia')
if (version == '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=${juliaInstallationPath}" -NoNewWindow -Wait`])
await exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/SILENT /dir=${path.join(process.cwd(), tempInstallDir)}" -NoNewWindow -Wait`])
} else {
await exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/S /D=${juliaInstallationPath}" -NoNewWindow -Wait`])
await exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/S /D=${path.join(process.cwd(), tempInstallDir)}" -NoNewWindow -Wait`])
}
return juliaInstallationPath
return tempInstallDir
case 'darwin':
await exec.exec('hdiutil', ['attach', juliaDownloadPath])
await exec.exec('mkdir', [`${process.env.HOME}/julia`])
await exec.exec('/bin/bash', ['-c', `cp -a /Volumes/Julia-*/Julia-*.app/Contents/Resources/julia ${process.env.HOME}`])
return `${process.env.HOME}/julia`
await exec.exec('/bin/bash', ['-c', `cp -a /Volumes/Julia-*/Julia-*.app/Contents/Resources/julia ${tempInstallDir}`])
return path.join(tempInstallDir, 'julia')
default:
throw new Error(`Platform ${osPlat} is not supported`)
}
Expand Down
7 changes: 7 additions & 0 deletions src/setup-julia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as core from '@actions/core'
import * as exec from '@actions/exec'
import * as tc from '@actions/tool-cache'

import * as fs from 'fs'
import * as https from 'https'
import * as path from 'path'

Expand Down Expand Up @@ -58,12 +59,18 @@ async function run() {
// Add it to cache
juliaPath = await tc.cacheDir(juliaInstallationPath, 'julia', version, arch)
core.debug(`added Julia to cache: ${juliaPath}`)

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

// Add it to PATH
core.addPath(path.join(juliaPath, 'bin'))

// Set output
core.setOutput('julia-bindir', path.join(juliaPath, 'bin'))

// Test if Julia has been installed
exec.exec('julia', ['--version'])
Expand Down

0 comments on commit c639390

Please sign in to comment.