Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const core = __importStar(__nccwpck_require__(7484));
const io = __importStar(__nccwpck_require__(4994));
const tc = __importStar(__nccwpck_require__(3472));
const fs = __importStar(__nccwpck_require__(9896));
const https = __importStar(__nccwpck_require__(5692));
Expand Down Expand Up @@ -653,6 +654,17 @@ function run() {
// Search in cache
let juliaPath;
juliaPath = tc.find('julia', version, arch);
// tc.find only checks for the .complete marker; the marker can be present
// while the directory is empty/partial because tc.cacheDir is called with
// an empty dir BEFORE installJulia extracts into it (see PR196 hack below).
// Validate the cached entry by checking the binary file exists.
if (juliaPath) {
const cachedJuliaBin = path.join(juliaPath, 'bin', os.platform() == 'win32' ? 'julia.exe' : 'julia');
if (!fs.existsSync(cachedJuliaBin)) {
core.warning(`Cached Julia ${arch}/${version} at ${juliaPath} is incomplete (missing ${cachedJuliaBin}); reinstalling.`);
juliaPath = '';
}
}
if (!juliaPath) {
core.debug(`could not find Julia ${arch}/${version} in cache`);
// https://github.com/julia-actions/setup-julia/pull/196
Expand All @@ -672,9 +684,22 @@ function run() {
core.debug(`using cached version of Julia: ${juliaPath}`);
}
// Add it to PATH
core.addPath(path.join(juliaPath, 'bin'));
const juliaBindir = path.join(juliaPath, 'bin');
core.addPath(juliaBindir);
// Verify that PATH lookup of `julia` resolves to the binary we just installed.
// On self-hosted runners other Julia entries (e.g. juliaup launcher in
// ~/.juliaup/bin) can shadow the toolcache binary depending on PATH state.
const resolvedJulia = yield io.which('julia', true);
const expectedJulia = path.join(juliaBindir, os.platform() == 'win32' ? 'julia.exe' : 'julia');
const norm = (p) => {
const resolved = path.resolve(fs.realpathSync(p));
return os.platform() == 'win32' ? resolved.toLowerCase() : resolved;
};
if (norm(resolvedJulia) !== norm(expectedJulia)) {
core.warning(`PATH lookup of \`julia\` resolves to ${resolvedJulia}, not the installed binary at ${expectedJulia}. Another Julia in PATH is shadowing setup-julia's install; fix the runner's PATH (e.g. remove or reorder \`~/.juliaup/bin\`).`);
}
// Set output
core.setOutput('julia-bindir', path.join(juliaPath, 'bin'));
core.setOutput('julia-bindir', juliaBindir);
// Test if Julia has been installed and print the version
const showVersionInfoInput = core.getInput('show-versioninfo');
yield installer.showVersionInfo(showVersionInfoInput, version);
Expand Down
29 changes: 27 additions & 2 deletions lib/setup-julia.js

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

31 changes: 29 additions & 2 deletions src/setup-julia.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as core from '@actions/core'
import * as io from '@actions/io'
import * as tc from '@actions/tool-cache'

import * as fs from 'fs'
Expand Down Expand Up @@ -102,6 +103,18 @@ async function run() {
let juliaPath: string;
juliaPath = tc.find('julia', version, arch)

// tc.find only checks for the .complete marker; the marker can be present
// while the directory is empty/partial because tc.cacheDir is called with
// an empty dir BEFORE installJulia extracts into it (see PR196 hack below).
// Validate the cached entry by checking the binary file exists.
if (juliaPath) {
const cachedJuliaBin = path.join(juliaPath, 'bin', os.platform() == 'win32' ? 'julia.exe' : 'julia')
if (!fs.existsSync(cachedJuliaBin)) {
core.warning(`Cached Julia ${arch}/${version} at ${juliaPath} is incomplete (missing ${cachedJuliaBin}); reinstalling.`)
juliaPath = ''
}
}

if (!juliaPath) {
core.debug(`could not find Julia ${arch}/${version} in cache`)

Expand All @@ -124,10 +137,24 @@ async function run() {
}

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

// Verify that PATH lookup of `julia` resolves to the binary we just installed.
// On self-hosted runners other Julia entries (e.g. juliaup launcher in
// ~/.juliaup/bin) can shadow the toolcache binary depending on PATH state.
const resolvedJulia = await io.which('julia', true)
const expectedJulia = path.join(juliaBindir, os.platform() == 'win32' ? 'julia.exe' : 'julia')
const norm = (p: string) => {
const resolved = path.resolve(fs.realpathSync(p))
return os.platform() == 'win32' ? resolved.toLowerCase() : resolved
}
if (norm(resolvedJulia) !== norm(expectedJulia)) {
core.warning(`PATH lookup of \`julia\` resolves to ${resolvedJulia}, not the installed binary at ${expectedJulia}. Another Julia in PATH is shadowing setup-julia's install; fix the runner's PATH (e.g. remove or reorder \`~/.juliaup/bin\`).`)
}

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

// Test if Julia has been installed and print the version
const showVersionInfoInput = core.getInput('show-versioninfo')
Expand Down
Loading