Skip to content

Commit

Permalink
Resolve #665: ghc-head works with GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
phadej committed Aug 3, 2023
1 parent fcf086c commit f9fae58
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 14 deletions.
24 changes: 23 additions & 1 deletion .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ jobs:
compilerVersion: 8.2.2
setup-method: ghcup
allow-failure: false
- compiler: ghc-head
compilerKind: ghc
compilerVersion: latest-nightly
setup-method: ghcup
allow-failure: true
fail-fast: false
steps:
- name: apt
Expand All @@ -79,6 +84,8 @@ jobs:
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.19.2/x86_64-linux-ghcup-0.1.19.2 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.7.yaml;
"$HOME/.ghcup/bin/ghcup" config add-release-channel https://ghc.gitlab.haskell.org/ghcup-metadata/ghcup-nightlies-0.0.7.yaml;
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.10.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
env:
Expand All @@ -101,7 +108,7 @@ jobs:
echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV"
echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV"
echo "ARG_BENCH=--enable-benchmarks" >> "$GITHUB_ENV"
echo "HEADHACKAGE=false" >> "$GITHUB_ENV"
if [ $((HCNUMVER > 90405)) -ne 0 ] ; then echo "HEADHACKAGE=true" >> "$GITHUB_ENV" ; else echo "HEADHACKAGE=false" >> "$GITHUB_ENV" ; fi
echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV"
echo "GHCJSARITH=0" >> "$GITHUB_ENV"
env:
Expand Down Expand Up @@ -130,6 +137,18 @@ jobs:
repository hackage.haskell.org
url: http://hackage.haskell.org/
EOF
if $HEADHACKAGE; then
cat >> $CABAL_CONFIG <<EOF
repository head.hackage.ghc.haskell.org
url: https://ghc.gitlab.haskell.org/head.hackage/
secure: True
root-keys: 7541f32a4ccca4f97aea3b22f5e593ba2c0267546016b992dfadcd2fe944e55d
26021a13b401500c8eb2761ca95c61f2d625bfef951b939a8124ed12ecf07329
f76d08be13e9a61a377a85e2fb63f4c5435d40f8feb3e12eb05905edb8cdea89
key-threshold: 3
active-repositories: hackage.haskell.org, head.hackage.ghc.haskell.org:override
EOF
fi
cat >> $CABAL_CONFIG <<EOF
jobs: 2
EOF
Expand Down Expand Up @@ -225,6 +244,9 @@ jobs:
package bytestring
tests: False
EOF
if $HEADHACKAGE; then
echo "allow-newer: $($HCPKG list --simple-output | sed -E 's/([a-zA-Z-]+)-[0-9.]+/*:\1,/g')" >> cabal.project
fi
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: $_ installed\n" unless /^(Cabal|Cabal-syntax|cabal-install-parsers|haskell-ci|parsec)$/; }' >> cabal.project.local
cat cabal.project
cat cabal.project.local
Expand Down
2 changes: 1 addition & 1 deletion cabal.haskell-ci
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs: 2:2
-- linux-jobs: >=8.10

-- Add GHC head job
ghc-head: False
ghc-head: True

-- travis Caching
-- cache: True
Expand Down
2 changes: 1 addition & 1 deletion haskell-ci.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.2
name: haskell-ci
version: 0.16.6
version: 0.17.20230803
synopsis: Cabal package script generator for Travis-CI
description:
Script generator (@haskell-ci@) for
Expand Down
2 changes: 1 addition & 1 deletion src/HaskellCI/Compiler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ compilerKind (GHC _) = "ghc"
compilerKind (GHCJS _) = "ghcjs"

compilerVersion :: CompilerVersion -> String
compilerVersion GHCHead = "head"
compilerVersion GHCHead = "latest-nightly" -- https://ghc.gitlab.haskell.org/ghcup-metadata/ghcup-nightlies-0.0.7.yaml
compilerVersion (GHC v) = C.prettyShow v
compilerVersion (GHCJS v) = C.prettyShow v

Expand Down
2 changes: 1 addition & 1 deletion src/HaskellCI/Ghcup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ import HaskellCI.Prelude
import qualified Distribution.Version as C

defaultGhcupVersion :: Version
defaultGhcupVersion = C.mkVersion [0,1,19,2]
defaultGhcupVersion = C.mkVersion [0,1,19,5]
18 changes: 9 additions & 9 deletions src/HaskellCI/GitHub.hs
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,10 @@ makeGitHub _argv config@Config {..} gitconfig prj jobs@JobVersions {..} = do
sh $ "chmod a+x \"$HOME/.ghcup/bin/ghcup\""

-- if any job uses prereleases, add release channel unconditionally. (HEADHACKAGE variable is set later)
when (anyJobUsesHeadHackage || previewCabal cfgCabalInstallVersion) $
when (anyJobUsesHeadHackage || previewCabal cfgCabalInstallVersion) $ do
sh "\"$HOME/.ghcup/bin/ghcup\" config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.7.yaml;"

sh "\"$HOME/.ghcup/bin/ghcup\" config add-release-channel https://ghc.gitlab.haskell.org/ghcup-metadata/ghcup-nightlies-0.0.7.yaml;"

installGhcupCabal :: ShM ()
installGhcupCabal =
sh $ "\"$HOME/.ghcup/bin/ghcup\" install cabal " ++ cabalFullVer ++ " || (cat \"$HOME\"/.ghcup/logs/*.* && false)"
Expand Down Expand Up @@ -219,11 +220,12 @@ makeGitHub _argv config@Config {..} gitconfig prj jobs@JobVersions {..} = do
else tell_env "CABAL" $ "/opt/cabal/" ++ cabalVer ++ "/bin/cabal -vnormal+nowrap"

ghcup <- runSh $ do
let hc = "$HOME/.ghcup/bin/$HCKIND-$HCVER"
sh $ "HC=" ++ hc -- HC is an absolute path.
tell_env "HC" "$HC"
tell_env "HCPKG" $ "$HOME/.ghcup/bin/$HCKIND-pkg-$HCVER"
tell_env "HADDOCK" "$HOME/.ghcup/bin/haddock-$HCVER"
sh $ "HC=$(\"$HOME/.ghcup/bin/ghcup\" whereis ghc \"$HCVER\")"
sh $ "HCPKG=$(echo \"$HC\" | sed 's#ghc$#ghc-pkg#')"
sh $ "HADDOCK=$(echo \"$HC\" | sed 's#ghc$#haddock#')"
tell_env "HC" "$HC"
tell_env "HCPKG" "$HCPKG"
tell_env "HADDOCK" "$HADDOCK"
ghcupCabalPath

setup hvrppa ghcup
Expand Down Expand Up @@ -642,8 +644,6 @@ makeGitHub _argv config@Config {..} gitconfig prj jobs@JobVersions {..} = do
, ghmeSetupMethod = if isGHCUP compiler then GHCUP else HVRPPA
}
| compiler <- reverse $ toList linuxVersions
, compiler /= GHCHead -- TODO: Make this work
-- https://github.com/haskell-CI/haskell-ci/issues/458
]
})
unless (null cfgIrcChannels) $
Expand Down

0 comments on commit f9fae58

Please sign in to comment.