Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion cabal.haskell-ci
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ghc-head: False
-- remove cabal noise from test output
-- cabal-noise: False

-- Build tests. In addition to True and False you may specify
-- Build tests. Alternatively to True and False you may specify
-- a version range, e.g. >= 8.0 to build tests only in some jobs.
tests: True

Expand Down
46 changes: 34 additions & 12 deletions src/HaskellCI/GitHub.hs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ makeGitHub
-> Either HsCiError GitHub
makeGitHub _argv config@Config {..} gitconfig prj jobs@JobVersions {..} = do
let envEnv = Map.fromList
[ ("HCNAME", "${{ matrix.compiler }}") -- e.g. ghc-8.8.4
, ("HCKIND", "${{ matrix.compilerKind }}") -- ghc
, ("HCVER", "${{ matrix.compilerVersion }}") -- 8.8.4
[ ("HCNAME", ghWrapExpr "matrix.compiler") -- e.g. ghc-8.8.4
, ("HCKIND", ghWrapExpr "matrix.compilerKind") -- ghc
, ("HCVER", ghWrapExpr "matrix.compilerVersion") -- 8.8.4
]

-- Validity checks
Expand Down Expand Up @@ -311,7 +311,12 @@ makeGitHub _argv config@Config {..} gitconfig prj jobs@JobVersions {..} = do
Binary.put cfgGhcupJobs -- GHC location affects doctest, e.g

when (doctestEnabled) $ githubUses "cache (tools)" "actions/cache/restore@v4"
[ ("key", "${{ runner.os }}-${{ matrix.compiler }}-tools-" ++ toolsConfigHash)
[ ("key", intercalate "-" [
ghWrapExpr "runner.os"
, ghWrapExpr "matrix.compiler"
, "tools"
, toolsConfigHash
])
, ("path", "~/.haskell-ci-tools")
]

Expand Down Expand Up @@ -348,7 +353,12 @@ makeGitHub _argv config@Config {..} gitconfig prj jobs@JobVersions {..} = do
sh_if range "doctest --version"

when (doctestEnabled) $ githubUsesIf "save cache (tools)" "actions/cache/save@v4" "always()"
[ ("key", "${{ runner.os }}-${{ matrix.compiler }}-tools-" ++ toolsConfigHash)
[ ("key", intercalate "-" [
ghWrapExpr "runner.os"
, ghWrapExpr "matrix.compiler"
, "tools"
, toolsConfigHash
])
, ("path", "~/.haskell-ci-tools")
]

Expand Down Expand Up @@ -444,8 +454,16 @@ makeGitHub _argv config@Config {..} gitconfig prj jobs@JobVersions {..} = do
-- This a hack. https://github.com/actions/cache/issues/109
-- Hashing Java - Maven style.
githubUses "restore cache" "actions/cache/restore@v4"
[ ("key", "${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}")
, ("restore-keys", "${{ runner.os }}-${{ matrix.compiler }}-")
[ ("key", intercalate "-" [
ghWrapExpr "runner.os"
, ghWrapExpr "matrix.compiler"
, ghWrapExpr "github.sha"
])
, ("restore-keys", intercalate "-" [
ghWrapExpr "runner.os"
, ghWrapExpr "matrix.compiler"
, "" -- Includes a trailing dash
])
, ("path", "~/.cabal/store")
]

Expand Down Expand Up @@ -579,7 +597,11 @@ makeGitHub _argv config@Config {..} gitconfig prj jobs@JobVersions {..} = do
sh_cs $ "$CABAL v2-haddock --disable-documentation" ++ haddockFlags ++ " $ARG_COMPILER " ++ withHaddock ++ " " ++ allFlags ++ " all"

githubUsesIf "save cache" "actions/cache/save@v4" "always()"
[ ("key", "${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}")
[ ("key", intercalate "-" [
ghWrapExpr "runner.os"
, ghWrapExpr "matrix.compiler"
, ghWrapExpr "github.sha"
])
, ("path", "~/.cabal/store")
]

Expand All @@ -591,15 +613,15 @@ makeGitHub _argv config@Config {..} gitconfig prj jobs@JobVersions {..} = do
}
, ghJobs = Map.fromList $ buildList $ do
item (mainJobName, GitHubJob
{ ghjName = actionName ++ " - Linux - ${{ matrix.compiler }}"
{ ghjName = intercalate " - " [actionName, "Linux", ghWrapExpr "matrix.compiler"]
-- NB: The Ubuntu version used in `runs-on` isn't
-- particularly important since we use a Docker container.
, ghjRunsOn = ghcRunsOnVer
, ghjNeeds = []
, ghjSteps = steps
, ghjIf = Nothing
, ghjContainer = Just $ "buildpack-deps:" ++ ubuntuVer
, ghjContinueOnError = Just "${{ matrix.allow-failure }}"
, ghjContinueOnError = Just $ ghWrapExpr "matrix.allow-failure"
, ghjServices = mconcat
[ Map.singleton "postgres" postgresService | cfgPostgres ]
, ghjTimeout = max 10 cfgTimeoutMinutes
Expand Down Expand Up @@ -773,10 +795,10 @@ ircJob actionName mainJobName projectName cfg gitconfig = item ("irc", GitHubJob
, Just repo <- parseGitHubRepo url

= Just
$ "${{ always() && (github.repository == '" ++ T.unpack repo ++ "') }}"
$ ghWrapExpr "always() && (github.repository == '" ++ T.unpack repo ++ "')"

| otherwise
= Just "${{ always() }}"
= Just $ ghWrapExpr "always()"
-- Use always() above to ensure that the IRC job will still run even if
-- the build job itself fails (see #437).

Expand Down