From aced07b9c95ab8da2c43bfbc2f2c3d71c4a155fc Mon Sep 17 00:00:00 2001 From: Sascha Mann Date: Thu, 30 Jul 2020 13:05:57 +0200 Subject: [PATCH] Fail build when inputs are empty --- lib/setup-julia.js | 12 ++++++++++++ package-lock.json | 2 +- package.json | 2 +- src/setup-julia.ts | 14 ++++++++++++++ 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/lib/setup-julia.js b/lib/setup-julia.js index eadc716..8fc78c9 100644 --- a/lib/setup-julia.js +++ b/lib/setup-julia.js @@ -23,8 +23,20 @@ const installer = __importStar(require("./installer")); function run() { return __awaiter(this, void 0, void 0, function* () { try { + // Inputs const versionInput = core.getInput('version'); const arch = core.getInput('arch'); + // 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 }}`. + // In that case, we want the action to fail, rather than trying to download julia from an URL that's missing parts and 404ing. + // We _could_ fall back to the default but that means that builds silently do things differently than they're meant to, which + // is worse than failing the build. + if (!versionInput) { + throw new Error('Version input must not be null'); + } + if (!arch) { + throw new Error(`Arch input must not be null`); + } const availableReleases = installer.juliaVersions; const version = installer.getJuliaVersion(availableReleases, versionInput); core.debug(`selected Julia version: ${arch}/${version}`); diff --git a/package-lock.json b/package-lock.json index ac121bd..40061fb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "setup-julia", - "version": "1.1.10", + "version": "1.1.11", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 586fca1..39b700a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "setup-julia", - "version": "1.1.10", + "version": "1.1.11", "private": true, "description": "setup Julia action", "main": "lib/setup-julia.js", diff --git a/src/setup-julia.ts b/src/setup-julia.ts index 849c677..ba9d53f 100644 --- a/src/setup-julia.ts +++ b/src/setup-julia.ts @@ -8,8 +8,22 @@ import * as installer from './installer' async function run() { try { + // Inputs const versionInput = core.getInput('version') const arch = core.getInput('arch') + + // 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 }}`. + // In that case, we want the action to fail, rather than trying to download julia from an URL that's missing parts and 404ing. + // We _could_ fall back to the default but that means that builds silently do things differently than they're meant to, which + // is worse than failing the build. + if (!versionInput) { + throw new Error('Version input must not be null') + } + if (!arch) { + throw new Error(`Arch input must not be null`) + } + const availableReleases = installer.juliaVersions const version = installer.getJuliaVersion(availableReleases, versionInput) core.debug(`selected Julia version: ${arch}/${version}`)