Get Julia versions from versions.json (#24)

This replaces the hardcoded versions array which will decouple the setup-julia version and the installable Julia versions.
This commit is contained in:
Sascha Mann
2020-11-08 15:06:21 +01:00
committed by GitHub
parent c5d801f77b
commit 45f46ba622
8 changed files with 5098 additions and 98 deletions

File diff suppressed because it is too large Load Diff

113
__tests__/installer.test.ts Normal file
View File

@@ -0,0 +1,113 @@
// The testing setup has been derived from the actions/setup-go@bc6edb5 action.
// Check README.md for licence information.
import * as path from 'path'
import * as io from '@actions/io'
import nock = require('nock')
import * as semver from 'semver'
const testVersions = [
'0.1.2', '0.2.0', '0.2.1', '0.3.0',
'0.3.1', '0.3.10', '0.3.11', '0.3.12',
'0.3.2', '0.3.3', '0.3.4', '0.3.5',
'0.3.6', '0.3.7', '0.3.8', '0.3.9',
'0.4.0', '0.4.0-rc1', '0.4.0-rc2', '0.4.0-rc3',
'0.4.0-rc4', '0.4.1', '0.4.2', '0.4.3',
'0.4.4', '0.4.5', '0.4.6', '0.4.7',
'0.5.0', '0.5.0-rc0', '0.5.0-rc1', '0.5.0-rc2',
'0.5.0-rc3', '0.5.0-rc4', '0.5.1', '0.5.2',
'0.6.0', '0.6.0-pre.alpha', '0.6.0-pre.beta', '0.6.0-rc1',
'0.6.0-rc2', '0.6.0-rc3', '0.6.1', '0.6.2',
'0.6.3', '0.6.4', '0.7.0', '0.7.0-alpha',
'0.7.0-beta', '0.7.0-beta2', '0.7.0-rc1', '0.7.0-rc2',
'0.7.0-rc3', '1.0.0', '1.0.0-rc1', '1.0.1',
'1.0.2', '1.0.3', '1.0.4', '1.0.5',
'1.1.0', '1.1.0-rc1', '1.1.0-rc2', '1.1.1',
'1.2.0', '1.2.0-rc1', '1.2.0-rc2', '1.2.0-rc3',
'1.3.0-alpha', '1.3.0-rc1', '1.3.0-rc2', '1.3.0-rc3',
'1.3.0-rc4'
]
const toolDir = path.join(__dirname, 'runner', 'tools')
const tempDir = path.join(__dirname, 'runner', 'temp')
const fixtureDir = path.join(__dirname, 'fixtures')
process.env['RUNNER_TOOL_CACHE'] = toolDir;
process.env['RUNNER_TEMP'] = tempDir;
import * as installer from '../src/installer'
describe('version matching tests', () => {
describe('specific versions', () => {
it('Doesn\'t change the version when given a valid semver version', async () => {
expect(await installer.getJuliaVersion([], '1.0.5')).toEqual('1.0.5')
expect(await installer.getJuliaVersion(['v1.0.5', 'v1.0.6'], '1.0.5')).toEqual('1.0.5')
expect(await installer.getJuliaVersion(['v1.0.4', 'v1.0.5'], '1.0.5')).toEqual('1.0.5')
expect(await installer.getJuliaVersion(['v1.0.4'], '1.0.5')).toEqual('1.0.5')
expect(await installer.getJuliaVersion([], '1.3.0-alpha')).toEqual('1.3.0-alpha')
expect(await installer.getJuliaVersion(['v1.2.0', 'v1.3.0-alpha', 'v1.3.0-rc1', 'v1.3.0'], '1.3.0-alpha')).toEqual('1.3.0-alpha')
expect(await installer.getJuliaVersion([], '1.3.0-rc2')).toEqual('1.3.0-rc2')
})
it('Doesn\'t change the version when given `nightly`', async () => {
expect(await installer.getJuliaVersion([], 'nightly')).toEqual('nightly')
expect(await installer.getJuliaVersion(testVersions, 'nightly')).toEqual('nightly')
})
})
describe('version ranges', () => {
it('Chooses the highest available version that matches the input', async () => {
expect(await installer.getJuliaVersion(testVersions, '1')).toEqual('1.2.0')
expect(await installer.getJuliaVersion(testVersions, '1.0')).toEqual('1.0.5')
expect(await installer.getJuliaVersion(testVersions, '^1.3.0-rc1')).toEqual('1.3.0-rc4')
expect(await installer.getJuliaVersion(testVersions, '^1.2.0-rc1')).toEqual('1.2.0')
})
})
describe('node-semver behaviour', () => {
describe('Windows installer change', () => {
it('Correctly understands >1.4.0', () => {
expect(semver.gtr('1.4.0-rc1', '1.3', {includePrerelease: true})).toBeTruthy()
expect(semver.gtr('1.4.0-DEV', '1.3', {includePrerelease: true})).toBeTruthy()
expect(semver.gtr('1.3.1', '1.3', {includePrerelease: true})).toBeFalsy()
expect(semver.gtr('1.3.2-rc1', '1.3', {includePrerelease: true})).toBeFalsy()
})
})
})
})
describe('installer tests', () => {
beforeAll(async () => {
await io.rmRF(toolDir)
await io.rmRF(tempDir)
}, 100000)
afterAll(async () => {
try {
await io.rmRF(toolDir)
await io.rmRF(tempDir)
} catch {
console.log('Failed to remove test directories')
}
}, 100000)
describe('versions.json parsing', () => {
// Instead of downloading versions.json, use fixtures/versions.json
beforeEach(() => {
nock('https://julialang-s3.julialang.org')
.get('/bin/versions.json')
.replyWithFile(200, path.join(fixtureDir, 'versions.json'))
})
afterEach(() => {
nock.cleanAll()
nock.enableNetConnect()
})
it('Extracts the list of available versions', async () => {
expect(await (await installer.getJuliaVersions(await installer.getJuliaVersionInfo())).sort()).toEqual(testVersions.sort())
})
})
})

101
lib/installer.js generated
View File

@@ -22,11 +22,42 @@ const fs = __importStar(require("fs"));
const os = __importStar(require("os")); const os = __importStar(require("os"));
const path = __importStar(require("path")); const path = __importStar(require("path"));
const semver = __importStar(require("semver")); const semver = __importStar(require("semver"));
// Translations between actions input and Julia arch names
const osMap = {
'win32': 'winnt',
'darwin': 'mac',
'linux': 'linux'
};
const archMap = {
'x86': 'i686',
'x64': 'x86_64'
};
// Store information about the environment // Store information about the environment
const osPlat = os.platform(); // possible values: win32 (Windows), linux (Linux), darwin (macOS) const osPlat = os.platform(); // possible values: win32 (Windows), linux (Linux), darwin (macOS)
core.debug(`platform: ${osPlat}`); core.debug(`platform: ${osPlat}`);
// This is temporary until we have a better way of fetching releases (see #1, #4 for details) /**
exports.juliaVersions = ['v1.5.2', 'v1.5.1', 'v1.5.0', 'v1.5.0-rc2', 'v1.5.0-rc1', 'v1.5.0-beta1', 'v1.4.2', 'v1.4.1', 'v1.4.0', 'v1.4.0-rc2', 'v1.4.0-rc1', 'v1.3.1', 'v1.3.0', 'v1.3.0-rc5', 'v1.3.0-rc4', 'v1.3.0-rc3', 'v1.3.0-rc2', 'v1.0.5', 'v1.2.0', 'v1.3.0-rc1', 'v1.2.0-rc3', 'v1.3.0-alpha', 'v1.2.0-rc2', 'v1.2.0-rc1', 'v1.1.1', 'v1.0.4', 'v1.1.0', 'v1.1.0-rc2', 'v1.1.0-rc1', 'v1.0.3', 'v1.0.2', 'v1.0.1', 'v1.0.0', 'v0.7.0', 'v1.0.0-rc1', 'v0.7.0-rc3', 'v0.7.0-rc2', 'v0.7.0-rc1', 'v0.7.0-beta2', 'v0.6.4', 'v0.7.0-beta', 'v0.7.0-alpha', 'v0.6.3', 'v0.6.2', 'v0.6.1', 'v0.6.0', 'v0.6.0-rc3', 'v0.6.0-rc2', 'v0.5.2', 'v0.6.0-rc1', 'v0.6.0-pre.beta', 'v0.5.1', 'v0.6.0-pre.alpha', 'v0.5.0', 'v0.4.7', 'v0.5.0-rc4', 'v0.5.0-rc3', 'v0.5.0-rc2', 'v0.5.0-rc1', 'v0.5.0-rc0', 'v0.4.6', 'v0.4.5', 'v0.4.4', 'v0.4.3', 'v0.4.2', 'v0.4.1', 'v0.3.12', 'v0.4.0', 'v0.4.0-rc4', 'v0.4.0-rc3', 'v0.4.0-rc2', 'v0.4.0-rc1', 'v0.3.11', 'v0.3.10', 'v0.3.9', 'v0.3.8', 'v0.3.7', 'v0.3.6', 'v0.3.5', 'v0.3.4', 'v0.3.3', 'v0.3.2', 'v0.3.1', 'v0.3.0', 'v0.3.0-rc4', 'v0.3.0-rc3', 'v0.3.0-rc2', 'v0.3.0-rc1', 'v0.2.0-rc1', 'v0.2.0-rc3', 'v0.2.0-rc4', 'v0.2.0', 'v0.2.0-rc2']; * @returns The content of the downloaded versions.json file as object.
*/
function getJuliaVersionInfo() {
return __awaiter(this, void 0, void 0, function* () {
const versionsFile = yield tc.downloadTool('https://julialang-s3.julialang.org/bin/versions.json');
return JSON.parse(fs.readFileSync(versionsFile).toString());
});
}
exports.getJuliaVersionInfo = getJuliaVersionInfo;
/**
* @returns An array of all Julia versions available for download
*/
function getJuliaVersions(versionInfo) {
return __awaiter(this, void 0, void 0, function* () {
let versions = [];
for (let version in versionInfo) {
versions.push(version);
}
return versions;
});
}
exports.getJuliaVersions = getJuliaVersions;
function getJuliaVersion(availableReleases, versionInput) { function getJuliaVersion(availableReleases, versionInput) {
if (semver.valid(versionInput) == versionInput) { if (semver.valid(versionInput) == versionInput) {
// versionInput is a valid version, use it directly // versionInput is a valid version, use it directly
@@ -46,67 +77,47 @@ function getJuliaVersion(availableReleases, versionInput) {
return version; return version;
} }
exports.getJuliaVersion = getJuliaVersion; exports.getJuliaVersion = getJuliaVersion;
function getMajorMinorVersion(version) { function getNightlyFileName(arch) {
return version.split('.').slice(0, 2).join('.');
}
function getDownloadURL(version, arch) {
let platform;
if (osPlat === 'win32') { // Windows
platform = 'winnt';
}
else if (osPlat === 'darwin') { // macOS
if (arch == 'x86') {
throw new Error('32-bit Julia is not available on macOS');
}
platform = 'mac';
}
else if (osPlat === 'linux') { // Linux
platform = 'linux';
}
else {
throw new Error(`Platform ${osPlat} is not supported`);
}
// nightlies
if (version == 'nightly') {
const baseURL = 'https://julialangnightlies-s3.julialang.org/bin';
return `${baseURL}/${platform}/${arch}/${getFileName('latest', arch)}`;
}
// normal versions
const baseURL = 'https://julialang-s3.julialang.org/bin';
const versionDir = getMajorMinorVersion(version);
return `${baseURL}/${platform}/${arch}/${versionDir}/${getFileName(version, arch)}`;
}
function getFileName(version, arch) {
let versionExt, ext; let versionExt, ext;
if (osPlat === 'win32') { // Windows if (osPlat == 'win32') {
versionExt = arch == 'x64' ? '-win64' : '-win32'; versionExt = arch == 'x64' ? '-win64' : '-win32';
ext = 'exe'; ext = 'exe';
} }
else if (osPlat === 'darwin') { // macOS else if (osPlat == 'darwin') {
if (arch == 'x86') { if (arch == 'x86') {
throw new Error('32-bit Julia is not available on macOS'); throw new Error('32-bit Julia is not available on macOS');
} }
versionExt = '-mac64'; versionExt = '-mac64';
ext = 'dmg'; ext = 'dmg';
} }
else if (osPlat === 'linux') { // Linux else if (osPlat === 'linux') {
if (version == 'latest') { // nightly version versionExt = arch == 'x64' ? '-linux64' : '-linux32';
versionExt = arch == 'x64' ? '-linux64' : '-linux32';
}
else {
versionExt = arch == 'x64' ? '-linux-x86_64' : '-linux-i686';
}
ext = 'tar.gz'; ext = 'tar.gz';
} }
else { else {
throw new Error(`Platform ${osPlat} is not supported`); throw new Error(`Platform ${osPlat} is not supported`);
} }
return `julia-${version}${versionExt}.${ext}`; return `julia-latest${versionExt}.${ext}`;
} }
function installJulia(version, arch) { function getDownloadURL(versionInfo, version, arch) {
// nightlies
if (version == 'nightly') {
const baseURL = 'https://julialangnightlies-s3.julialang.org/bin';
return `${baseURL}/${osMap[osPlat]}/${arch}/${getNightlyFileName(arch)}`;
}
for (let file of versionInfo[version].files) {
if (file.os == osMap[osPlat] && file.arch == archMap[arch]) {
core.debug(file);
return file.url;
}
}
throw `Could not find ${archMap[arch]}/${version} binaries`;
}
exports.getDownloadURL = getDownloadURL;
function installJulia(versionInfo, version, arch) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
// Download Julia // Download Julia
const downloadURL = getDownloadURL(version, arch); const downloadURL = getDownloadURL(versionInfo, version, arch);
core.debug(`downloading Julia from ${downloadURL}`); core.debug(`downloading Julia from ${downloadURL}`);
const juliaDownloadPath = yield tc.downloadTool(downloadURL); const juliaDownloadPath = yield tc.downloadTool(downloadURL);
const tempInstallDir = fs.mkdtempSync(`julia-${arch}-${version}-`); const tempInstallDir = fs.mkdtempSync(`julia-${arch}-${version}-`);

7
lib/setup-julia.js generated
View File

@@ -54,15 +54,16 @@ function run() {
if (!arch) { if (!arch) {
throw new Error(`Arch input must not be null`); throw new Error(`Arch input must not be null`);
} }
const availableReleases = installer.juliaVersions; const versionInfo = yield installer.getJuliaVersionInfo();
const availableReleases = yield installer.getJuliaVersions(versionInfo);
const version = installer.getJuliaVersion(availableReleases, versionInput); const version = installer.getJuliaVersion(availableReleases, versionInput);
core.debug(`selected Julia version: ${arch}/${version}`); core.debug(`selected Julia version: ${arch}/${version}`);
// Search in cache // Search in cache
let juliaPath; let juliaPath;
juliaPath = tc.find('julia', version, arch); juliaPath = tc.find('julia', version, arch);
if (!juliaPath) { if (!juliaPath) {
core.debug(`could not find Julia ${version} in cache`); core.debug(`could not find Julia ${arch}/${version} in cache`);
const juliaInstallationPath = yield installer.installJulia(version, arch); const juliaInstallationPath = yield installer.installJulia(versionInfo, version, arch);
// Add it to cache // Add it to cache
juliaPath = yield tc.cacheDir(juliaInstallationPath, 'julia', version, arch); juliaPath = yield tc.cacheDir(juliaInstallationPath, 'julia', version, arch);
core.debug(`added Julia to cache: ${juliaPath}`); core.debug(`added Julia to cache: ${juliaPath}`);

36
package-lock.json generated
View File

@@ -5461,6 +5461,36 @@
"integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==",
"dev": true "dev": true
}, },
"nock": {
"version": "11.7.2",
"resolved": "https://registry.npmjs.org/nock/-/nock-11.7.2.tgz",
"integrity": "sha512-7swr5bL1xBZ5FctyubjxEVySXOSebyqcL7Vy1bx1nS9IUqQWj81cmKjVKJLr8fHhtzI1MV8nyCdENA/cGcY1+Q==",
"dev": true,
"requires": {
"debug": "^4.1.0",
"json-stringify-safe": "^5.0.1",
"lodash": "^4.17.13",
"mkdirp": "^0.5.0",
"propagate": "^2.0.0"
},
"dependencies": {
"debug": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
"dev": true,
"requires": {
"ms": "^2.1.1"
}
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"dev": true
}
}
},
"node-int64": { "node-int64": {
"version": "0.4.0", "version": "0.4.0",
"resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz",
@@ -5821,6 +5851,12 @@
"sisteransi": "^1.0.4" "sisteransi": "^1.0.4"
} }
}, },
"propagate": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/propagate/-/propagate-2.0.1.tgz",
"integrity": "sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag==",
"dev": true
},
"psl": { "psl": {
"version": "1.7.0", "version": "1.7.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.7.0.tgz", "resolved": "https://registry.npmjs.org/psl/-/psl-1.7.0.tgz",

View File

@@ -34,6 +34,7 @@
"@zeit/ncc": "^0.22.0", "@zeit/ncc": "^0.22.0",
"jest": "^24.8.0", "jest": "^24.8.0",
"jest-circus": "^24.7.1", "jest-circus": "^24.7.1",
"nock": "^11.7.2",
"prettier": "^1.17.1", "prettier": "^1.17.1",
"ts-jest": "^26.0.0", "ts-jest": "^26.0.0",
"typescript": "^3.5.1" "typescript": "^3.5.1"

View File

@@ -8,12 +8,42 @@ import * as path from 'path'
import * as semver from 'semver' import * as semver from 'semver'
// Translations between actions input and Julia arch names
const osMap = {
'win32': 'winnt',
'darwin': 'mac',
'linux': 'linux'
}
const archMap = {
'x86': 'i686',
'x64': 'x86_64'
}
// Store information about the environment // Store information about the environment
const osPlat = os.platform() // possible values: win32 (Windows), linux (Linux), darwin (macOS) const osPlat = os.platform() // possible values: win32 (Windows), linux (Linux), darwin (macOS)
core.debug(`platform: ${osPlat}`) core.debug(`platform: ${osPlat}`)
// This is temporary until we have a better way of fetching releases (see #1, #4 for details) /**
export const juliaVersions = ['v1.5.2', 'v1.5.1', 'v1.5.0', 'v1.5.0-rc2', 'v1.5.0-rc1', 'v1.5.0-beta1', 'v1.4.2', 'v1.4.1', 'v1.4.0', 'v1.4.0-rc2', 'v1.4.0-rc1', 'v1.3.1', 'v1.3.0', 'v1.3.0-rc5', 'v1.3.0-rc4', 'v1.3.0-rc3', 'v1.3.0-rc2', 'v1.0.5', 'v1.2.0', 'v1.3.0-rc1', 'v1.2.0-rc3', 'v1.3.0-alpha', 'v1.2.0-rc2', 'v1.2.0-rc1', 'v1.1.1', 'v1.0.4', 'v1.1.0', 'v1.1.0-rc2', 'v1.1.0-rc1', 'v1.0.3', 'v1.0.2', 'v1.0.1', 'v1.0.0', 'v0.7.0', 'v1.0.0-rc1', 'v0.7.0-rc3', 'v0.7.0-rc2', 'v0.7.0-rc1', 'v0.7.0-beta2', 'v0.6.4', 'v0.7.0-beta', 'v0.7.0-alpha', 'v0.6.3', 'v0.6.2', 'v0.6.1', 'v0.6.0', 'v0.6.0-rc3', 'v0.6.0-rc2', 'v0.5.2', 'v0.6.0-rc1', 'v0.6.0-pre.beta', 'v0.5.1', 'v0.6.0-pre.alpha', 'v0.5.0', 'v0.4.7', 'v0.5.0-rc4', 'v0.5.0-rc3', 'v0.5.0-rc2', 'v0.5.0-rc1', 'v0.5.0-rc0', 'v0.4.6', 'v0.4.5', 'v0.4.4', 'v0.4.3', 'v0.4.2', 'v0.4.1', 'v0.3.12', 'v0.4.0', 'v0.4.0-rc4', 'v0.4.0-rc3', 'v0.4.0-rc2', 'v0.4.0-rc1', 'v0.3.11', 'v0.3.10', 'v0.3.9', 'v0.3.8', 'v0.3.7', 'v0.3.6', 'v0.3.5', 'v0.3.4', 'v0.3.3', 'v0.3.2', 'v0.3.1', 'v0.3.0', 'v0.3.0-rc4', 'v0.3.0-rc3', 'v0.3.0-rc2', 'v0.3.0-rc1', 'v0.2.0-rc1', 'v0.2.0-rc3', 'v0.2.0-rc4', 'v0.2.0', 'v0.2.0-rc2'] * @returns The content of the downloaded versions.json file as object.
*/
export async function getJuliaVersionInfo(): Promise<object> {
const versionsFile = await tc.downloadTool('https://julialang-s3.julialang.org/bin/versions.json')
return JSON.parse(fs.readFileSync(versionsFile).toString())
}
/**
* @returns An array of all Julia versions available for download
*/
export async function getJuliaVersions(versionInfo): Promise<string[]> {
let versions: string[] = []
for (let version in versionInfo) {
versions.push(version)
}
return versions
}
export function getJuliaVersion(availableReleases: string[], versionInput: string): string { export function getJuliaVersion(availableReleases: string[], versionInput: string): string {
if (semver.valid(versionInput) == versionInput) { if (semver.valid(versionInput) == versionInput) {
@@ -38,68 +68,48 @@ export function getJuliaVersion(availableReleases: string[], versionInput: strin
return version return version
} }
function getMajorMinorVersion(version: string): string { function getNightlyFileName(arch: string): string {
return version.split('.').slice(0, 2).join('.')
}
function getDownloadURL(version: string, arch: string): string {
let platform: string
if (osPlat === 'win32') { // Windows
platform = 'winnt'
} else if (osPlat === 'darwin') { // macOS
if (arch == 'x86') {
throw new Error('32-bit Julia is not available on macOS')
}
platform = 'mac'
} else if (osPlat === 'linux') { // Linux
platform = 'linux'
} else {
throw new Error(`Platform ${osPlat} is not supported`)
}
// nightlies
if (version == 'nightly') {
const baseURL = 'https://julialangnightlies-s3.julialang.org/bin'
return `${baseURL}/${platform}/${arch}/${getFileName('latest', arch)}`
}
// normal versions
const baseURL = 'https://julialang-s3.julialang.org/bin'
const versionDir = getMajorMinorVersion(version)
return `${baseURL}/${platform}/${arch}/${versionDir}/${getFileName(version, arch)}`
}
function getFileName(version: string, arch: string): string {
let versionExt: string, ext: string let versionExt: string, ext: string
if (osPlat === 'win32') { // Windows if (osPlat == 'win32') {
versionExt = arch == 'x64' ? '-win64' : '-win32' versionExt = arch == 'x64' ? '-win64' : '-win32'
ext = 'exe' ext = 'exe'
} else if (osPlat === 'darwin') { // macOS } else if (osPlat == 'darwin') {
if (arch == 'x86') { if (arch == 'x86') {
throw new Error('32-bit Julia is not available on macOS') throw new Error('32-bit Julia is not available on macOS')
} }
versionExt = '-mac64' versionExt = '-mac64'
ext = 'dmg' ext = 'dmg'
} else if (osPlat === 'linux') { // Linux } else if (osPlat === 'linux') {
if (version == 'latest') { // nightly version versionExt = arch == 'x64' ? '-linux64' : '-linux32'
versionExt = arch == 'x64' ? '-linux64' : '-linux32'
} else {
versionExt = arch == 'x64' ? '-linux-x86_64' : '-linux-i686'
}
ext = 'tar.gz' ext = 'tar.gz'
} else { } else {
throw new Error(`Platform ${osPlat} is not supported`) throw new Error(`Platform ${osPlat} is not supported`)
} }
return `julia-${version}${versionExt}.${ext}` return `julia-latest${versionExt}.${ext}`
} }
export async function installJulia(version: string, arch: string): Promise<string> { export function getDownloadURL(versionInfo, version: string, arch: string): string {
// nightlies
if (version == 'nightly') {
const baseURL = 'https://julialangnightlies-s3.julialang.org/bin'
return `${baseURL}/${osMap[osPlat]}/${arch}/${getNightlyFileName(arch)}`
}
for (let file of versionInfo[version].files) {
if (file.os == osMap[osPlat] && file.arch == archMap[arch]) {
core.debug(file)
return file.url
}
}
throw `Could not find ${archMap[arch]}/${version} binaries`
}
export async function installJulia(versionInfo, version: string, arch: string): Promise<string> {
// Download Julia // Download Julia
const downloadURL = getDownloadURL(version, arch) const downloadURL = getDownloadURL(versionInfo, version, arch)
core.debug(`downloading Julia from ${downloadURL}`) core.debug(`downloading Julia from ${downloadURL}`)
const juliaDownloadPath = await tc.downloadTool(downloadURL) const juliaDownloadPath = await tc.downloadTool(downloadURL)

View File

@@ -44,7 +44,8 @@ async function run() {
throw new Error(`Arch input must not be null`) throw new Error(`Arch input must not be null`)
} }
const availableReleases = installer.juliaVersions const versionInfo = await installer.getJuliaVersionInfo()
const availableReleases = await installer.getJuliaVersions(versionInfo)
const version = installer.getJuliaVersion(availableReleases, versionInput) const version = installer.getJuliaVersion(availableReleases, versionInput)
core.debug(`selected Julia version: ${arch}/${version}`) core.debug(`selected Julia version: ${arch}/${version}`)
@@ -53,8 +54,8 @@ async function run() {
juliaPath = tc.find('julia', version, arch) juliaPath = tc.find('julia', version, arch)
if (!juliaPath) { if (!juliaPath) {
core.debug(`could not find Julia ${version} in cache`) core.debug(`could not find Julia ${arch}/${version} in cache`)
const juliaInstallationPath = await installer.installJulia(version, arch); const juliaInstallationPath = await installer.installJulia(versionInfo, version, arch)
// Add it to cache // Add it to cache
juliaPath = await tc.cacheDir(juliaInstallationPath, 'julia', version, arch) juliaPath = await tc.cacheDir(juliaInstallationPath, 'julia', version, arch)