diff --git a/.github/workflows/example-builds-nightly.yml b/.github/workflows/example-builds-nightly.yml index 623a9ac..17dcfe7 100644 --- a/.github/workflows/example-builds-nightly.yml +++ b/.github/workflows/example-builds-nightly.yml @@ -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()' diff --git a/.github/workflows/example-builds.yml b/.github/workflows/example-builds.yml index 50c7386..dfa2f2a 100644 --- a/.github/workflows/example-builds.yml +++ b/.github/workflows/example-builds.yml @@ -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()' diff --git a/README.md b/README.md index a5ce675..6bd6df6 100644 --- a/README.md +++ b/README.md @@ -43,8 +43,18 @@ This action sets up a Julia environment for use in actions by downloading a spec # Default: x64 arch: '' - # If true, display the output of InteractiveUtils.versioninfo() after installing. - # See "versioninfo" below for example usage. + # 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 # # Default: false show-versioninfo: '' @@ -179,18 +189,13 @@ jobs: ### versioninfo -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`: +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. -```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. +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. ## Versioning diff --git a/lib/installer.js b/lib/installer.js index 5ca8581..4517d60 100644 --- a/lib/installer.js +++ b/lib/installer.js @@ -184,3 +184,40 @@ 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; diff --git a/lib/setup-julia.js b/lib/setup-julia.js index 42ebdd3..8d17fc1 100644 --- a/lib/setup-julia.js +++ b/lib/setup-julia.js @@ -16,7 +16,6 @@ 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")); @@ -79,15 +78,8 @@ function run() { // Set output core.setOutput('julia-bindir', path.join(juliaPath, 'bin')); // Test if Julia has been installed and print the 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']); - } + const showVersionInfoInput = core.getInput('show-versioninfo'); + yield installer.showVersionInfo(showVersionInfoInput, version); } catch (error) { core.setFailed(error.message); diff --git a/package-lock.json b/package-lock.json index d61922c..851603f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "setup-julia", - "version": "1.5.2", + "version": "1.6.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 354f251..63ec0e8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "setup-julia", - "version": "1.5.2", + "version": "1.6.0", "private": true, "description": "setup Julia action", "main": "lib/setup-julia.js", diff --git a/src/installer.ts b/src/installer.ts index 907bfd7..ffd0f7b 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -178,3 +178,42 @@ 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 { + // --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}`) + } +} diff --git a/src/setup-julia.ts b/src/setup-julia.ts index 08bab8d..6ac61ec 100644 --- a/src/setup-julia.ts +++ b/src/setup-julia.ts @@ -75,14 +75,8 @@ async function run() { core.setOutput('julia-bindir', path.join(juliaPath, 'bin')) // Test if Julia has been installed and print the 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']) - } + const showVersionInfoInput = core.getInput('show-versioninfo') + await installer.showVersionInfo(showVersionInfoInput, version) } catch (error) { core.setFailed(error.message) }