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

Commit 3501ebb

Browse files
authored
Add suport for GHC nightlies via GHCup (#279)
This is supported since GHCup 0.1.19.3. See: https://www.haskell.org/ghcup/guide/#nightlies
1 parent 25533b9 commit 3501ebb

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

.github/workflows/workflow.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ jobs:
101101
ghc: "9.6.0.20230111"
102102
cabal: "3.8"
103103

104+
# Test ghc nightly
105+
- os: ubuntu-latest
106+
ghcup_release_channel: "https://ghc.gitlab.haskell.org/ghcup-metadata/ghcup-nightlies-0.0.7.yaml"
107+
plan:
108+
ghc: "latest-nightly"
109+
cabal: "latest"
110+
104111
# setup does something special for 7.10.3 (issue #79)
105112
- os: ubuntu-20.04
106113
plan:
@@ -159,8 +166,18 @@ jobs:
159166
GHCVER="$(ghc --numeric-version)"
160167
echo "CABALVER=${CABALVER}" >> "${GITHUB_ENV}"
161168
echo "GHCVER=${GHCVER}" >> "${GITHUB_ENV}"
169+
if [[ "${{ steps.setup.outputs.ghc-version }}" == "latest-nightly" ]]
170+
then
171+
GHCVER_EXPECTED=$( \
172+
curl "${{ matrix.ghcup_release_channel }}" | \
173+
yq '.ghcupDownloads.GHC[] | select(.viTags[] | contains("LatestNightly")) | key' \
174+
)
175+
echo "Latest nightly: ${GHCVER_EXPECTED}"
176+
else
177+
GHCVER_EXPECTED="${{ steps.setup.outputs.ghc-version }}"
178+
fi
162179
[[ "${CABALVER}" == "${{ steps.setup.outputs.cabal-version }}" ]] && \
163-
[[ "${GHCVER}" == "${{ steps.setup.outputs.ghc-version }}" ]]
180+
[[ "${GHCVER}" == "${GHCVER_EXPECTED}" ]]
164181
165182
- name: Test runghc
166183
run: |

setup/dist/index.js

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

setup/lib/installer.js

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

setup/src/installer.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {ghcup_version, OS, Tool, releaseRevision} from './opts';
88
import process from 'process';
99
import * as glob from '@actions/glob';
1010
import * as fs from 'fs';
11-
import {compareVersions} from 'compare-versions'; // compareVersions can be used in the sense of >
11+
import {compareVersions, validate} from 'compare-versions'; // compareVersions can be used in the sense of >
1212

1313
// Don't throw on non-zero.
1414
const exec = async (cmd: string, args?: string[]): Promise<number> =>
@@ -171,7 +171,12 @@ export async function installTool(
171171
await ghcupGHCHead();
172172
break;
173173
}
174-
if (tool === 'ghc' && compareVersions('8.3', version)) {
174+
// “version” may not be a semantic version (e.g. “latest-nightly”),
175+
// so guard “compareVersions” with “validate”.
176+
if (
177+
tool === 'ghc' &&
178+
(!validate(version) || compareVersions('8.3', version))
179+
) {
175180
// Andreas, 2022-12-09: The following errors out if we are not ubuntu-20.04.
176181
// Atm, I do not know how to check whether we are on ubuntu-20.04.
177182
// So, ignore the error.

0 commit comments

Comments
 (0)