Skip to content

Commit 8530407

Browse files
authored
Merge pull request #1387 from haskell/master
master2central april 30 2025
2 parents 48b833a + 1217eb0 commit 8530407

File tree

12 files changed

+249
-191
lines changed

12 files changed

+249
-191
lines changed

.github/workflows/haskell-ci.yml

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
#
77
# haskell-ci regenerate
88
#
9-
# For more information, see https://github.com/andreasabel/haskell-ci
9+
# For more information, see https://github.com/haskell-CI/haskell-ci
1010
#
11-
# version: 0.19.20240630
11+
# version: 0.19.20250330
1212
#
13-
# REGENDATA ("0.19.20240630",["github","hackage-server.cabal"])
13+
# REGENDATA ("0.19.20250330",["github","hackage-server.cabal"])
1414
#
1515
name: Haskell-CI
1616
on:
@@ -23,7 +23,7 @@ on:
2323
jobs:
2424
linux:
2525
name: Haskell-CI - Linux - ${{ matrix.compiler }}
26-
runs-on: ubuntu-20.04
26+
runs-on: ubuntu-24.04
2727
timeout-minutes:
2828
60
2929
container:
@@ -74,17 +74,30 @@ jobs:
7474
allow-failure: false
7575
fail-fast: false
7676
steps:
77-
- name: apt
77+
- name: apt-get install
7878
run: |
7979
apt-get update
8080
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5
81+
apt-get install -y libbrotli-dev libgd-dev
82+
- name: Install GHCup
83+
run: |
8184
mkdir -p "$HOME/.ghcup/bin"
82-
curl -sL https://downloads.haskell.org/ghcup/0.1.20.0/x86_64-linux-ghcup-0.1.20.0 > "$HOME/.ghcup/bin/ghcup"
85+
curl -sL https://downloads.haskell.org/ghcup/0.1.50.1/x86_64-linux-ghcup-0.1.50.1 > "$HOME/.ghcup/bin/ghcup"
8386
chmod a+x "$HOME/.ghcup/bin/ghcup"
87+
- name: Install cabal-install
88+
run: |
89+
"$HOME/.ghcup/bin/ghcup" install cabal 3.14.1.1-p1 || (cat "$HOME"/.ghcup/logs/*.* && false)
90+
echo "CABAL=$HOME/.ghcup/bin/cabal-3.14.1.1-p1 -vnormal+nowrap" >> "$GITHUB_ENV"
91+
- name: Install GHC (GHCup)
92+
if: matrix.setup-method == 'ghcup'
93+
run: |
8494
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false)
85-
"$HOME/.ghcup/bin/ghcup" install cabal 3.12.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
86-
apt-get update
87-
apt-get install -y libbrotli-dev libgd-dev
95+
HC=$("$HOME/.ghcup/bin/ghcup" whereis ghc "$HCVER")
96+
HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#')
97+
HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#')
98+
echo "HC=$HC" >> "$GITHUB_ENV"
99+
echo "HCPKG=$HCPKG" >> "$GITHUB_ENV"
100+
echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV"
88101
env:
89102
HCKIND: ${{ matrix.compilerKind }}
90103
HCNAME: ${{ matrix.compiler }}
@@ -95,21 +108,12 @@ jobs:
95108
echo "LANG=C.UTF-8" >> "$GITHUB_ENV"
96109
echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV"
97110
echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV"
98-
HCDIR=/opt/$HCKIND/$HCVER
99-
HC=$("$HOME/.ghcup/bin/ghcup" whereis ghc "$HCVER")
100-
HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#')
101-
HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#')
102-
echo "HC=$HC" >> "$GITHUB_ENV"
103-
echo "HCPKG=$HCPKG" >> "$GITHUB_ENV"
104-
echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV"
105-
echo "CABAL=$HOME/.ghcup/bin/cabal-3.12.1.0 -vnormal+nowrap" >> "$GITHUB_ENV"
106111
HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')
107112
echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV"
108113
if [ $((HCNUMVER >= 90400)) -ne 0 ] ; then echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV" ; else echo "ARG_TESTS=--disable-tests" >> "$GITHUB_ENV" ; fi
109114
echo "ARG_BENCH=--enable-benchmarks" >> "$GITHUB_ENV"
110115
echo "HEADHACKAGE=false" >> "$GITHUB_ENV"
111116
echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV"
112-
echo "GHCJSARITH=0" >> "$GITHUB_ENV"
113117
env:
114118
HCKIND: ${{ matrix.compilerKind }}
115119
HCNAME: ${{ matrix.compiler }}
@@ -225,8 +229,8 @@ jobs:
225229
rm -f cabal.project.local
226230
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
227231
- name: save cache
228-
uses: actions/cache/save@v4
229232
if: always()
233+
uses: actions/cache/save@v4
230234
with:
231235
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
232236
path: ~/.cabal/store

exes/BuildClient.hs

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{-# LANGUAGE PatternGuards #-}
22
{-# LANGUAGE ScopedTypeVariables #-}
3+
{-# LANGUAGE OverloadedStrings #-}
34
module Main (main) where
45

5-
import Network.HTTP hiding (password)
6-
import Network.Browser
6+
import Network.HTTP.Types.Header
7+
import Network.HTTP.Types.Status
78
import Network.URI (URI(..))
89
import Distribution.Client
910
import Distribution.Client.Cron (cron, rethrowSignalsAsExceptions,
@@ -26,6 +27,7 @@ import Control.Applicative as App
2627
import Control.Exception
2728
import Control.Monad
2829
import Control.Monad.Trans
30+
import qualified Data.ByteString.Char8 as BSS
2931
import qualified Data.ByteString.Lazy as BS
3032
import qualified Data.Map as M
3133

@@ -878,20 +880,28 @@ uploadResults :: Verbosity -> BuildConfig -> DocInfo -> Maybe FilePath
878880
uploadResults verbosity config docInfo
879881
mdocsTarballFile buildReportFile buildLogFile testLogFile coverageFile installOk =
880882
httpSession verbosity "hackage-build" version $ do
881-
-- Make sure we authenticate to Hackage
882-
setAuthorityGen (provideAuthInfo (bc_srcURI config)
883-
(Just (bc_username config, bc_password config)))
884883
case mdocsTarballFile of
885884
Nothing -> return ()
886885
Just docsTarballFile ->
887886
putDocsTarball config docInfo docsTarballFile
888887

889888
putBuildFiles config docInfo buildReportFile buildLogFile testLogFile coverageFile installOk
890889

890+
withAuth :: BuildConfig -> Request -> Request
891+
withAuth config req =
892+
noRedirects $ applyBasicAuth (BSS.pack $ bc_username config) (BSS.pack $ bc_password config) req
893+
891894
putDocsTarball :: BuildConfig -> DocInfo -> FilePath -> HttpSession ()
892-
putDocsTarball config docInfo docsTarballFile =
893-
requestPUTFile (docInfoDocsURI config docInfo)
894-
"application/x-tar" (Just "gzip") docsTarballFile
895+
putDocsTarball config docInfo docsTarballFile = do
896+
body <- liftIO $ BS.readFile docsTarballFile
897+
req <- withAuth config <$> mkUploadRequest "PUT" uri mimetype mEncoding [] body
898+
runRequest req $ \rsp -> do
899+
rsp' <- responseReadBSL rsp
900+
checkStatus uri rsp'
901+
where
902+
uri = docInfoDocsURI config docInfo
903+
mimetype = "application/x-tar"
904+
mEncoding = Just "gzip"
895905

896906
putBuildFiles :: BuildConfig -> DocInfo -> Maybe FilePath
897907
-> FilePath -> Maybe FilePath -> Maybe FilePath -> Bool -> HttpSession ()
@@ -902,22 +912,17 @@ putBuildFiles config docInfo reportFile buildLogFile testLogFile coverageFile in
902912
coverageContent <- liftIO $ traverse readFile coverageFile
903913
let uri = docInfoReports config docInfo
904914
body = encode $ BR.BuildFiles reportContent (Just logContent) testContent coverageContent (not installOk)
905-
setAllowRedirects False
906-
(_, response) <- request Request {
907-
rqURI = uri,
908-
rqMethod = PUT,
909-
rqHeaders = [Header HdrContentType "application/json",
910-
Header HdrContentLength (show (BS.length body))],
911-
rqBody = body
912-
}
913-
case rspCode response of
914-
--TODO: fix server to not do give 303, 201 is more appropriate
915-
(3,0,3) -> return ()
916-
_ -> do checkStatus uri response
915+
let headers = [ (hAccept, BSS.pack "application/json") ]
916+
req <- withAuth config <$> mkUploadRequest (BSS.pack "PUT") uri "application/json" Nothing headers body
917+
runRequest req $ \rsp -> do
918+
case statusCode $ responseStatus rsp of
919+
--TODO: fix server to not do give 303, 201 is more appropriate
920+
303 -> return ()
921+
_ -> do rsp' <- responseReadBSL rsp
922+
checkStatus uri rsp'
917923
fail "Unexpected response from server."
918924

919925

920-
921926
-------------------------
922927
-- Command line handling
923928
-------------------------

hackage-server.cabal

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,9 @@ library
408408
build-depends:
409409
, HStringTemplate ^>= 0.8
410410
, HTTP ^>= 4000.3.16 || ^>= 4000.4.1
411+
, http-client ^>= 0.7 && < 0.8
412+
, http-client-tls ^>= 0.3
413+
, http-types >= 0.10 && < 0.13
411414
, QuickCheck >= 2.14 && < 2.16
412415
, acid-state ^>= 0.16
413416
, async ^>= 2.2.1
@@ -453,6 +456,7 @@ library
453456
, stm ^>= 2.5.0
454457
, stringsearch ^>= 0.3.6.6
455458
, tagged ^>= 0.8.5
459+
, transformers ^>= 0.6
456460
, xhtml >= 3000.2.0.0 && < 3000.4
457461
, xmlgen ^>= 0.6
458462
, xss-sanitize ^>= 0.3.6
@@ -505,7 +509,7 @@ executable hackage-build
505509

506510
build-depends:
507511
-- version constraints inherited from hackage-server
508-
, HTTP
512+
, http-types
509513

510514
-- Runtime dependency only;
511515
-- TODO: we have no proper support for this kind of dependencies in cabal

0 commit comments

Comments
 (0)