mirror of
https://github.com/julia-actions/setup-julia.git
synced 2026-02-12 11:06:53 +08:00
35
README.md
35
README.md
@@ -104,15 +104,42 @@ You can either specify specific Julia versions or version ranges. If you specify
|
|||||||
|
|
||||||
- `1.2.0` is a valid semver version. The action will try to download exactly this version. If it's not available, the build step will fail.
|
- `1.2.0` is a valid semver version. The action will try to download exactly this version. If it's not available, the build step will fail.
|
||||||
- `1.0` is a version range that will match the highest available Julia version that starts with `1.0`, e.g. `1.0.5`, excluding pre-releases.
|
- `1.0` is a version range that will match the highest available Julia version that starts with `1.0`, e.g. `1.0.5`, excluding pre-releases.
|
||||||
- `^1.3.0-rc1` is a **caret** version range that includes pre-releases starting at `rc1`. It matches all versions `≥ 1.3.0-rc1` and `< 2.0.0`.
|
- `^1.3.0-rc1` is a **caret** version range that includes pre-releases of `1.3.0` starting at `rc1`. It matches all versions `≥ 1.3.0-rc1` and `< 2.0.0`.
|
||||||
- `~1.3.0-rc1` is a **tilde** version range that includes pre-releases starting at `rc1`. It matches all versions `≥ 1.3.0-rc1` and `< 1.4.0`.
|
- `~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. It matches all versions `≥ 1.3.0-` and `< 2.0.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. It matches all versions `≥ 1.3.0-` and `< 1.4.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`.
|
||||||
- `nightly` will install the latest nightly 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.
|
- `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.
|
||||||
|
|
||||||
Internally the action uses node's semver package to resolve version ranges. Its [documentation](https://github.com/npm/node-semver#advanced-range-syntax) contains more details on the version range syntax. You can test what version will be selected for a given input in this JavaScript [REPL](https://repl.it/@SaschaMann/setup-julia-version-logic).
|
Internally the action uses node's semver package to resolve version ranges. Its [documentation](https://github.com/npm/node-semver#advanced-range-syntax) contains more details on the version range syntax. You can test what version will be selected for a given input in this JavaScript [REPL](https://repl.it/@SaschaMann/setup-julia-version-logic).
|
||||||
|
|
||||||
|
#### Prereleases
|
||||||
|
|
||||||
|
There are two methods of including pre-releases in version matching:
|
||||||
|
|
||||||
|
1. Including the pre-release tag in the version itself, e.g. `^1.3.0-rc1`.
|
||||||
|
2. Setting the input `include-all-prereleases` to `true`.
|
||||||
|
|
||||||
|
These behave slightly differently.
|
||||||
|
|
||||||
|
1. If the version `a.b.c` contains pre-release tag, all pre-releases of version `a.b.c` will be included in the version matching.
|
||||||
|
For example, `^1.3.0-rc1` would match `1.3.0-rc2` but would **not** match `1.4.0-rc1` once released.
|
||||||
|
2. If `include-preleases` is set to true, **all** pre-releases of all versions will be included in the version matching. In this case, `^1.3.0-rc1` would match `1.4.0-rc1` once released.
|
||||||
|
|
||||||
|
**Example:** Without `include-all-prereleases: true`, the version `^1.3.0-rc1` would match `1.3.0-rc1`, `1.3.0-rc2`, `1.3.0`, `1.4.0` once they are released.
|
||||||
|
With `include-all-prereleases: true`, it would match `1.3.0-rc1`, `1.3.0-rc2`, `1.3.0`, `1.4.0-rc1`, `1.4.0`.
|
||||||
|
|
||||||
|
If you want to run tests against the latest tagged version, no matter what version that is, you can use
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: julia-actions/setup-julia@v1
|
||||||
|
with:
|
||||||
|
version: '1'
|
||||||
|
include-all-prereleases: true
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Recently released versions
|
||||||
|
|
||||||
The available Julia versions are pulled from [`versions.json`](https://julialang-s3.julialang.org/bin/versions.json). This file is automatically updated once a day. Therefore it may take up to 24 hours until a newly released Julia version is available in the action.
|
The available Julia versions are pulled from [`versions.json`](https://julialang-s3.julialang.org/bin/versions.json). This file is automatically updated once a day. Therefore it may take up to 24 hours until a newly released Julia version is available in the action.
|
||||||
|
|
||||||
### Matrix Testing
|
### Matrix Testing
|
||||||
|
|||||||
@@ -66,6 +66,14 @@ describe('version matching tests', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
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')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('node-semver behaviour', () => {
|
describe('node-semver behaviour', () => {
|
||||||
describe('Windows installer change', () => {
|
describe('Windows installer change', () => {
|
||||||
it('Correctly understands >1.4.0', () => {
|
it('Correctly understands >1.4.0', () => {
|
||||||
|
|||||||
@@ -5,6 +5,10 @@ inputs:
|
|||||||
version:
|
version:
|
||||||
description: 'The Julia version to download (if necessary) and use. Example: 1.0.4'
|
description: 'The Julia version to download (if necessary) and use. Example: 1.0.4'
|
||||||
default: '1'
|
default: '1'
|
||||||
|
include-all-prereleases:
|
||||||
|
description: 'Include prereleases when matching the Julia version to available versions.'
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
arch:
|
arch:
|
||||||
description: 'Architecture of the Julia binaries. Defaults to the architecture of the runner executing the job.'
|
description: 'Architecture of the Julia binaries. Defaults to the architecture of the runner executing the job.'
|
||||||
required: false
|
required: false
|
||||||
|
|||||||
4
lib/installer.js
generated
4
lib/installer.js
generated
@@ -87,13 +87,13 @@ function getJuliaVersions(versionInfo) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.getJuliaVersions = getJuliaVersions;
|
exports.getJuliaVersions = getJuliaVersions;
|
||||||
function getJuliaVersion(availableReleases, versionInput) {
|
function getJuliaVersion(availableReleases, versionInput, includePrerelease = false) {
|
||||||
if (semver.valid(versionInput) == versionInput || versionInput.endsWith('nightly')) {
|
if (semver.valid(versionInput) == versionInput || versionInput.endsWith('nightly')) {
|
||||||
// versionInput is a valid version or a nightly version, use it directly
|
// versionInput is a valid version or a nightly version, use it directly
|
||||||
return versionInput;
|
return versionInput;
|
||||||
}
|
}
|
||||||
// Use the highest available version that matches versionInput
|
// Use the highest available version that matches versionInput
|
||||||
let version = semver.maxSatisfying(availableReleases, versionInput);
|
let version = semver.maxSatisfying(availableReleases, versionInput, { includePrerelease });
|
||||||
if (version == null) {
|
if (version == null) {
|
||||||
throw new Error(`Could not find a Julia version that matches ${versionInput}`);
|
throw new Error(`Could not find a Julia version that matches ${versionInput}`);
|
||||||
}
|
}
|
||||||
|
|||||||
3
lib/setup-julia.js
generated
3
lib/setup-julia.js
generated
@@ -49,6 +49,7 @@ function run() {
|
|||||||
}
|
}
|
||||||
// Inputs
|
// Inputs
|
||||||
const versionInput = core.getInput('version');
|
const versionInput = core.getInput('version');
|
||||||
|
const includePrereleases = core.getInput('include-all-prereleases') == 'true';
|
||||||
const originalArchInput = core.getInput('arch');
|
const originalArchInput = core.getInput('arch');
|
||||||
// It can easily happen that, for example, a workflow file contains an input `version: ${{ matrix.julia-version }}`
|
// It can easily happen that, for example, a workflow file contains an input `version: ${{ matrix.julia-version }}`
|
||||||
// while the strategy matrix only contains a key `${{ matrix.version }}`.
|
// while the strategy matrix only contains a key `${{ matrix.version }}`.
|
||||||
@@ -64,7 +65,7 @@ function run() {
|
|||||||
const arch = archSynonyms[originalArchInput];
|
const arch = archSynonyms[originalArchInput];
|
||||||
const versionInfo = yield installer.getJuliaVersionInfo();
|
const versionInfo = yield installer.getJuliaVersionInfo();
|
||||||
const availableReleases = yield installer.getJuliaVersions(versionInfo);
|
const availableReleases = yield installer.getJuliaVersions(versionInfo);
|
||||||
const version = installer.getJuliaVersion(availableReleases, versionInput);
|
const version = installer.getJuliaVersion(availableReleases, versionInput, includePrereleases);
|
||||||
core.debug(`selected Julia version: ${arch}/${version}`);
|
core.debug(`selected Julia version: ${arch}/${version}`);
|
||||||
core.setOutput('julia-version', version);
|
core.setOutput('julia-version', version);
|
||||||
// Search in cache
|
// Search in cache
|
||||||
|
|||||||
@@ -75,14 +75,14 @@ export async function getJuliaVersions(versionInfo): Promise<string[]> {
|
|||||||
return versions
|
return versions
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getJuliaVersion(availableReleases: string[], versionInput: string): string {
|
export function getJuliaVersion(availableReleases: string[], versionInput: string, includePrerelease: boolean = false): string {
|
||||||
if (semver.valid(versionInput) == versionInput || versionInput.endsWith('nightly')) {
|
if (semver.valid(versionInput) == versionInput || versionInput.endsWith('nightly')) {
|
||||||
// versionInput is a valid version or a nightly version, use it directly
|
// versionInput is a valid version or a nightly version, use it directly
|
||||||
return versionInput
|
return versionInput
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use the highest available version that matches versionInput
|
// Use the highest available version that matches versionInput
|
||||||
let version = semver.maxSatisfying(availableReleases, versionInput)
|
let version = semver.maxSatisfying(availableReleases, versionInput, {includePrerelease})
|
||||||
if (version == null) {
|
if (version == null) {
|
||||||
throw new Error(`Could not find a Julia version that matches ${versionInput}`)
|
throw new Error(`Could not find a Julia version that matches ${versionInput}`)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ async function run() {
|
|||||||
|
|
||||||
// Inputs
|
// Inputs
|
||||||
const versionInput = core.getInput('version')
|
const versionInput = core.getInput('version')
|
||||||
|
const includePrereleases = core.getInput('include-all-prereleases') == 'true'
|
||||||
const originalArchInput = core.getInput('arch')
|
const originalArchInput = core.getInput('arch')
|
||||||
|
|
||||||
// It can easily happen that, for example, a workflow file contains an input `version: ${{ matrix.julia-version }}`
|
// It can easily happen that, for example, a workflow file contains an input `version: ${{ matrix.julia-version }}`
|
||||||
@@ -57,7 +58,7 @@ async function run() {
|
|||||||
|
|
||||||
const versionInfo = await installer.getJuliaVersionInfo()
|
const versionInfo = await installer.getJuliaVersionInfo()
|
||||||
const availableReleases = await installer.getJuliaVersions(versionInfo)
|
const availableReleases = await installer.getJuliaVersions(versionInfo)
|
||||||
const version = installer.getJuliaVersion(availableReleases, versionInput)
|
const version = installer.getJuliaVersion(availableReleases, versionInput, includePrereleases)
|
||||||
core.debug(`selected Julia version: ${arch}/${version}`)
|
core.debug(`selected Julia version: ${arch}/${version}`)
|
||||||
core.setOutput('julia-version', version)
|
core.setOutput('julia-version', version)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user