Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
Use ghcup to install cabal head (#290)
Browse files Browse the repository at this point in the history
This allows `head` to be the specified cabal version.

Commits:
* Use ghcup to install cabal head
* Add cabal head to cabal-version description
* Add cabal head test and check
* Add cabal head to README supported versions
* Use wildcard to check that version is prefix
* Make sed version grabber cross platform
  • Loading branch information
nlander authored Oct 2, 2023
1 parent ddbdc95 commit 77e8db1
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 8 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,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 @@ -176,7 +179,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://raw.githubusercontent.com/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 setup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,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 setup/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 setup/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 setup/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 setup/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

0 comments on commit 77e8db1

Please sign in to comment.