Skip to content
Merged
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
42 changes: 23 additions & 19 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
#
# haskell-ci regenerate
#
# For more information, see https://github.com/andreasabel/haskell-ci
# For more information, see https://github.com/haskell-CI/haskell-ci
#
# version: 0.19.20240630
# version: 0.19.20250330
#
# REGENDATA ("0.19.20240630",["github","hackage-server.cabal"])
# REGENDATA ("0.19.20250330",["github","hackage-server.cabal"])
#
name: Haskell-CI
on:
Expand All @@ -23,7 +23,7 @@ on:
jobs:
linux:
name: Haskell-CI - Linux - ${{ matrix.compiler }}
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
timeout-minutes:
60
container:
Expand Down Expand Up @@ -74,17 +74,30 @@ jobs:
allow-failure: false
fail-fast: false
steps:
- name: apt
- name: apt-get install
run: |
apt-get update
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5
apt-get install -y libbrotli-dev libgd-dev
- name: Install GHCup
run: |
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.20.0/x86_64-linux-ghcup-0.1.20.0 > "$HOME/.ghcup/bin/ghcup"
curl -sL https://downloads.haskell.org/ghcup/0.1.50.1/x86_64-linux-ghcup-0.1.50.1 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
- name: Install cabal-install
run: |
"$HOME/.ghcup/bin/ghcup" install cabal 3.14.1.1-p1 || (cat "$HOME"/.ghcup/logs/*.* && false)
echo "CABAL=$HOME/.ghcup/bin/cabal-3.14.1.1-p1 -vnormal+nowrap" >> "$GITHUB_ENV"
- name: Install GHC (GHCup)
if: matrix.setup-method == 'ghcup'
run: |
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.12.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
apt-get update
apt-get install -y libbrotli-dev libgd-dev
HC=$("$HOME/.ghcup/bin/ghcup" whereis ghc "$HCVER")
HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#')
HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#')
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HCPKG" >> "$GITHUB_ENV"
echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV"
env:
HCKIND: ${{ matrix.compilerKind }}
HCNAME: ${{ matrix.compiler }}
Expand All @@ -95,21 +108,12 @@ jobs:
echo "LANG=C.UTF-8" >> "$GITHUB_ENV"
echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV"
echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV"
HCDIR=/opt/$HCKIND/$HCVER
HC=$("$HOME/.ghcup/bin/ghcup" whereis ghc "$HCVER")
HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#')
HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#')
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HCPKG" >> "$GITHUB_ENV"
echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.12.1.0 -vnormal+nowrap" >> "$GITHUB_ENV"
HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')
echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV"
echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV"
echo "ARG_BENCH=--enable-benchmarks" >> "$GITHUB_ENV"
echo "HEADHACKAGE=false" >> "$GITHUB_ENV"
echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV"
echo "GHCJSARITH=0" >> "$GITHUB_ENV"
env:
HCKIND: ${{ matrix.compilerKind }}
HCNAME: ${{ matrix.compiler }}
Expand Down Expand Up @@ -225,8 +229,8 @@ jobs:
rm -f cabal.project.local
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
- name: save cache
uses: actions/cache/save@v4
if: always()
uses: actions/cache/save@v4
with:
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
path: ~/.cabal/store
47 changes: 26 additions & 21 deletions exes/BuildClient.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{-# LANGUAGE PatternGuards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE OverloadedStrings #-}
module Main (main) where

import Network.HTTP hiding (password)
import Network.Browser
import Network.HTTP.Types.Header
import Network.HTTP.Types.Status
import Network.URI (URI(..))
import Distribution.Client
import Distribution.Client.Cron (cron, rethrowSignalsAsExceptions,
Expand All @@ -26,6 +27,7 @@ import Control.Applicative as App
import Control.Exception
import Control.Monad
import Control.Monad.Trans
import qualified Data.ByteString.Char8 as BSS
import qualified Data.ByteString.Lazy as BS
import qualified Data.Map as M

Expand Down Expand Up @@ -878,20 +880,28 @@ uploadResults :: Verbosity -> BuildConfig -> DocInfo -> Maybe FilePath
uploadResults verbosity config docInfo
mdocsTarballFile buildReportFile buildLogFile testLogFile coverageFile installOk =
httpSession verbosity "hackage-build" version $ do
-- Make sure we authenticate to Hackage
setAuthorityGen (provideAuthInfo (bc_srcURI config)
(Just (bc_username config, bc_password config)))
case mdocsTarballFile of
Nothing -> return ()
Just docsTarballFile ->
putDocsTarball config docInfo docsTarballFile

putBuildFiles config docInfo buildReportFile buildLogFile testLogFile coverageFile installOk

withAuth :: BuildConfig -> Request -> Request
withAuth config req =
noRedirects $ applyBasicAuth (BSS.pack $ bc_username config) (BSS.pack $ bc_password config) req

putDocsTarball :: BuildConfig -> DocInfo -> FilePath -> HttpSession ()
putDocsTarball config docInfo docsTarballFile =
requestPUTFile (docInfoDocsURI config docInfo)
"application/x-tar" (Just "gzip") docsTarballFile
putDocsTarball config docInfo docsTarballFile = do
body <- liftIO $ BS.readFile docsTarballFile
req <- withAuth config <$> mkUploadRequest "PUT" uri mimetype mEncoding [] body
runRequest req $ \rsp -> do
rsp' <- responseReadBSL rsp
checkStatus uri rsp'
where
uri = docInfoDocsURI config docInfo
mimetype = "application/x-tar"
mEncoding = Just "gzip"

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



-------------------------
-- Command line handling
-------------------------
Expand Down
6 changes: 5 additions & 1 deletion hackage-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,9 @@ library
build-depends:
, HStringTemplate ^>= 0.8
, HTTP ^>= 4000.3.16 || ^>= 4000.4.1
, http-client ^>= 0.7 && < 0.8
, http-client-tls ^>= 0.3
, http-types >= 0.10 && < 0.13
, QuickCheck >= 2.14 && < 2.16
, acid-state ^>= 0.16
, async ^>= 2.2.1
Expand Down Expand Up @@ -454,6 +457,7 @@ library
, stm ^>= 2.5.0
, stringsearch ^>= 0.3.6.6
, tagged ^>= 0.8.5
, transformers ^>= 0.6
, xhtml >= 3000.2.0.0 && < 3000.4
, xmlgen ^>= 0.6
, xss-sanitize ^>= 0.3.6
Expand Down Expand Up @@ -506,7 +510,7 @@ executable hackage-build

build-depends:
-- version constraints inherited from hackage-server
, HTTP
, http-types

-- Runtime dependency only;
-- TODO: we have no proper support for this kind of dependencies in cabal
Expand Down
Loading
Loading