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

Allow lts for the LTS, and allow pre for the latest pre-release #234

Merged
merged 9 commits into from
Jun 26, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/example-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
fail-fast: false
matrix:
julia-version: ['1.0.5', '1.2', '^1.5.0-beta1', '1']
julia-version: ['1.0.5', '1.2', '^1.5.0-beta1', '1', 'lts', 'pre']
julia-arch: [x64, x86]
os: [ubuntu-latest, macOS-latest, windows-latest]
# 32-bit Julia binaries are not available on macOS
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ You can either specify specific Julia versions or version ranges. If you specify
- `'~1.3.0-rc1'` is a **tilde** version range that includes pre-releases of `1.3.0` starting at `rc1`. It matches all versions `≥ 1.3.0-rc1` and `< 1.4.0`.
- `'^1.3.0-0'` is a **caret** version range that includes _all_ pre-releases of `1.3.0`. It matches all versions `≥ 1.3.0-` and `< 2.0.0`.
- `'~1.3.0-0'` is a **tilde** version range that includes _all_ pre-releases of `1.3.0`. It matches all versions `≥ 1.3.0-` and `< 1.4.0`.
- `'lts'` will install the latest LTS build.
- `'pre'` will install the latest prerelease build.
- `'nightly'` will install the latest nightly build.
- `'1.7-nightly'` will install the latest nightly build for the upcoming 1.7 release. This version will only be available during certain phases of the Julia release cycle.

Expand Down
18,729 changes: 16,273 additions & 2,456 deletions __tests__/fixtures/versions.json

Large diffs are not rendered by default.

63 changes: 37 additions & 26 deletions __tests__/installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@
import * as path from 'path'

import * as io from '@actions/io'
import * as semver from 'semver'

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'
'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', '1.3.0-alpha', '1.3.0-rc1', '1.3.0-rc2', '1.3.0-rc3', '1.3.0-rc4', '1.3.0-rc5', '1.3.1',
'1.4.0', '1.4.0-rc1', '1.4.0-rc2', '1.4.1', '1.4.2',
'1.5.0', '1.5.0-beta1', '1.5.0-rc1', '1.5.0-rc2', '1.5.1', '1.5.2', '1.5.3', '1.5.4',
'1.6.0', '1.6.0-beta1', '1.6.0-rc1', '1.6.0-rc2', '1.6.0-rc3', '1.6.1', '1.6.2', '1.6.3', '1.6.4', '1.6.5', '1.6.6', '1.6.7',
'1.7.0', '1.7.0-beta1', '1.7.0-beta2', '1.7.0-beta3', '1.7.0-beta4', '1.7.0-rc1', '1.7.0-rc2', '1.7.0-rc3', '1.7.1', '1.7.2', '1.7.3',
'1.8.0', '1.8.0-beta1', '1.8.0-beta2', '1.8.0-beta3', '1.8.0-rc1', '1.8.0-rc2', '1.8.0-rc3', '1.8.0-rc4', '1.8.1', '1.8.2', '1.8.3', '1.8.4', '1.8.5',
'1.9.0', '1.9.0-alpha1', '1.9.0-beta1', '1.9.0-beta2', '1.9.0-beta3', '1.9.0-beta4', '1.9.0-rc1', '1.9.0-rc2', '1.9.0-rc3', '1.9.1', '1.9.2', '1.9.3', '1.9.4',
'1.10.0', '1.10.0-alpha1', '1.10.0-beta1', '1.10.0-beta2', '1.10.0-beta3', '1.10.0-rc1', '1.10.0-rc2', '1.10.0-rc3', '1.10.1', '1.10.2',
'1.11.0-alpha1', '1.11.0-alpha2', '1.11.0-beta1'
]

const toolDir = path.join(__dirname, 'runner', 'tools')
Expand Down Expand Up @@ -55,22 +55,33 @@ describe('version matching tests', () => {
expect(installer.getJuliaVersion([], 'nightly')).toEqual('nightly')
expect(installer.getJuliaVersion(testVersions, 'nightly')).toEqual('nightly')
})

it('LTS', () => {
// Update test when LTS is updated
expect(installer.getJuliaVersion(testVersions, 'lts')).toEqual(installer.getJuliaVersion(testVersions, '1.6'))
expect(installer.getJuliaVersion(testVersions, 'lts')).toEqual('1.6.7')
})

it('pre', () => {
expect(installer.getJuliaVersion(testVersions, 'pre')).toEqual('1.11.0-beta1')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KristofferC Will this test will need to be updated every time there's a new pre-release?

})
})

describe('version ranges', () => {
it('Chooses the highest available version that matches the input', () => {
expect(installer.getJuliaVersion(testVersions, '1')).toEqual('1.2.0')
expect(installer.getJuliaVersion(testVersions, '1')).toEqual('1.10.2')
expect(installer.getJuliaVersion(testVersions, '1.0')).toEqual('1.0.5')
expect(installer.getJuliaVersion(testVersions, '^1.3.0-rc1')).toEqual('1.3.0-rc4')
expect(installer.getJuliaVersion(testVersions, '^1.2.0-rc1')).toEqual('1.2.0')
expect(installer.getJuliaVersion(testVersions, '^1.3.0-rc1')).toEqual('1.10.2')
expect(installer.getJuliaVersion(testVersions, '^1.2.0-rc1')).toEqual('1.10.2')
expect(installer.getJuliaVersion(testVersions, '^1.10.0-rc1')).toEqual('1.10.2')
})
})

describe('include-prereleases', () => {
it('Chooses the highest available version that matches the input including prereleases', () => {
expect(installer.getJuliaVersion(testVersions, '^1.2.0-0', true)).toEqual('1.3.0-rc4')
expect(installer.getJuliaVersion(testVersions, '1', true)).toEqual('1.3.0-rc4')
expect(installer.getJuliaVersion(testVersions, '^1.2.0-0', false)).toEqual('1.2.0')
expect(installer.getJuliaVersion(testVersions, '^1.2.0-0', true)).toEqual('1.11.0-beta1')
expect(installer.getJuliaVersion(testVersions, '1', true)).toEqual('1.11.0-beta1')
expect(installer.getJuliaVersion(testVersions, '^1.2.0-0', false)).toEqual('1.10.2')
})
})

Expand Down
8 changes: 8 additions & 0 deletions lib/installer.js

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

11 changes: 11 additions & 0 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import retry = require('async-retry')

import * as semver from 'semver'

const LTS_VERSION = '1.6'
const MAJOR_VERSION = '1' // Could be deduced from versions.json

// Translations between actions input and Julia arch names
const osMap = {
'win32': 'winnt',
Expand Down Expand Up @@ -82,6 +85,14 @@ export function getJuliaVersion(availableReleases: string[], versionInput: strin
return versionInput
}

if (versionInput == 'lts') {
return getJuliaVersion(availableReleases, LTS_VERSION, false)
}

if (versionInput == 'pre') {
return getJuliaVersion(availableReleases, MAJOR_VERSION, true)
}

// Use the highest available version that matches versionInput
let version = semver.maxSatisfying(availableReleases, versionInput, {includePrerelease})
if (version == null) {
Expand Down
1 change: 0 additions & 1 deletion src/setup-julia.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as core from '@actions/core'
import * as exec from '@actions/exec'
import * as tc from '@actions/tool-cache'

import * as fs from 'fs'
Expand Down