Skip to content

Use ghcup to install cabal head (haskell/actions#290) #45

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
Oct 2, 2023
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
15 changes: 14 additions & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ jobs:
# Latest releases
- ghc: latest
cabal: latest
# Latest ghc with cabal head
- ghc: latest
cabal: head
# Recommended releases (update according to ghcup)
# 9.4 will be recommended soon
- ghc: "9.4"
Expand Down Expand Up @@ -177,7 +180,17 @@ jobs:
else
GHCVER_EXPECTED="${{ steps.setup.outputs.ghc-version }}"
fi
[[ "${CABALVER}" == "${{ steps.setup.outputs.cabal-version }}" ]] && \
if [[ "${{ steps.setup.outputs.cabal-version }}" == "head" ]]
then
CABALVER_EXPECTED=$( \
curl --silent https://github.com/raw/haskell/cabal/master/cabal-install/cabal-install.cabal | \
sed -E -n 's/^Version:[[:space:]]+//p' \
)
echo "Cabal head: ${CABALVER_EXPECTED}"
else
CABALVER_EXPECTED="${{ steps.setup.outputs.cabal-version }}"
fi
[[ "${CABALVER_EXPECTED}" == ${CABALVER}* ]] && \
[[ "${GHCVER}" == "${GHCVER_EXPECTED}" ]]

- name: Test runghc
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ Suggestion: Try to support at least the three latest major versions of GHC.

**Cabal:**

- `head` (the [cabal-head](https://github.com/haskell/cabal/releases/tag/cabal-head) release of the most recent build of the `master` branch)
- `latest` (default, recommended)
- `3.10.1.0` `3.10`
- `3.8.1.0` `3.8`
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ inputs:
default: 'latest'
cabal-version:
required: false
description: 'Version of Cabal to use. If set to "latest", it will always get the latest stable version.'
description: 'Version of Cabal to use. If set to "latest", it will always get the latest stable version. If set to "head", it will always get the latest build of cabal.'
default: 'latest'
stack-version:
required: false
Expand Down
32 changes: 30 additions & 2 deletions dist/index.js

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

32 changes: 30 additions & 2 deletions lib/installer.js

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

32 changes: 30 additions & 2 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,36 @@ export async function addGhcupReleaseChannel(
async function ghcup(tool: Tool, version: string, os: OS): Promise<void> {
core.info(`Attempting to install ${tool} ${version} using ghcup`);
const bin = await ghcupBin(os);
const returnCode = await exec(bin, ['install', tool, version]);
if (returnCode === 0) await exec(bin, ['set', tool, version]);
if (tool === 'cabal' && version === 'head') {
await ghcupCabalHead(os, bin);
} else {
const returnCode = await exec(bin, ['install', tool, version]);
if (returnCode === 0) await exec(bin, ['set', tool, version]);
}
}

function cabalHeadUrlTag(os: OS): string {
switch (os) {
case 'linux':
return 'Linux';
case 'darwin':
return 'macOS';
case 'win32':
return 'Windows';
}
}

async function ghcupCabalHead(os: OS, bin: string): Promise<void> {
const osTag = cabalHeadUrlTag(os);
const cabalHeadUrl = `https://github.com/haskell/cabal/releases/download/cabal-head/cabal-head-${osTag}-x86_64.tar.gz`;
const returnCode = await exec(bin, [
'install',
'cabal',
'-u',
cabalHeadUrl,
'head'
]);
if (returnCode === 0) await exec(bin, ['set', 'cabal', 'head']);
}

async function ghcupGHCHead(): Promise<void> {
Expand Down