From a2f8e189b328253b93fc5bba5362710bf9e9654b Mon Sep 17 00:00:00 2001 From: Bodigrim Date: Wed, 14 Dec 2022 20:27:07 +0000 Subject: [PATCH] Don't fall back to ppa:hvr/ghc, ghcup is sufficient in all cases --- setup/README.md | 2 +- setup/dist/index.js | 21 ++------------------- setup/src/installer.ts | 24 ++---------------------- 3 files changed, 5 insertions(+), 42 deletions(-) diff --git a/setup/README.md b/setup/README.md index 8c99502d..07248841 100644 --- a/setup/README.md +++ b/setup/README.md @@ -9,7 +9,7 @@ This action sets up a Haskell environment for use in actions by: - setting the outputs of `ghc-path`, `cabal-path`, `stack-path`, and `cabal-store` when necessary. The GitHub runners come with [pre-installed versions of GHC and Cabal](https://help.github.com/en/actions/reference/software-installed-on-github-hosted-runners). Those will be used whenever possible. -For all other versions, this action utilizes [`ppa:hvr/ghc`](https://launchpad.net/~hvr/+archive/ubuntu/ghc), [`ghcup`](https://gitlab.haskell.org/haskell/ghcup-hs), and [`chocolatey`](https://chocolatey.org/packages/ghc). +For all other versions, this action utilizes [`ghcup`](https://gitlab.haskell.org/haskell/ghcup-hs), and [`chocolatey`](https://chocolatey.org/packages/ghc). ## Usage diff --git a/setup/dist/index.js b/setup/dist/index.js index ae262701..d2f1e8f9 100644 --- a/setup/dist/index.js +++ b/setup/dist/index.js @@ -13350,29 +13350,22 @@ function warn(tool, version) { 'If the list is outdated, please file an issue here: https://github.com/actions/virtual-environments\n' + 'by using the appropriate tool request template: https://github.com/actions/virtual-environments/issues/new/choose'); } -function aptVersion(tool, version) { - // For Cabal, extract the first two segments of the version number. This - // regex is intentionally liberal to accomodate unusual cases like "head". - return tool === 'cabal' ? /[^.]*\.?[^.]*/.exec(version)[0] : version; -} async function isInstalled(tool, version, os) { const toolPath = tc.find(tool, version); if (toolPath) return success(tool, version, toolPath, os); const ghcupPath = `${process_1.default.env.HOME}/.ghcup${tool === 'ghc' ? `/ghc/${version}` : ''}/bin`; - const v = aptVersion(tool, version); - const aptPath = `/opt/${tool}/${v}/bin`; const chocoPath = await getChocoPath(tool, version); const locations = { stack: [], cabal: { win32: [chocoPath], - linux: [aptPath], + linux: [], darwin: [] }[os], ghc: { win32: [chocoPath], - linux: [aptPath, ghcupPath], + linux: [ghcupPath], darwin: [ghcupPath] }[os] }; @@ -13427,9 +13420,6 @@ async function installTool(tool, version, os) { await aptLibNCurses5(); } await ghcup(tool, version, os); - if (await isInstalled(tool, version, os)) - return; - await apt(tool, version); break; case 'win32': await choco(tool, version); @@ -13492,13 +13482,6 @@ async function aptLibNCurses5() { const returnCode = await exec(`sudo -- sh -c "apt-get update && apt-get -y install libncurses5 libtinfo5"`); return returnCode === 0; } -async function apt(tool, version) { - const toolName = tool === 'ghc' ? 'ghc' : 'cabal-install'; - const v = aptVersion(tool, version); - core.info(`Attempting to install ${toolName} ${v} using apt-get`); - // Ignore the return code so we can fall back to ghcup - await exec(`sudo -- sh -c "add-apt-repository -y ppa:hvr/ghc && apt-get update && apt-get -y install ${toolName}-${v}"`); -} async function choco(tool, version) { core.info(`Attempting to install ${tool} ${version} using chocolatey`); // Choco tries to invoke `add-path` command on earlier versions of ghc, which has been deprecated and fails the step, so disable command execution during this. diff --git a/setup/src/installer.ts b/setup/src/installer.ts index ef221850..4e0e1251 100644 --- a/setup/src/installer.ts +++ b/setup/src/installer.ts @@ -65,12 +65,6 @@ function warn(tool: Tool, version: string): void { ); } -function aptVersion(tool: string, version: string): string { - // For Cabal, extract the first two segments of the version number. This - // regex is intentionally liberal to accomodate unusual cases like "head". - return tool === 'cabal' ? /[^.]*\.?[^.]*/.exec(version)![0] : version; -} - async function isInstalled( tool: Tool, version: string, @@ -82,8 +76,6 @@ async function isInstalled( const ghcupPath = `${process.env.HOME}/.ghcup${ tool === 'ghc' ? `/ghc/${version}` : '' }/bin`; - const v = aptVersion(tool, version); - const aptPath = `/opt/${tool}/${v}/bin`; const chocoPath = await getChocoPath(tool, version); @@ -91,12 +83,12 @@ async function isInstalled( stack: [], // Always installed into the tool cache cabal: { win32: [chocoPath], - linux: [aptPath], + linux: [], darwin: [] }[os], ghc: { win32: [chocoPath], - linux: [aptPath, ghcupPath], + linux: [ghcupPath], darwin: [ghcupPath] }[os] }; @@ -162,8 +154,6 @@ export async function installTool( await aptLibNCurses5(); } await ghcup(tool, version, os); - if (await isInstalled(tool, version, os)) return; - await apt(tool, version); break; case 'win32': await choco(tool, version); @@ -245,16 +235,6 @@ async function aptLibNCurses5(): Promise { return returnCode === 0; } -async function apt(tool: Tool, version: string): Promise { - const toolName = tool === 'ghc' ? 'ghc' : 'cabal-install'; - const v = aptVersion(tool, version); - core.info(`Attempting to install ${toolName} ${v} using apt-get`); - // Ignore the return code so we can fall back to ghcup - await exec( - `sudo -- sh -c "add-apt-repository -y ppa:hvr/ghc && apt-get update && apt-get -y install ${toolName}-${v}"` - ); -} - async function choco(tool: Tool, version: string): Promise { core.info(`Attempting to install ${tool} ${version} using chocolatey`); // Choco tries to invoke `add-path` command on earlier versions of ghc, which has been deprecated and fails the step, so disable command execution during this.