Skip to content

Remove apt (ppa:hvr) fallback install method #121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ This action sets up a Haskell environment for use in actions by:
The GitHub runners come with [pre-installed versions of GHC and Cabal](https://github.com/actions/runner-images).
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://github.com/haskell/ghcup-hs), and
[`chocolatey`](https://chocolatey.org/packages/ghc).

Expand Down
24 changes: 3 additions & 21 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 3 additions & 21 deletions lib/installer.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 3 additions & 25 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,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 accommodate unusual cases like "head".
return tool === 'cabal' ? /[^.]*\.?[^.]*/.exec(version)![0] : version;
}

async function isInstalled(
tool: Tool,
version: string,
Expand All @@ -79,10 +73,6 @@ async function isInstalled(
const ghcupPath =
os === 'win32' ? 'C:/ghcup/bin' : `${process.env.HOME}/.ghcup/bin`;

// Path where apt installs binaries of a tool
const v = aptVersion(tool, version);
const aptPath = `/opt/${tool}/${v}/bin`;

// Path where choco installs binaries of a tool
const chocoPath = await getChocoPath(
tool,
Expand All @@ -94,12 +84,12 @@ async function isInstalled(
stack: [], // Always installed into the tool cache
cabal: {
win32: [chocoPath, ghcupPath],
linux: [aptPath, ghcupPath],
linux: [ghcupPath],
darwin: [ghcupPath]
}[os],
ghc: {
win32: [chocoPath, ghcupPath],
linux: [aptPath, ghcupPath],
linux: [ghcupPath],
darwin: [ghcupPath]
}[os]
};
Expand Down Expand Up @@ -141,7 +131,7 @@ async function isInstalled(
await exec(await ghcupBin(os, arch), ['unset', tool]);
}
} else {
// Install methods apt and choco have precise install paths,
// Install method choco has precise install paths,
// so if the install path is present, the tool should be present, too.
return success(tool, version, installedPath, os);
}
Expand Down Expand Up @@ -187,8 +177,6 @@ export async function installTool(
await aptLibNCurses5();
}
await ghcup(tool, version, os, arch);
if (await isInstalled(tool, version, os, arch)) return;
await apt(tool, version);
break;
case 'win32':
await choco(tool, version);
Expand Down Expand Up @@ -292,16 +280,6 @@ async function aptLibNCurses5(): Promise<boolean> {
return returnCode === 0;
}

async function apt(tool: Tool, version: string): Promise<void> {
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<void> {
core.info(`Attempting to install ${tool} ${version} using chocolatey`);

Expand Down
Loading