diff --git a/src/HaskellCI/Config.hs b/src/HaskellCI/Config.hs index 335988ed..68f97fc2 100644 --- a/src/HaskellCI/Config.hs +++ b/src/HaskellCI/Config.hs @@ -81,6 +81,7 @@ data Config = Config , cfgFolds :: S.Set Fold , cfgGhcHead :: !Bool , cfgPostgres :: !Bool + , cfgPostgresVersions :: [String] , cfgGoogleChrome :: !Bool , cfgEnv :: M.Map Version String , cfgAllowFailures :: !VersionRange @@ -211,6 +212,8 @@ configGrammar = Config ^^^ help "Add ghc-head job" <*> C.booleanFieldDef "postgresql" (field @"cfgPostgres") False ^^^ help "Add postgresql service" + <*> C.monoidalFieldAla "postgresql-versions" (C.alaList' C.FSep C.Token') (field @"cfgPostgresVersions") + ^^^ help "Postgresql versions to use" <*> C.booleanFieldDef "google-chrome" (field @"cfgGoogleChrome") False ^^^ help "Add google-chrome service" <*> C.monoidalFieldAla "env" Env (field @"cfgEnv") diff --git a/src/HaskellCI/GitHub.hs b/src/HaskellCI/GitHub.hs index 99bc20f5..52591d7b 100644 --- a/src/HaskellCI/GitHub.hs +++ b/src/HaskellCI/GitHub.hs @@ -606,7 +606,9 @@ makeGitHub _argv config@Config {..} gitconfig prj jobs@JobVersions {..} = do } , ghJobs = Map.fromList $ buildList $ do item (mainJobName, GitHubJob - { ghjName = actionName ++ " - Linux - ${{ matrix.compiler }}" + { ghjName = actionName + ++ " - Linux - ${{ matrix.compiler }}" + ++ (if cfgPostgres then " - Postgres ${{ matrix.postgres-version }}" else "") -- NB: The Ubuntu version used in `runs-on` isn't -- particularly important since we use a Docker container. , ghjRunsOn = ghcRunsOnVer @@ -625,16 +627,23 @@ makeGitHub _argv config@Config {..} gitconfig prj jobs@JobVersions {..} = do previewGHC cfgHeadHackage compiler || maybeGHC False (`C.withinRange` cfgAllowFailures) compiler , ghmeSetupMethod = if isGHCUP compiler then GHCUP else HVRPPA + , ghmePostgresVersion = postgresVersion } | compiler <- reverse $ toList linuxVersions , compiler /= GHCHead -- TODO: Make this work -- https://github.com/haskell-CI/haskell-ci/issues/458 + , postgresVersion <- pgVersions ] }) unless (null cfgIrcChannels) $ ircJob actionName mainJobName projectName config gitconfig } where + pgVersions = if cfgPostgres + then if null cfgPostgresVersions + then ["10"] + else cfgPostgresVersions + else ["postgres-not-enabled"] actionName = fromMaybe "Haskell-CI" cfgGitHubActionName mainJobName = "linux" @@ -755,7 +764,8 @@ makeGitHub _argv config@Config {..} gitconfig prj jobs@JobVersions {..} = do postgresService :: GitHubService postgresService = GitHubService - { ghServImage = "postgres:14" + + { ghServImage = "postgres:${{matrix.postgres-version}}" , ghServOptions = Just "--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5" , ghServEnv = Map.fromList [ ("POSTGRES_PASSWORD", "postgres") diff --git a/src/HaskellCI/GitHub/Yaml.hs b/src/HaskellCI/GitHub/Yaml.hs index 75cf8301..2468f89d 100644 --- a/src/HaskellCI/GitHub/Yaml.hs +++ b/src/HaskellCI/GitHub/Yaml.hs @@ -49,6 +49,7 @@ data GitHubMatrixEntry = GitHubMatrixEntry { ghmeCompiler :: CompilerVersion , ghmeAllowFailure :: Bool , ghmeSetupMethod :: SetupMethod + , ghmePostgresVersion :: String } deriving (Show) @@ -140,7 +141,7 @@ instance ToYaml GitHubMatrixEntry where , "compilerVersion" ~> fromString (compilerVersion ghmeCompiler) , "setup-method" ~> toYaml ghmeSetupMethod , "allow-failure" ~> toYaml ghmeAllowFailure - ] + , "postgres-version"~> fromString ghmePostgresVersion] instance ToYaml GitHubStep where toYaml GitHubStep {..} = ykeyValuesFilt [] $ diff --git a/src/HaskellCI/Travis.hs b/src/HaskellCI/Travis.hs index bd78d9b3..f4f80880 100644 --- a/src/HaskellCI/Travis.hs +++ b/src/HaskellCI/Travis.hs @@ -454,13 +454,13 @@ makeTravis argv config@Config {..} prj jobs@JobVersions {..} = do when cfgPostgres $ item "postgresql" , travisAddons = TravisAddons { taApt = TravisApt [] [] - , taPostgres = if cfgPostgres then Just "10" else Nothing + , taPostgres = Nothing , taGoogleChrome = cfgGoogleChrome } , travisMatrix = TravisMatrix { tmInclude = buildList $ do - let tellJob :: Bool -> CompilerVersion -> ListBuilder TravisJob () - tellJob osx gv = do + let tellJob :: Bool -> CompilerVersion -> Maybe String -> ListBuilder TravisJob () + tellJob osx gv pg = do let cvs = dispCabalVersion $ correspondingCabalVersion cfgCabalInstallVersion gv let gvs = dispGhcVersion gv @@ -494,13 +494,17 @@ makeTravis argv config@Config {..} prj jobs@JobVersions {..} = do , taSources = hvrppa : ghcjsAptSources } - , taPostgres = Nothing + , taPostgres = pg , taGoogleChrome = False } } - - for_ (reverse $ S.toList linuxVersions) $ tellJob False - for_ (reverse $ S.toList macosVersions) $ tellJob True + let postgresVersions = if cfgPostgres + then Just <$> cfgPostgresVersions + else [Nothing] + for_ (reverse $ S.toList linuxVersions) $ \v -> + for_ postgresVersions $ tellJob False v + for_ (reverse $ S.toList macosVersions) $ \v -> + for_ postgresVersions $ tellJob True v , tmAllowFailures = [ TravisAllowFailure $ dispGhcVersion compiler