Skip to content

Commit 1603f72

Browse files
wismillandreasabel
authored andcommitted
Add support for GHC nightlies via GHCup
This is supported since GHCup 0.1.19.3. See: https://www.haskell.org/ghcup/guide/#nightlies
1 parent 1983353 commit 1603f72

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
@@ -100,6 +100,13 @@ jobs:
100100
ghc: "9.6.0.20230111"
101101
cabal: "3.8"
102102

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

dist/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13442,7 +13442,10 @@ async function installTool(tool, version, os) {
1344213442
await ghcupGHCHead();
1344313443
break;
1344413444
}
13445-
if (tool === 'ghc' && (0, compare_versions_1.compareVersions)('8.3', version)) {
13445+
// “version” may not be a semantic version (e.g. “latest-nightly”),
13446+
// so guard “compareVersions” with “validate”.
13447+
if (tool === 'ghc' &&
13448+
(!(0, compare_versions_1.validate)(version) || (0, compare_versions_1.compareVersions)('8.3', version))) {
1344613449
// Andreas, 2022-12-09: The following errors out if we are not ubuntu-20.04.
1344713450
// Atm, I do not know how to check whether we are on ubuntu-20.04.
1344813451
// So, ignore the error.

lib/installer.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,10 @@ async function installTool(tool, version, os) {
161161
await ghcupGHCHead();
162162
break;
163163
}
164-
if (tool === 'ghc' && (0, compare_versions_1.compareVersions)('8.3', version)) {
164+
// “version” may not be a semantic version (e.g. “latest-nightly”),
165+
// so guard “compareVersions” with “validate”.
166+
if (tool === 'ghc' &&
167+
(!(0, compare_versions_1.validate)(version) || (0, compare_versions_1.compareVersions)('8.3', version))) {
165168
// Andreas, 2022-12-09: The following errors out if we are not ubuntu-20.04.
166169
// Atm, I do not know how to check whether we are on ubuntu-20.04.
167170
// So, ignore the error.

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)