Skip to content

Commit ad0f8c4

Browse files
committed
Make (GHC) version mapping configurable
1 parent 6d1a5ef commit ad0f8c4

File tree

14 files changed

+58
-31
lines changed

14 files changed

+58
-31
lines changed

.github/workflows/haskell-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ jobs:
181181
- name: cache (tools)
182182
uses: actions/cache/restore@v4
183183
with:
184-
key: ${{ runner.os }}-${{ matrix.compiler }}-tools-1e9b3b69
184+
key: ${{ runner.os }}-${{ matrix.compiler }}-tools-ff63ec70
185185
path: ~/.haskell-ci-tools
186186
- name: install cabal-plan
187187
run: |
@@ -209,7 +209,7 @@ jobs:
209209
if: always()
210210
uses: actions/cache/save@v4
211211
with:
212-
key: ${{ runner.os }}-${{ matrix.compiler }}-tools-1e9b3b69
212+
key: ${{ runner.os }}-${{ matrix.compiler }}-tools-ff63ec70
213213
path: ~/.haskell-ci-tools
214214
- name: checkout
215215
uses: actions/checkout@v4

cabal.haskell-ci

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,6 @@ raw-project
145145
keep-going: False
146146
package bytestring
147147
tests: False
148+
149+
-- Mapping of GHC versions (used for prereleases)
150+
ghc-version-mapping: 9.12.1:9.12.0.20241114

src/HaskellCI.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,6 @@ configFromCabalFile cfg (cabalFile, gpd) = do
549549
lastStableGhcVers
550550
= nubBy ((==) `on` ghcMajVer)
551551
$ sortBy (flip compare)
552-
$ filter (not . isPreviewGHC . GHC)
553552
$ knownGhcVersions
554553

555554
isTwoDigitGhcVersion :: VersionRange -> Maybe Version

src/HaskellCI/Auxiliary.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ data Auxiliary = Auxiliary
4646
, extraCabalProjectFields :: FilePath -> [C.PrettyField ()]
4747
, testShowDetails :: String
4848
, anyJobUsesHeadHackage :: Bool
49-
, anyJobUsesPreviewGHC :: Bool
5049
, runHaddock :: Bool
5150
, haddockFlags :: String
5251
}
@@ -139,9 +138,6 @@ auxiliary Config {..} prj JobVersions {..} = Auxiliary {..}
139138
anyJobUsesHeadHackage :: Bool
140139
anyJobUsesHeadHackage = not $ null headGhcVers
141140

142-
anyJobUsesPreviewGHC :: Bool
143-
anyJobUsesPreviewGHC = not $ null $ S.filter isPreviewGHC allVersions
144-
145141
pkgNameDirVariable' :: String -> String
146142
pkgNameDirVariable' n = "PKGDIR_" ++ map f n where
147143
f '-' = '_'

src/HaskellCI/Compiler.hs

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ module HaskellCI.Compiler (
99
-- ** Predicates
1010
isGHCHead,
1111
usesHeadHackage,
12-
isPreviewGHC,
1312
-- ** Selectors
1413
compilerKind,
1514
compilerVersion,
@@ -31,8 +30,7 @@ module HaskellCI.Compiler (
3130
previewCabal,
3231
-- * Misc
3332
ghcMajVer,
34-
translateCompilerVersion,
35-
) where
33+
) where
3634

3735
import HaskellCI.Prelude
3836

@@ -189,9 +187,6 @@ dispGhcVersionShort (GHCJS v) = "ghcjs-" ++ C.prettyShow v
189187
dispCabalVersion :: Maybe Version -> String
190188
dispCabalVersion = maybe "head" C.prettyShow
191189

192-
ghcAlpha :: Maybe (Version, Version)
193-
ghcAlpha = Just (mkVersion [9,12,1], mkVersion [9,12,0,20241031])
194-
195190
-- | GHC HEAD, and versions specified by head.hackage option.
196191
usesHeadHackage
197192
:: VersionRange -- ^ head.hackage range
@@ -201,11 +196,6 @@ usesHeadHackage _vr GHCHead = True
201196
usesHeadHackage vr (GHC v) = withinRange v vr
202197
usesHeadHackage _vr (GHCJS _) = False
203198

204-
isPreviewGHC :: CompilerVersion -> Bool
205-
isPreviewGHC GHCHead = True
206-
isPreviewGHC (GHC v) = maybe False (\(v', _) -> v /= v') ghcAlpha
207-
isPreviewGHC (GHCJS _) = False
208-
209199
isGHCHead :: CompilerVersion -> Bool
210200
isGHCHead GHCHead = True
211201
isGHCHead _ = False
@@ -222,13 +212,3 @@ ghcMajVer :: Version -> (Int,Int)
222212
ghcMajVer v
223213
| x:y:_ <- versionNumbers v = (x,y)
224214
| otherwise = error $ "panic: ghcMajVer called with " ++ show v
225-
226-
-- | Map compiler version to one available to download.
227-
--
228-
-- This way we can map e.g. 9.4.1 to 9.4.0.20220501 i.e. a prerelease.
229-
translateCompilerVersion :: CompilerVersion -> CompilerVersion
230-
translateCompilerVersion (GHC v)
231-
| Just (u, w) <- ghcAlpha
232-
, v == u
233-
= GHC w
234-
translateCompilerVersion v = v

src/HaskellCI/Config/Grammar.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ configGrammar = Config
173173
^^^ help "The name of GitHub Action"
174174
<*> optionalFieldDef "timeout-minutes" (field @"cfgTimeoutMinutes") defaultConfig
175175
^^^ metahelp "MINUTES" "The maximum number of minutes to let a job run"
176+
<*> optionalFieldDefAla "ghc-version-mapping" (alaMap' C.NoCommaFSep VersionPair) (field @"cfgVersionMapping") defaultConfig
177+
^^^ metahelp "VERSIONS" "Mapping of GHC versions (used for prereleases)"
176178

177179
-------------------------------------------------------------------------------
178180
-- Env

src/HaskellCI/Config/History.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module HaskellCI.Config.History (
88
import HaskellCI.Prelude
99

1010
import qualified Distribution.Version as C
11+
import qualified Data.Map.Strict as Map
1112

1213
import HaskellCI.Config.Initial
1314
import HaskellCI.Config.Type
@@ -45,6 +46,8 @@ configHistory =
4546
, ghcupVanilla = C.withinVersion (C.mkVersion [9,8,3])
4647
, ghcupPrerelease = C.orLaterVersion (C.mkVersion [9,12])
4748
}
49+
, ver 0 19 20241117 := \cfg -> cfg
50+
& field @"cfgVersionMapping" .~ Map.singleton (mkVersion [9,12,1]) (mkVersion [9,12,0,20241031])
4851
]
4952
where
5053
ver x y z = [x, y, z]

src/HaskellCI/Config/Initial.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,5 @@ initialConfig = Config
8181
, cfgRawTravis = ""
8282
, cfgGitHubActionName = Nothing
8383
, cfgTimeoutMinutes = 60
84+
, cfgVersionMapping = mempty
8485
}

src/HaskellCI/Config/Type.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ data Config = Config
8181
, cfgRawTravis :: !String
8282
, cfgGitHubActionName :: !(Maybe String)
8383
, cfgTimeoutMinutes :: !Natural
84+
, cfgVersionMapping :: !(Map Version Version)
8485
}
8586
deriving (Show, Generic)
8687

src/HaskellCI/GitHub.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ makeGitHub _argv config@Config {..} gitconfig prj jobs@JobVersions {..} = do
533533
-- we can have multiple setup methods for the same
534534
-- compiler version, if jobs overlap.
535535
[ [ GitHubMatrixEntry
536-
{ ghmeCompiler = translateCompilerVersion $ compiler
536+
{ ghmeCompiler = translateCompilerVersion cfgVersionMapping $ compiler
537537
, ghmeAllowFailure =
538538
isGHCHead compiler
539539
|| maybeGHC False (`C.withinRange` cfgAllowFailures) compiler
@@ -777,3 +777,7 @@ parseGitHubRepo t =
777777
-- runners support.
778778
ghcRunsOnVer :: String
779779
ghcRunsOnVer = "ubuntu-20.04"
780+
781+
translateCompilerVersion :: Map Version Version -> CompilerVersion -> CompilerVersion
782+
translateCompilerVersion m (GHC v) = GHC (Map.findWithDefault v v m)
783+
translateCompilerVersion _ x = x

0 commit comments

Comments
 (0)