From d8110230de9b4ef8aaf820b58052e26195b05ad4 Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Thu, 23 Jul 2020 12:35:18 +0100 Subject: [PATCH 1/2] Update ghcup to 0.1.8 and add ghc-8.8.4 support Need to make the apt install function not error whenever it returns a non-zero exit code, because ghc-8.8.4 isn't available via apt just yet --- dist/index.js | 9 ++++++--- src/installer.ts | 7 +++++-- src/versions.json | 1 + 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/dist/index.js b/dist/index.js index 6d3f838..2bbacc8 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4334,7 +4334,7 @@ function escapeProperty(s) { /***/ 447: /***/ (function(module) { -module.exports = {"ghc":["8.10.1","8.8.3","8.8.2","8.8.1","8.6.5","8.6.4","8.6.3","8.6.2","8.6.1","8.4.4","8.4.3","8.4.2","8.4.1","8.2.2","8.0.2","7.10.3"],"cabal":["3.2.0.0","3.0.0.0","2.4.1.0","2.4.0.0","2.2.0.0"],"stack":["2.3.1","2.1.3","2.1.1","1.9.3","1.9.1","1.7.1","1.6.5","1.6.3","1.6.1","1.5.1","1.5.0","1.4.0","1.3.2","1.3.0","1.2.0"]}; +module.exports = {"ghc":["8.10.1","8.8.4","8.8.3","8.8.2","8.8.1","8.6.5","8.6.4","8.6.3","8.6.2","8.6.1","8.4.4","8.4.3","8.4.2","8.4.1","8.2.2","8.0.2","7.10.3"],"cabal":["3.2.0.0","3.0.0.0","2.4.1.0","2.4.0.0","2.2.0.0"],"stack":["2.3.1","2.1.3","2.1.1","1.9.3","1.9.1","1.7.1","1.6.5","1.6.3","1.6.1","1.5.1","1.5.0","1.4.0","1.3.2","1.3.0","1.2.0"]}; /***/ }), @@ -11095,7 +11095,10 @@ async function apt(tool, version) { const toolName = tool === 'ghc' ? 'ghc' : 'cabal-install'; const v = tool === 'cabal' ? version.slice(0, 3) : version; core.info(`Attempting to install ${toolName} ${v} using apt-get`); - await exec_1.exec(`sudo -- sh -c "apt-get -y install ${toolName}-${v}"`); + // Ignore the return code so we can fall back to ghcup + await exec_1.exec(`sudo -- sh -c "apt-get -y install ${toolName}-${v}"`, undefined, { + ignoreReturnCode: true + }); } async function choco(tool, version) { core.info(`Attempting to install ${tool} ${version} using chocolatey`); @@ -11111,7 +11114,7 @@ async function choco(tool, version) { ]); } async function ghcupBin(os) { - const v = '0.1.5'; + const v = '0.1.8'; const cachedBin = tc.find('ghcup', v); if (cachedBin) return path_1.join(cachedBin, 'ghcup'); diff --git a/src/installer.ts b/src/installer.ts index 3d5967f..d71c42f 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -161,7 +161,10 @@ async function apt(tool: Tool, version: string): Promise { const toolName = tool === 'ghc' ? 'ghc' : 'cabal-install'; const v = tool === 'cabal' ? version.slice(0, 3) : version; core.info(`Attempting to install ${toolName} ${v} using apt-get`); - await exec(`sudo -- sh -c "apt-get -y install ${toolName}-${v}"`); + // Ignore the return code so we can fall back to ghcup + await exec(`sudo -- sh -c "apt-get -y install ${toolName}-${v}"`, undefined, { + ignoreReturnCode: true + }); } async function choco(tool: Tool, version: string): Promise { @@ -180,7 +183,7 @@ async function choco(tool: Tool, version: string): Promise { } async function ghcupBin(os: OS): Promise { - const v = '0.1.5'; + const v = '0.1.8'; const cachedBin = tc.find('ghcup', v); if (cachedBin) return join(cachedBin, 'ghcup'); diff --git a/src/versions.json b/src/versions.json index ecc96dd..f13493c 100644 --- a/src/versions.json +++ b/src/versions.json @@ -1,6 +1,7 @@ { "ghc": [ "8.10.1", + "8.8.4", "8.8.3", "8.8.2", "8.8.1", From c2e19a92bb0ac0c8b2cfb756147f1da9464cc539 Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Mon, 27 Jul 2020 13:27:27 +0100 Subject: [PATCH 2/2] Ignore exit code for choco and ghcup installs This means that they can now fallback to alternatve install options --- dist/index.js | 10 +++++++--- src/installer.ts | 36 ++++++++++++++++++++++++------------ 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/dist/index.js b/dist/index.js index 2bbacc8..4f015b2 100644 --- a/dist/index.js +++ b/dist/index.js @@ -11111,7 +11111,9 @@ async function choco(tool, version) { '-m', '--no-progress', '-r' - ]); + ], { + ignoreReturnCode: true + }); } async function ghcupBin(os) { const v = '0.1.8'; @@ -11125,8 +11127,10 @@ async function ghcupBin(os) { async function ghcup(tool, version, os) { core.info(`Attempting to install ${tool} ${version} using ghcup`); const bin = await ghcupBin(os); - await exec_1.exec(bin, [tool === 'ghc' ? 'install' : 'install-cabal', version]); - if (tool === 'ghc') + const returnCode = await exec_1.exec(bin, [tool === 'ghc' ? 'install' : 'install-cabal', version], { + ignoreReturnCode: true + }); + if (returnCode === 0 && tool === 'ghc') await exec_1.exec(bin, ['set', version]); } diff --git a/src/installer.ts b/src/installer.ts index d71c42f..e7b47f8 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -170,16 +170,22 @@ async function apt(tool: Tool, version: string): Promise { async function choco(tool: Tool, version: string): Promise { core.info(`Attempting to install ${tool} ${version} using chocolatey`); - await exec('powershell', [ - 'choco', - 'install', - tool, - '--version', - version, - '-m', - '--no-progress', - '-r' - ]); + await exec( + 'powershell', + [ + 'choco', + 'install', + tool, + '--version', + version, + '-m', + '--no-progress', + '-r' + ], + { + ignoreReturnCode: true + } + ); } async function ghcupBin(os: OS): Promise { @@ -199,6 +205,12 @@ async function ghcupBin(os: OS): Promise { async function ghcup(tool: Tool, version: string, os: OS): Promise { core.info(`Attempting to install ${tool} ${version} using ghcup`); const bin = await ghcupBin(os); - await exec(bin, [tool === 'ghc' ? 'install' : 'install-cabal', version]); - if (tool === 'ghc') await exec(bin, ['set', version]); + const returnCode = await exec( + bin, + [tool === 'ghc' ? 'install' : 'install-cabal', version], + { + ignoreReturnCode: true + } + ); + if (returnCode === 0 && tool === 'ghc') await exec(bin, ['set', version]); }