Skip to content

Commit

Permalink
Add support for GHC nightlies via GHCup
Browse files Browse the repository at this point in the history
This is supported since GHCup 0.1.19.3. See:
https://www.haskell.org/ghcup/guide/#nightlies
  • Loading branch information
wismill authored and andreasabel committed Aug 8, 2023
1 parent 1983353 commit 1603f72
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ jobs:
ghc: "9.6.0.20230111"
cabal: "3.8"

# Test ghc nightly
- os: ubuntu-latest
ghcup_release_channel: "https://ghc.gitlab.haskell.org/ghcup-metadata/ghcup-nightlies-0.0.7.yaml"
plan:
ghc: "latest-nightly"
cabal: "latest"

# setup does something special for 7.10.3 (issue #79)
- os: ubuntu-20.04
plan:
Expand Down Expand Up @@ -158,8 +165,18 @@ jobs:
GHCVER="$(ghc --numeric-version)"
echo "CABALVER=${CABALVER}" >> "${GITHUB_ENV}"
echo "GHCVER=${GHCVER}" >> "${GITHUB_ENV}"
if [[ "${{ steps.setup.outputs.ghc-version }}" == "latest-nightly" ]]
then
GHCVER_EXPECTED=$( \
curl "${{ matrix.ghcup_release_channel }}" | \
yq '.ghcupDownloads.GHC[] | select(.viTags[] | contains("LatestNightly")) | key' \
)
echo "Latest nightly: ${GHCVER_EXPECTED}"
else
GHCVER_EXPECTED="${{ steps.setup.outputs.ghc-version }}"
fi
[[ "${CABALVER}" == "${{ steps.setup.outputs.cabal-version }}" ]] && \
[[ "${GHCVER}" == "${{ steps.setup.outputs.ghc-version }}" ]]
[[ "${GHCVER}" == "${GHCVER_EXPECTED}" ]]
- name: Test runghc
run: |
Expand Down
5 changes: 4 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13442,7 +13442,10 @@ async function installTool(tool, version, os) {
await ghcupGHCHead();
break;
}
if (tool === 'ghc' && (0, compare_versions_1.compareVersions)('8.3', version)) {
// “version” may not be a semantic version (e.g. “latest-nightly”),
// so guard “compareVersions” with “validate”.
if (tool === 'ghc' &&
(!(0, compare_versions_1.validate)(version) || (0, compare_versions_1.compareVersions)('8.3', version))) {
// Andreas, 2022-12-09: The following errors out if we are not ubuntu-20.04.
// Atm, I do not know how to check whether we are on ubuntu-20.04.
// So, ignore the error.
Expand Down
5 changes: 4 additions & 1 deletion lib/installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ async function installTool(tool, version, os) {
await ghcupGHCHead();
break;
}
if (tool === 'ghc' && (0, compare_versions_1.compareVersions)('8.3', version)) {
// “version” may not be a semantic version (e.g. “latest-nightly”),
// so guard “compareVersions” with “validate”.
if (tool === 'ghc' &&
(!(0, compare_versions_1.validate)(version) || (0, compare_versions_1.compareVersions)('8.3', version))) {
// Andreas, 2022-12-09: The following errors out if we are not ubuntu-20.04.
// Atm, I do not know how to check whether we are on ubuntu-20.04.
// So, ignore the error.
Expand Down
9 changes: 7 additions & 2 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {ghcup_version, OS, Tool, releaseRevision} from './opts';
import process from 'process';
import * as glob from '@actions/glob';
import * as fs from 'fs';
import {compareVersions} from 'compare-versions'; // compareVersions can be used in the sense of >
import {compareVersions, validate} from 'compare-versions'; // compareVersions can be used in the sense of >

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

0 comments on commit 1603f72

Please sign in to comment.