Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding ability to specify mulitple postgresql versions to be used in builds #615

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/HaskellCI/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
13 changes: 11 additions & 2 deletions src/HaskellCI/GitHub.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"

Expand Down Expand Up @@ -755,7 +764,7 @@ makeGitHub _argv config@Config {..} gitconfig prj jobs@JobVersions {..} = do

postgresService :: GitHubService
postgresService = GitHubService
{ ghServImage = "postgres:10"
{ 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")
Expand Down
3 changes: 2 additions & 1 deletion src/HaskellCI/GitHub/Yaml.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ data GitHubMatrixEntry = GitHubMatrixEntry
{ ghmeCompiler :: CompilerVersion
, ghmeAllowFailure :: Bool
, ghmeSetupMethod :: SetupMethod
, ghmePostgresVersion :: String
}
deriving (Show)

Expand Down Expand Up @@ -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 [] $
Expand Down
18 changes: 11 additions & 7 deletions src/HaskellCI/Travis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be toDescList. Same below.

for_ postgresVersions $ tellJob False v
for_ (reverse $ S.toList macosVersions) $ \v ->
for_ postgresVersions $ tellJob True v

, tmAllowFailures =
[ TravisAllowFailure $ dispGhcVersion compiler
Expand Down