Skip to content

Commit

Permalink
install ghc
Browse files Browse the repository at this point in the history
  • Loading branch information
phadej committed Nov 11, 2024
1 parent 3f84112 commit 3256442
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 22 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,17 @@ jobs:
- name: Install cabal-install
run: |
"$HOME/.ghcup/bin/ghcup" install cabal 3.12.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
- name: TODO
- name: Install GHC (hvr-ppa)
if: matrix.setup-method == 'hvr-ppa'
run: |
echo true
env:
HCKIND: ${{ matrix.compilerKind }}
HCNAME: ${{ matrix.compiler }}
HCVER: ${{ matrix.compilerVersion }}
- name: Install GHC (GHCup)
if: matrix.setup-method == 'ghcup'
run: |
"$HOME/.ghcup/bin/ghcup" config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.8.yaml;
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false)
env:
HCKIND: ${{ matrix.compilerKind }}
Expand Down
41 changes: 21 additions & 20 deletions src/HaskellCI/GitHub.hs
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,12 @@ makeGitHub _argv config@Config {..} gitconfig prj jobs@JobVersions {..} = do
| GHC (C.mkVersion [8,4,4]) `elem` allVersions
, GHC (C.mkVersion [8,4,4]) & isGHCUP
]

sh $ "apt-get install -y --no-install-recommends " ++ unwords corePkgs

-- additional packages
unless (null cfgApt) $ sh $ "apt-get install -y " ++ unwords (S.toList cfgApt)

githubRun "Install GHCup" $ do
let ghcupVer = C.prettyShow cfgGhcupVersion
sh $ "mkdir -p \"$HOME/.ghcup/bin\""
Expand All @@ -156,14 +160,11 @@ makeGitHub _argv config@Config {..} gitconfig prj jobs@JobVersions {..} = do
githubRun "Install cabal-install" $ do
sh $ "\"$HOME/.ghcup/bin/ghcup\" install cabal " ++ cabalFullVer ++ " || (cat \"$HOME\"/.ghcup/logs/*.* && false)"

-- TODO: Install cabal-install
-- TODO: Install GHC
githubRun' "TODO" envEnv $ do
let installGhcup :: ShM ()
installGhcup = do
-- if any job uses prereleases, add release channel unconditionally. (HEADHACKAGE variable is set later)
when (anyJobUsesPreviewGHC || previewCabal cfgCabalInstallVersion) $
sh "\"$HOME/.ghcup/bin/ghcup\" config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.8.yaml;"

-- todo: when any job uses hvr-ppa
githubRunIf' "Install GHC (hvr-ppa)" "matrix.setup-method == 'hvr-ppa'" envEnv $ do
sh $ "echo true"
{-
hvrppa <- runSh $ do
sh "apt-add-repository -y 'ppa:hvr/ghc'"
Expand All @@ -180,17 +181,17 @@ makeGitHub _argv config@Config {..} gitconfig prj jobs@JobVersions {..} = do
then if_then_else RangeGHCJS ghcjsInstall baseInstall
else sh baseInstall
installGhcup
-}

ghcup <- runSh $ do
installGhcup
-- todo: when any job uses ghcup
githubRunIf' "Install GHC (GHCup)" "matrix.setup-method == 'ghcup'" envEnv $ do
-- when (anyJobUsesPreviewGHC || previewCabal cfgCabalInstallVersion) $
-- sh "\"$HOME/.ghcup/bin/ghcup\" config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.8.yaml;"

sh $ "\"$HOME/.ghcup/bin/ghcup\" install ghc \"$HCVER\" || (cat \"$HOME\"/.ghcup/logs/*.* && false)"
unless (null cfgApt) $ do
sh "apt-get update"
sh $ "apt-get install -y " ++ unwords (S.toList cfgApt)
sh $ "\"$HOME/.ghcup/bin/ghcup\" install ghc \"$HCVER\" || (cat \"$HOME\"/.ghcup/logs/*.* && false)"

setup hvrppa ghcup
-- TODO: "GHCup vanilla"
-- TODO: "GHCup prerelease"

githubRun' "Set PATH and environment variables" envEnv $ do
echo_to "$GITHUB_PATH" "$HOME/.cabal/bin"
Expand Down Expand Up @@ -660,10 +661,10 @@ makeGitHub _argv config@Config {..} gitconfig prj jobs@JobVersions {..} = do
githubRun :: String -> ShM () -> ListBuilder (Either HsCiError GitHubStep) ()
githubRun name = githubRun' name mempty

githubRunIf :: String -> String -> ShM () -> ListBuilder (Either HsCiError GitHubStep) ()
githubRunIf name if_ action = undefined name if_ action

_unused = githubRunIf -- TODO
githubRunIf' :: String -> String -> Map.Map String String -> ShM () -> ListBuilder (Either HsCiError GitHubStep) ()
githubRunIf' name if_ env shm = item $ do
shs <- runSh shm
return $ GitHubStep name (Just if_) $ Left $ GitHubRun shs env

githubUses :: String -> String -> [(String, String)] -> ListBuilder (Either HsCiError GitHubStep) ()
githubUses name action with = item $ return $
Expand Down

0 comments on commit 3256442

Please sign in to comment.