mirror of
https://github.com/julia-actions/setup-julia.git
synced 2026-02-12 19:16:54 +08:00
Compare commits
1 Commits
releases/v
...
v1.5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
27ff99664b |
2
.github/workflows/example-builds-nightly.yml
vendored
2
.github/workflows/example-builds-nightly.yml
vendored
@@ -35,5 +35,5 @@ jobs:
|
||||
with:
|
||||
version: ${{ matrix.julia-version }}
|
||||
arch: ${{ matrix.julia-arch }}
|
||||
show-versioninfo: 'true'
|
||||
- run: julia --version
|
||||
- run: julia --compile=min -O0 -e 'import InteractiveUtils; InteractiveUtils.versioninfo()'
|
||||
|
||||
2
.github/workflows/example-builds.yml
vendored
2
.github/workflows/example-builds.yml
vendored
@@ -34,5 +34,5 @@ jobs:
|
||||
with:
|
||||
version: ${{ matrix.julia-version }}
|
||||
arch: ${{ matrix.julia-arch }}
|
||||
show-versioninfo: 'true'
|
||||
- run: julia --version
|
||||
- run: julia --compile=min -O0 -e 'import InteractiveUtils; InteractiveUtils.versioninfo()'
|
||||
|
||||
31
README.md
31
README.md
@@ -43,18 +43,8 @@ This action sets up a Julia environment for use in actions by downloading a spec
|
||||
# Default: x64
|
||||
arch: ''
|
||||
|
||||
# Set the display setting for printing InteractiveUtils.versioninfo() after installing.
|
||||
#
|
||||
# Starting Julia and running InteractiveUtils.versioninfo() takes a significant amount of time (1s or ~10% of the total build time in testing),
|
||||
# so you may not want to run it in every build, in particular on paid runners, as this cost will add up quickly.
|
||||
#
|
||||
# See "versioninfo" below for example usage and further explanations.
|
||||
#
|
||||
# Supported values: true | false | never
|
||||
#
|
||||
# true: Always print versioninfo
|
||||
# false: Only print versioninfo for nightly Julia
|
||||
# never: Never print versioninfo
|
||||
# If true, display the output of InteractiveUtils.versioninfo() after installing.
|
||||
# See "versioninfo" below for example usage.
|
||||
#
|
||||
# Default: false
|
||||
show-versioninfo: ''
|
||||
@@ -189,13 +179,18 @@ jobs:
|
||||
|
||||
### versioninfo
|
||||
|
||||
By default, only the output of `julia --version` is printed as verification that Julia has been installed for stable versions of Julia.
|
||||
`InteractiveUtils.versioninfo()` is run by default for nightly builds.
|
||||
By default, only a brief version identifier is printed in the run log. You can display the full `versioninfo` by adding `show-versioninfo`.
|
||||
Here's an example that prints this information just for `nightly`:
|
||||
|
||||
Starting Julia and printing the full versioninfo takes a significant amount of time (1s or ~10% of the total build time in testing), so you may not want to run it in every build, in particular on paid runners as this cost will add up quickly.
|
||||
However, `julia --version` does not provide sufficient information to know which commit a nightly binary was built from, therefore it is useful to show the full versioninfo on nightly builds regardless.
|
||||
|
||||
You can override this behaviour by changing the input to `never` if you never want to run `InteractiveUtils.versioninfo()` or to `true` if you always want to run `InteractiveUtils.versioninfo()`, even on stable Julia builds.
|
||||
```yaml
|
||||
- uses: julia-actions/setup-julia@v1
|
||||
with:
|
||||
version: ${{ matrix.version }}
|
||||
arch: ${{ matrix.arch }}
|
||||
show-versioninfo: ${{ matrix.version == 'nightly' }}
|
||||
```
|
||||
|
||||
You use `'true'` if you want it printed for all Julia versions.
|
||||
|
||||
## Versioning
|
||||
|
||||
|
||||
420
dist/index.js
vendored
420
dist/index.js
vendored
@@ -2880,13 +2880,6 @@ function coerce (version, options) {
|
||||
}
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 321:
|
||||
/***/ (function(module, __unusedexports, __webpack_require__) {
|
||||
|
||||
module.exports = __webpack_require__(600);
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 357:
|
||||
@@ -3240,73 +3233,6 @@ function getState(name) {
|
||||
exports.getState = getState;
|
||||
//# sourceMappingURL=core.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 523:
|
||||
/***/ (function(module, __unusedexports, __webpack_require__) {
|
||||
|
||||
// Packages
|
||||
var retrier = __webpack_require__(321);
|
||||
|
||||
function retry(fn, opts) {
|
||||
function run(resolve, reject) {
|
||||
var options = opts || {};
|
||||
|
||||
// Default `randomize` to true
|
||||
if (!('randomize' in options)) {
|
||||
options.randomize = true;
|
||||
}
|
||||
|
||||
var op = retrier.operation(options);
|
||||
|
||||
// We allow the user to abort retrying
|
||||
// this makes sense in the cases where
|
||||
// knowledge is obtained that retrying
|
||||
// would be futile (e.g.: auth errors)
|
||||
|
||||
function bail(err) {
|
||||
reject(err || new Error('Aborted'));
|
||||
}
|
||||
|
||||
function onError(err, num) {
|
||||
if (err.bail) {
|
||||
bail(err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!op.retry(err)) {
|
||||
reject(op.mainError());
|
||||
} else if (options.onRetry) {
|
||||
options.onRetry(err, num);
|
||||
}
|
||||
}
|
||||
|
||||
function runAttempt(num) {
|
||||
var val;
|
||||
|
||||
try {
|
||||
val = fn(bail, num);
|
||||
} catch (err) {
|
||||
onError(err, num);
|
||||
return;
|
||||
}
|
||||
|
||||
Promise.resolve(val)
|
||||
.then(resolve)
|
||||
.catch(function catchIt(err) {
|
||||
onError(err, num);
|
||||
});
|
||||
}
|
||||
|
||||
op.attempt(runAttempt);
|
||||
}
|
||||
|
||||
return new Promise(run);
|
||||
}
|
||||
|
||||
module.exports = retry;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 533:
|
||||
@@ -3750,113 +3676,6 @@ function _evaluateVersions(versions, versionSpec) {
|
||||
}
|
||||
//# sourceMappingURL=tool-cache.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 600:
|
||||
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
||||
|
||||
var RetryOperation = __webpack_require__(988);
|
||||
|
||||
exports.operation = function(options) {
|
||||
var timeouts = exports.timeouts(options);
|
||||
return new RetryOperation(timeouts, {
|
||||
forever: options && options.forever,
|
||||
unref: options && options.unref,
|
||||
maxRetryTime: options && options.maxRetryTime
|
||||
});
|
||||
};
|
||||
|
||||
exports.timeouts = function(options) {
|
||||
if (options instanceof Array) {
|
||||
return [].concat(options);
|
||||
}
|
||||
|
||||
var opts = {
|
||||
retries: 10,
|
||||
factor: 2,
|
||||
minTimeout: 1 * 1000,
|
||||
maxTimeout: Infinity,
|
||||
randomize: false
|
||||
};
|
||||
for (var key in options) {
|
||||
opts[key] = options[key];
|
||||
}
|
||||
|
||||
if (opts.minTimeout > opts.maxTimeout) {
|
||||
throw new Error('minTimeout is greater than maxTimeout');
|
||||
}
|
||||
|
||||
var timeouts = [];
|
||||
for (var i = 0; i < opts.retries; i++) {
|
||||
timeouts.push(this.createTimeout(i, opts));
|
||||
}
|
||||
|
||||
if (options && options.forever && !timeouts.length) {
|
||||
timeouts.push(this.createTimeout(i, opts));
|
||||
}
|
||||
|
||||
// sort the array numerically ascending
|
||||
timeouts.sort(function(a,b) {
|
||||
return a - b;
|
||||
});
|
||||
|
||||
return timeouts;
|
||||
};
|
||||
|
||||
exports.createTimeout = function(attempt, opts) {
|
||||
var random = (opts.randomize)
|
||||
? (Math.random() + 1)
|
||||
: 1;
|
||||
|
||||
var timeout = Math.round(random * opts.minTimeout * Math.pow(opts.factor, attempt));
|
||||
timeout = Math.min(timeout, opts.maxTimeout);
|
||||
|
||||
return timeout;
|
||||
};
|
||||
|
||||
exports.wrap = function(obj, options, methods) {
|
||||
if (options instanceof Array) {
|
||||
methods = options;
|
||||
options = null;
|
||||
}
|
||||
|
||||
if (!methods) {
|
||||
methods = [];
|
||||
for (var key in obj) {
|
||||
if (typeof obj[key] === 'function') {
|
||||
methods.push(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < methods.length; i++) {
|
||||
var method = methods[i];
|
||||
var original = obj[method];
|
||||
|
||||
obj[method] = function retryWrapper(original) {
|
||||
var op = exports.operation(options);
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
var callback = args.pop();
|
||||
|
||||
args.push(function(err) {
|
||||
if (op.retry(err)) {
|
||||
return;
|
||||
}
|
||||
if (err) {
|
||||
arguments[0] = op.mainError();
|
||||
}
|
||||
callback.apply(this, arguments);
|
||||
});
|
||||
|
||||
op.attempt(function() {
|
||||
original.apply(obj, args);
|
||||
});
|
||||
}.bind(obj, original);
|
||||
obj[method].options = options;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 605:
|
||||
@@ -4148,6 +3967,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = __importStar(__webpack_require__(470));
|
||||
const exec = __importStar(__webpack_require__(986));
|
||||
const tc = __importStar(__webpack_require__(533));
|
||||
const fs = __importStar(__webpack_require__(747));
|
||||
const https = __importStar(__webpack_require__(211));
|
||||
@@ -4210,8 +4030,15 @@ function run() {
|
||||
// Set output
|
||||
core.setOutput('julia-bindir', path.join(juliaPath, 'bin'));
|
||||
// Test if Julia has been installed and print the version
|
||||
const showVersionInfoInput = core.getInput('show-versioninfo');
|
||||
yield installer.showVersionInfo(showVersionInfoInput, version);
|
||||
if (core.getInput('show-versioninfo') == 'true') {
|
||||
// If enabled, show the full version info
|
||||
// --compile=min -O0 reduces the time from ~1.8-1.9s to ~0.8-0.9s
|
||||
exec.exec('julia', ['--compile=min', '-O0', '-e', 'using InteractiveUtils; versioninfo()']);
|
||||
}
|
||||
else {
|
||||
// Otherwise only print julia --version to save time
|
||||
exec.exec('julia', ['--version']);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(error.message);
|
||||
@@ -4258,7 +4085,6 @@ const crypto = __importStar(__webpack_require__(417));
|
||||
const fs = __importStar(__webpack_require__(747));
|
||||
const os = __importStar(__webpack_require__(87));
|
||||
const path = __importStar(__webpack_require__(622));
|
||||
const retry = __webpack_require__(523);
|
||||
const semver = __importStar(__webpack_require__(280));
|
||||
// Translations between actions input and Julia arch names
|
||||
const osMap = {
|
||||
@@ -4296,15 +4122,7 @@ function calculateChecksum(file) {
|
||||
*/
|
||||
function getJuliaVersionInfo() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// Occasionally the connection is reset for unknown reasons
|
||||
// In those cases, retry the download
|
||||
const versionsFile = yield retry((bail) => __awaiter(this, void 0, void 0, function* () {
|
||||
return yield tc.downloadTool('https://julialang-s3.julialang.org/bin/versions.json');
|
||||
}), {
|
||||
onRetry: (err) => {
|
||||
core.debug(`Download of versions.json failed, trying again. Error: ${err}`);
|
||||
}
|
||||
});
|
||||
const versionsFile = yield tc.downloadTool('https://julialang-s3.julialang.org/bin/versions.json');
|
||||
return JSON.parse(fs.readFileSync(versionsFile).toString());
|
||||
});
|
||||
}
|
||||
@@ -4382,10 +4200,6 @@ function getDownloadURL(fileInfo, version, arch) {
|
||||
if (version == 'nightly') {
|
||||
return `${baseURL}/${getNightlyFileName(arch)}`;
|
||||
}
|
||||
// Verify that fileInfo.url points at the official Julia download servers
|
||||
if (!fileInfo.url.startsWith('https://julialang-s3.julialang.org/')) {
|
||||
throw new Error(`versions.json points at a download location outside of Julia's download server: ${fileInfo.url}. Aborting for security reasons.`);
|
||||
}
|
||||
return fileInfo.url;
|
||||
}
|
||||
exports.getDownloadURL = getDownloadURL;
|
||||
@@ -4395,15 +4209,7 @@ function installJulia(versionInfo, version, arch) {
|
||||
const fileInfo = getFileInfo(versionInfo, version, arch);
|
||||
const downloadURL = getDownloadURL(fileInfo, version, arch);
|
||||
core.debug(`downloading Julia from ${downloadURL}`);
|
||||
// Occasionally the connection is reset for unknown reasons
|
||||
// In those cases, retry the download
|
||||
const juliaDownloadPath = yield retry((bail) => __awaiter(this, void 0, void 0, function* () {
|
||||
return yield tc.downloadTool(downloadURL);
|
||||
}), {
|
||||
onRetry: (err) => {
|
||||
core.debug(`Download of ${downloadURL} failed, trying again. Error: ${err}`);
|
||||
}
|
||||
});
|
||||
const juliaDownloadPath = yield tc.downloadTool(downloadURL);
|
||||
// Verify checksum
|
||||
if (!version.endsWith('nightly')) {
|
||||
const checkSum = yield calculateChecksum(juliaDownloadPath);
|
||||
@@ -4441,43 +4247,6 @@ function installJulia(versionInfo, version, arch) {
|
||||
});
|
||||
}
|
||||
exports.installJulia = installJulia;
|
||||
/**
|
||||
* Test if Julia has been installed and print the version.
|
||||
*
|
||||
* true => always show versioninfo
|
||||
* false => only show on nightlies
|
||||
* never => never show it anywhere
|
||||
*
|
||||
* @param showVersionInfoInput
|
||||
*/
|
||||
function showVersionInfo(showVersionInfoInput, version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// --compile=min -O0 reduces the time from ~1.8-1.9s to ~0.8-0.9s
|
||||
let exitCode;
|
||||
switch (showVersionInfoInput) {
|
||||
case 'true':
|
||||
exitCode = yield exec.exec('julia', ['--compile=min', '-O0', '-e', 'using InteractiveUtils; versioninfo()']);
|
||||
break;
|
||||
case 'false':
|
||||
if (version.endsWith('nightly')) {
|
||||
exitCode = yield exec.exec('julia', ['--compile=min', '-O0', '-e', 'using InteractiveUtils; versioninfo()']);
|
||||
}
|
||||
else {
|
||||
exitCode = yield exec.exec('julia', ['--version']);
|
||||
}
|
||||
break;
|
||||
case 'never':
|
||||
exitCode = yield exec.exec('julia', ['--version']);
|
||||
break;
|
||||
default:
|
||||
throw new Error(`${showVersionInfoInput} is not a valid value for show-versioninfo. Supported values: true | false | never`);
|
||||
}
|
||||
if (exitCode !== 0) {
|
||||
throw new Error(`Julia could not be installed properly. Exit code: ${exitCode}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.showVersionInfo = showVersionInfo;
|
||||
|
||||
|
||||
/***/ }),
|
||||
@@ -5029,171 +4798,6 @@ function exec(commandLine, args, options) {
|
||||
exports.exec = exec;
|
||||
//# sourceMappingURL=exec.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 988:
|
||||
/***/ (function(module) {
|
||||
|
||||
function RetryOperation(timeouts, options) {
|
||||
// Compatibility for the old (timeouts, retryForever) signature
|
||||
if (typeof options === 'boolean') {
|
||||
options = { forever: options };
|
||||
}
|
||||
|
||||
this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
|
||||
this._timeouts = timeouts;
|
||||
this._options = options || {};
|
||||
this._maxRetryTime = options && options.maxRetryTime || Infinity;
|
||||
this._fn = null;
|
||||
this._errors = [];
|
||||
this._attempts = 1;
|
||||
this._operationTimeout = null;
|
||||
this._operationTimeoutCb = null;
|
||||
this._timeout = null;
|
||||
this._operationStart = null;
|
||||
|
||||
if (this._options.forever) {
|
||||
this._cachedTimeouts = this._timeouts.slice(0);
|
||||
}
|
||||
}
|
||||
module.exports = RetryOperation;
|
||||
|
||||
RetryOperation.prototype.reset = function() {
|
||||
this._attempts = 1;
|
||||
this._timeouts = this._originalTimeouts;
|
||||
}
|
||||
|
||||
RetryOperation.prototype.stop = function() {
|
||||
if (this._timeout) {
|
||||
clearTimeout(this._timeout);
|
||||
}
|
||||
|
||||
this._timeouts = [];
|
||||
this._cachedTimeouts = null;
|
||||
};
|
||||
|
||||
RetryOperation.prototype.retry = function(err) {
|
||||
if (this._timeout) {
|
||||
clearTimeout(this._timeout);
|
||||
}
|
||||
|
||||
if (!err) {
|
||||
return false;
|
||||
}
|
||||
var currentTime = new Date().getTime();
|
||||
if (err && currentTime - this._operationStart >= this._maxRetryTime) {
|
||||
this._errors.unshift(new Error('RetryOperation timeout occurred'));
|
||||
return false;
|
||||
}
|
||||
|
||||
this._errors.push(err);
|
||||
|
||||
var timeout = this._timeouts.shift();
|
||||
if (timeout === undefined) {
|
||||
if (this._cachedTimeouts) {
|
||||
// retry forever, only keep last error
|
||||
this._errors.splice(this._errors.length - 1, this._errors.length);
|
||||
this._timeouts = this._cachedTimeouts.slice(0);
|
||||
timeout = this._timeouts.shift();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
var self = this;
|
||||
var timer = setTimeout(function() {
|
||||
self._attempts++;
|
||||
|
||||
if (self._operationTimeoutCb) {
|
||||
self._timeout = setTimeout(function() {
|
||||
self._operationTimeoutCb(self._attempts);
|
||||
}, self._operationTimeout);
|
||||
|
||||
if (self._options.unref) {
|
||||
self._timeout.unref();
|
||||
}
|
||||
}
|
||||
|
||||
self._fn(self._attempts);
|
||||
}, timeout);
|
||||
|
||||
if (this._options.unref) {
|
||||
timer.unref();
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
RetryOperation.prototype.attempt = function(fn, timeoutOps) {
|
||||
this._fn = fn;
|
||||
|
||||
if (timeoutOps) {
|
||||
if (timeoutOps.timeout) {
|
||||
this._operationTimeout = timeoutOps.timeout;
|
||||
}
|
||||
if (timeoutOps.cb) {
|
||||
this._operationTimeoutCb = timeoutOps.cb;
|
||||
}
|
||||
}
|
||||
|
||||
var self = this;
|
||||
if (this._operationTimeoutCb) {
|
||||
this._timeout = setTimeout(function() {
|
||||
self._operationTimeoutCb();
|
||||
}, self._operationTimeout);
|
||||
}
|
||||
|
||||
this._operationStart = new Date().getTime();
|
||||
|
||||
this._fn(this._attempts);
|
||||
};
|
||||
|
||||
RetryOperation.prototype.try = function(fn) {
|
||||
console.log('Using RetryOperation.try() is deprecated');
|
||||
this.attempt(fn);
|
||||
};
|
||||
|
||||
RetryOperation.prototype.start = function(fn) {
|
||||
console.log('Using RetryOperation.start() is deprecated');
|
||||
this.attempt(fn);
|
||||
};
|
||||
|
||||
RetryOperation.prototype.start = RetryOperation.prototype.try;
|
||||
|
||||
RetryOperation.prototype.errors = function() {
|
||||
return this._errors;
|
||||
};
|
||||
|
||||
RetryOperation.prototype.attempts = function() {
|
||||
return this._attempts;
|
||||
};
|
||||
|
||||
RetryOperation.prototype.mainError = function() {
|
||||
if (this._errors.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var counts = {};
|
||||
var mainError = null;
|
||||
var mainErrorCount = 0;
|
||||
|
||||
for (var i = 0; i < this._errors.length; i++) {
|
||||
var error = this._errors[i];
|
||||
var message = error.message;
|
||||
var count = (counts[message] || 0) + 1;
|
||||
|
||||
counts[message] = count;
|
||||
|
||||
if (count >= mainErrorCount) {
|
||||
mainError = error;
|
||||
mainErrorCount = count;
|
||||
}
|
||||
}
|
||||
|
||||
return mainError;
|
||||
};
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
/******/ });
|
||||
62
lib/installer.js
generated
62
lib/installer.js
generated
@@ -22,7 +22,6 @@ const crypto = __importStar(require("crypto"));
|
||||
const fs = __importStar(require("fs"));
|
||||
const os = __importStar(require("os"));
|
||||
const path = __importStar(require("path"));
|
||||
const retry = require("async-retry");
|
||||
const semver = __importStar(require("semver"));
|
||||
// Translations between actions input and Julia arch names
|
||||
const osMap = {
|
||||
@@ -60,15 +59,7 @@ function calculateChecksum(file) {
|
||||
*/
|
||||
function getJuliaVersionInfo() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// Occasionally the connection is reset for unknown reasons
|
||||
// In those cases, retry the download
|
||||
const versionsFile = yield retry((bail) => __awaiter(this, void 0, void 0, function* () {
|
||||
return yield tc.downloadTool('https://julialang-s3.julialang.org/bin/versions.json');
|
||||
}), {
|
||||
onRetry: (err) => {
|
||||
core.debug(`Download of versions.json failed, trying again. Error: ${err}`);
|
||||
}
|
||||
});
|
||||
const versionsFile = yield tc.downloadTool('https://julialang-s3.julialang.org/bin/versions.json');
|
||||
return JSON.parse(fs.readFileSync(versionsFile).toString());
|
||||
});
|
||||
}
|
||||
@@ -146,10 +137,6 @@ function getDownloadURL(fileInfo, version, arch) {
|
||||
if (version == 'nightly') {
|
||||
return `${baseURL}/${getNightlyFileName(arch)}`;
|
||||
}
|
||||
// Verify that fileInfo.url points at the official Julia download servers
|
||||
if (!fileInfo.url.startsWith('https://julialang-s3.julialang.org/')) {
|
||||
throw new Error(`versions.json points at a download location outside of Julia's download server: ${fileInfo.url}. Aborting for security reasons.`);
|
||||
}
|
||||
return fileInfo.url;
|
||||
}
|
||||
exports.getDownloadURL = getDownloadURL;
|
||||
@@ -159,15 +146,7 @@ function installJulia(versionInfo, version, arch) {
|
||||
const fileInfo = getFileInfo(versionInfo, version, arch);
|
||||
const downloadURL = getDownloadURL(fileInfo, version, arch);
|
||||
core.debug(`downloading Julia from ${downloadURL}`);
|
||||
// Occasionally the connection is reset for unknown reasons
|
||||
// In those cases, retry the download
|
||||
const juliaDownloadPath = yield retry((bail) => __awaiter(this, void 0, void 0, function* () {
|
||||
return yield tc.downloadTool(downloadURL);
|
||||
}), {
|
||||
onRetry: (err) => {
|
||||
core.debug(`Download of ${downloadURL} failed, trying again. Error: ${err}`);
|
||||
}
|
||||
});
|
||||
const juliaDownloadPath = yield tc.downloadTool(downloadURL);
|
||||
// Verify checksum
|
||||
if (!version.endsWith('nightly')) {
|
||||
const checkSum = yield calculateChecksum(juliaDownloadPath);
|
||||
@@ -205,40 +184,3 @@ function installJulia(versionInfo, version, arch) {
|
||||
});
|
||||
}
|
||||
exports.installJulia = installJulia;
|
||||
/**
|
||||
* Test if Julia has been installed and print the version.
|
||||
*
|
||||
* true => always show versioninfo
|
||||
* false => only show on nightlies
|
||||
* never => never show it anywhere
|
||||
*
|
||||
* @param showVersionInfoInput
|
||||
*/
|
||||
function showVersionInfo(showVersionInfoInput, version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// --compile=min -O0 reduces the time from ~1.8-1.9s to ~0.8-0.9s
|
||||
let exitCode;
|
||||
switch (showVersionInfoInput) {
|
||||
case 'true':
|
||||
exitCode = yield exec.exec('julia', ['--compile=min', '-O0', '-e', 'using InteractiveUtils; versioninfo()']);
|
||||
break;
|
||||
case 'false':
|
||||
if (version.endsWith('nightly')) {
|
||||
exitCode = yield exec.exec('julia', ['--compile=min', '-O0', '-e', 'using InteractiveUtils; versioninfo()']);
|
||||
}
|
||||
else {
|
||||
exitCode = yield exec.exec('julia', ['--version']);
|
||||
}
|
||||
break;
|
||||
case 'never':
|
||||
exitCode = yield exec.exec('julia', ['--version']);
|
||||
break;
|
||||
default:
|
||||
throw new Error(`${showVersionInfoInput} is not a valid value for show-versioninfo. Supported values: true | false | never`);
|
||||
}
|
||||
if (exitCode !== 0) {
|
||||
throw new Error(`Julia could not be installed properly. Exit code: ${exitCode}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.showVersionInfo = showVersionInfo;
|
||||
|
||||
12
lib/setup-julia.js
generated
12
lib/setup-julia.js
generated
@@ -16,6 +16,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const exec = __importStar(require("@actions/exec"));
|
||||
const tc = __importStar(require("@actions/tool-cache"));
|
||||
const fs = __importStar(require("fs"));
|
||||
const https = __importStar(require("https"));
|
||||
@@ -78,8 +79,15 @@ function run() {
|
||||
// Set output
|
||||
core.setOutput('julia-bindir', path.join(juliaPath, 'bin'));
|
||||
// Test if Julia has been installed and print the version
|
||||
const showVersionInfoInput = core.getInput('show-versioninfo');
|
||||
yield installer.showVersionInfo(showVersionInfoInput, version);
|
||||
if (core.getInput('show-versioninfo') == 'true') {
|
||||
// If enabled, show the full version info
|
||||
// --compile=min -O0 reduces the time from ~1.8-1.9s to ~0.8-0.9s
|
||||
exec.exec('julia', ['--compile=min', '-O0', '-e', 'using InteractiveUtils; versioninfo()']);
|
||||
}
|
||||
else {
|
||||
// Otherwise only print julia --version to save time
|
||||
exec.exec('julia', ['--version']);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(error.message);
|
||||
|
||||
30
package-lock.json
generated
30
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "setup-julia",
|
||||
"version": "1.6.0",
|
||||
"version": "1.5.2",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
@@ -1384,15 +1384,6 @@
|
||||
"@types/yargs": "^12.0.9"
|
||||
}
|
||||
},
|
||||
"@types/async-retry": {
|
||||
"version": "1.4.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/async-retry/-/async-retry-1.4.2.tgz",
|
||||
"integrity": "sha512-GUDuJURF0YiJZ+CBjNQA0+vbP/VHlJbB0sFqkzsV7EcOPRfurVonXpXKAt3w8qIjM1TEzpz6hc6POocPvHOS3w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/retry": "*"
|
||||
}
|
||||
},
|
||||
"@types/babel__core": {
|
||||
"version": "7.1.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.6.tgz",
|
||||
@@ -1480,12 +1471,6 @@
|
||||
"integrity": "sha512-E6Zn0rffhgd130zbCbAr/JdXfXkoOUFAKNs/rF8qnafSJ8KYaA/j3oz7dcwal+lYjLA7xvdd5J4wdYpCTlP8+w==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/retry": {
|
||||
"version": "0.12.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.0.tgz",
|
||||
"integrity": "sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/semver": {
|
||||
"version": "6.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/semver/-/semver-6.0.1.tgz",
|
||||
@@ -1658,14 +1643,6 @@
|
||||
"integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==",
|
||||
"dev": true
|
||||
},
|
||||
"async-retry": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/async-retry/-/async-retry-1.3.1.tgz",
|
||||
"integrity": "sha512-aiieFW/7h3hY0Bq5d+ktDBejxuwR78vRu9hDUdR8rNhSaQ29VzPL4AoIRG7D/c7tdenwOcKvgPM6tIxB3cB6HA==",
|
||||
"requires": {
|
||||
"retry": "0.12.0"
|
||||
}
|
||||
},
|
||||
"asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||
@@ -6069,11 +6046,6 @@
|
||||
"integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==",
|
||||
"dev": true
|
||||
},
|
||||
"retry": {
|
||||
"version": "0.12.0",
|
||||
"resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz",
|
||||
"integrity": "sha1-G0KmJmoh8HQh0bC1S33BZ7AcATs="
|
||||
},
|
||||
"rimraf": {
|
||||
"version": "2.7.1",
|
||||
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "setup-julia",
|
||||
"version": "1.6.0",
|
||||
"version": "1.5.2",
|
||||
"private": true,
|
||||
"description": "setup Julia action",
|
||||
"main": "lib/setup-julia.js",
|
||||
@@ -25,11 +25,9 @@
|
||||
"@actions/exec": "^1.0.0",
|
||||
"@actions/io": "^1.0.0",
|
||||
"@actions/tool-cache": "^1.0.0",
|
||||
"async-retry": "^1.3.1",
|
||||
"semver": "^6.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/async-retry": "^1.4.2",
|
||||
"@types/jest": "^24.0.13",
|
||||
"@types/node": "^12.12.7",
|
||||
"@types/semver": "^6.0.0",
|
||||
|
||||
@@ -6,7 +6,6 @@ import * as crypto from 'crypto'
|
||||
import * as fs from 'fs'
|
||||
import * as os from 'os'
|
||||
import * as path from 'path'
|
||||
import retry = require('async-retry')
|
||||
|
||||
import * as semver from 'semver'
|
||||
|
||||
@@ -48,15 +47,7 @@ async function calculateChecksum(file: string): Promise<string> {
|
||||
* @returns The content of the downloaded versions.json file as object.
|
||||
*/
|
||||
export async function getJuliaVersionInfo(): Promise<object> {
|
||||
// Occasionally the connection is reset for unknown reasons
|
||||
// In those cases, retry the download
|
||||
const versionsFile = await retry(async (bail: Function) => {
|
||||
return await tc.downloadTool('https://julialang-s3.julialang.org/bin/versions.json')
|
||||
}, {
|
||||
onRetry: (err: Error) => {
|
||||
core.debug(`Download of versions.json failed, trying again. Error: ${err}`)
|
||||
}
|
||||
})
|
||||
const versionsFile = await tc.downloadTool('https://julialang-s3.julialang.org/bin/versions.json')
|
||||
|
||||
return JSON.parse(fs.readFileSync(versionsFile).toString())
|
||||
}
|
||||
@@ -142,10 +133,6 @@ export function getDownloadURL(fileInfo, version: string, arch: string): string
|
||||
return `${baseURL}/${getNightlyFileName(arch)}`
|
||||
}
|
||||
|
||||
// Verify that fileInfo.url points at the official Julia download servers
|
||||
if (!fileInfo.url.startsWith('https://julialang-s3.julialang.org/')) {
|
||||
throw new Error(`versions.json points at a download location outside of Julia's download server: ${fileInfo.url}. Aborting for security reasons.`)
|
||||
}
|
||||
return fileInfo.url
|
||||
}
|
||||
|
||||
@@ -154,17 +141,7 @@ export async function installJulia(versionInfo, version: string, arch: string):
|
||||
const fileInfo = getFileInfo(versionInfo, version, arch)
|
||||
const downloadURL = getDownloadURL(fileInfo, version, arch)
|
||||
core.debug(`downloading Julia from ${downloadURL}`)
|
||||
|
||||
// Occasionally the connection is reset for unknown reasons
|
||||
// In those cases, retry the download
|
||||
const juliaDownloadPath = await retry(async (bail: Function) => {
|
||||
return await tc.downloadTool(downloadURL)
|
||||
}, {
|
||||
onRetry: (err: Error) => {
|
||||
core.debug(`Download of ${downloadURL} failed, trying again. Error: ${err}`)
|
||||
}
|
||||
})
|
||||
|
||||
const juliaDownloadPath = await tc.downloadTool(downloadURL)
|
||||
|
||||
// Verify checksum
|
||||
if (!version.endsWith('nightly')) {
|
||||
@@ -201,42 +178,3 @@ export async function installJulia(versionInfo, version: string, arch: string):
|
||||
throw new Error(`Platform ${osPlat} is not supported`)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if Julia has been installed and print the version.
|
||||
*
|
||||
* true => always show versioninfo
|
||||
* false => only show on nightlies
|
||||
* never => never show it anywhere
|
||||
*
|
||||
* @param showVersionInfoInput
|
||||
*/
|
||||
export async function showVersionInfo(showVersionInfoInput: string, version: string): Promise<void> {
|
||||
// --compile=min -O0 reduces the time from ~1.8-1.9s to ~0.8-0.9s
|
||||
let exitCode: number
|
||||
|
||||
switch (showVersionInfoInput) {
|
||||
case 'true':
|
||||
exitCode = await exec.exec('julia', ['--compile=min', '-O0', '-e', 'using InteractiveUtils; versioninfo()'])
|
||||
break
|
||||
|
||||
case 'false':
|
||||
if (version.endsWith('nightly')) {
|
||||
exitCode = await exec.exec('julia', ['--compile=min', '-O0', '-e', 'using InteractiveUtils; versioninfo()'])
|
||||
} else {
|
||||
exitCode = await exec.exec('julia', ['--version'])
|
||||
}
|
||||
break
|
||||
|
||||
case 'never':
|
||||
exitCode = await exec.exec('julia', ['--version'])
|
||||
break
|
||||
|
||||
default:
|
||||
throw new Error(`${showVersionInfoInput} is not a valid value for show-versioninfo. Supported values: true | false | never`)
|
||||
}
|
||||
|
||||
if (exitCode !== 0) {
|
||||
throw new Error(`Julia could not be installed properly. Exit code: ${exitCode}`)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,8 +75,14 @@ async function run() {
|
||||
core.setOutput('julia-bindir', path.join(juliaPath, 'bin'))
|
||||
|
||||
// Test if Julia has been installed and print the version
|
||||
const showVersionInfoInput = core.getInput('show-versioninfo')
|
||||
await installer.showVersionInfo(showVersionInfoInput, version)
|
||||
if (core.getInput('show-versioninfo') == 'true') {
|
||||
// If enabled, show the full version info
|
||||
// --compile=min -O0 reduces the time from ~1.8-1.9s to ~0.8-0.9s
|
||||
exec.exec('julia', ['--compile=min', '-O0', '-e', 'using InteractiveUtils; versioninfo()'])
|
||||
} else {
|
||||
// Otherwise only print julia --version to save time
|
||||
exec.exec('julia', ['--version'])
|
||||
}
|
||||
} catch (error) {
|
||||
core.setFailed(error.message)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user