diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 859c1251..7bb6cc0f 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -101,6 +101,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: @@ -159,8 +166,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: | diff --git a/setup/dist/index.js b/setup/dist/index.js index c43ba7d2..1a069f9a 100644 --- a/setup/dist/index.js +++ b/setup/dist/index.js @@ -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. diff --git a/setup/lib/installer.js b/setup/lib/installer.js index 70c94294..52df7c4e 100644 --- a/setup/lib/installer.js +++ b/setup/lib/installer.js @@ -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. diff --git a/setup/src/installer.ts b/setup/src/installer.ts index 6e7f24f0..e95cbb2c 100644 --- a/setup/src/installer.ts +++ b/setup/src/installer.ts @@ -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 => @@ -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.