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
59 changes: 34 additions & 25 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.20250506
#
# REGENDATA ("0.19.20240630",["github","hackage-cli.cabal"])
# REGENDATA ("0.19.20250506",["github","hackage-cli.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 All @@ -32,19 +32,24 @@ jobs:
strategy:
matrix:
include:
- compiler: ghc-9.10.1
- compiler: ghc-9.12.2
compilerKind: ghc
compilerVersion: 9.10.1
compilerVersion: 9.12.2
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.8.2
- compiler: ghc-9.10.2
compilerKind: ghc
compilerVersion: 9.8.2
compilerVersion: 9.10.2
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.6.5
- compiler: ghc-9.8.4
compilerKind: ghc
compilerVersion: 9.6.5
compilerVersion: 9.8.4
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.6.7
compilerKind: ghc
compilerVersion: 9.6.7
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.4.8
Expand Down Expand Up @@ -89,17 +94,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 libnuma-dev
apt-get install -y libbrotli-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.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
echo "CABAL=$HOME/.ghcup/bin/cabal-3.14.2.0 -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
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 @@ -110,21 +128,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 @@ -240,8 +249,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
1 change: 1 addition & 0 deletions .github/workflows/stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
defaults:
run:
shell: bash

steps:
- uses: actions/checkout@v4

Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog for hackage-cli

## 0.1.0.3

_Andreas Abel, 2025-06-04_

- Fix for `Cabal-3.14.*`.

Builds with `Cabal 3.4 - 3.14` and `GHC 8.2 - 9.12`.

## 0.1.0.2

_Andreas Abel, 2024-07-02_
Expand Down
9 changes: 1 addition & 8 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
packages: .

-- with-compiler: ghc-8.2.1

-- In order to build hackage-cli w/ an unreleased Cabal-2.x (NB: this builds fine w/ GHC 8.2.1 and its bundled Cabal-2.0):
-- 1. `cabal get -s Cabal`
-- 2. uncomment the 2 lines below (the constraints-line is a hack to avoid `setup`-components picking up the local Cabal package)

-- packages: Cabal/Cabal
-- constraints: setup.Cabal < 2
constraints: HsOpenSSL +use-pkg-config
14 changes: 8 additions & 6 deletions hackage-cli.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.4
name: hackage-cli
version: 0.1.0.2
version: 0.1.0.3

synopsis: CLI tool for Hackage
description:
Expand All @@ -18,9 +18,10 @@ build-type: Simple
-- Supported GHC versions when building with cabal:
tested-with:
-- Keep in descending order.
GHC == 9.10.1
GHC == 9.8.2
GHC == 9.6.5
GHC == 9.12.2
GHC == 9.10.2
GHC == 9.8.4
GHC == 9.6.7
GHC == 9.4.8
GHC == 9.2.8
GHC == 9.0.2
Expand All @@ -38,6 +39,7 @@ extra-source-files:
fixtures/*.diff
fixtures/*.cabal
-- Supported GHC versions when building with stack:
stack-9.10.yaml
stack-9.8.yaml
stack-9.6.yaml

Expand All @@ -54,7 +56,7 @@ library cabal-revisions
build-depends:
, base >= 4.10.0.0 && < 5
, bytestring >= 0.10.4.0 && < 0.13
, Cabal >= 3.4 && < 3.13
, Cabal >= 3.4 && < 3.15
, containers >= 0.5.0.0 && < 0.8
, mtl >= 2.2.2 && < 2.3 || >= 2.3.1 && < 2.4
, pretty ^>= 1.1.2
Expand Down Expand Up @@ -124,7 +126,7 @@ executable hackage-cli
, microlens-mtl >= 0.1.11.1 && < 0.3
, microlens-th >= 0.4.1.3 && < 0.5
, netrc ^>= 0.2.0.0
, optparse-applicative >= 0.14 && < 0.19
, optparse-applicative >= 0.14 && < 1
, process-extras ^>= 0.7.4
, semigroups >= 0.18.3 && < 0.21
, stringsearch ^>= 0.3.6
Expand Down
45 changes: 32 additions & 13 deletions src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ import qualified Distribution.Text as C
#if MIN_VERSION_Cabal(3,7,0)
import qualified Distribution.Simple.PackageDescription as C
#endif
#if MIN_VERSION_Cabal(3,14,0)
import Distribution.Utils.Path (makeSymbolicPath)
#endif

import Lens.Micro
import Lens.Micro.Mtl
Expand Down Expand Up @@ -79,9 +82,9 @@ import qualified Distribution.Types.GenericPackageDescription.Lens as LC

-- import Cabal

import Distribution.Server.Util.CabalRevisions
import IndexShaSum
import CabalEdit
import Distribution.Server.Util.CabalRevisions ( diffCabalRevisions, Change(Change) )
import IndexShaSum ( IndexShaSumOptions(IndexShaSumOptions), run )
import CabalEdit ( PkgRev, cabalEditXRev )

type PkgName = ByteString
type PkgVer = ByteString
Expand Down Expand Up @@ -623,9 +626,9 @@ main = do
mainWithOptions opts

mainWithOptions :: Options -> IO ()
mainWithOptions Options {..} = do
mainWithOptions Options{ optHost, optCommand } = do
case optCommand of
PullCabal (PullCOptions {..}) -> do
PullCabal (PullCOptions{ optPlCPkgName, optPlCIncrRev, optPlCForce, optPlCPkgVers }) -> do
let pkgn = optPlCPkgName

cs <- runHConn (fetchAllCabalFiles pkgn (fromMaybe C.anyVersion optPlCPkgVers))
Expand All @@ -652,8 +655,16 @@ mainWithOptions Options {..} = do

return ()

SyncCabal (SyncCOptions {..}) -> do
(pkgn,pkgv,xrev) <- pkgDescToPkgIdXrev <$> C.readGenericPackageDescription C.deafening optSyCFile
SyncCabal (SyncCOptions{ optSyCFile, optSyCIncrRev, optSyCForce }) -> do
(pkgn,pkgv,xrev) <- pkgDescToPkgIdXrev <$>
C.readGenericPackageDescription
C.deafening
#if MIN_VERSION_Cabal(3,14,0)
Nothing
(makeSymbolicPath optSyCFile)
#else
optSyCFile
#endif
cab0 <- BS.readFile optSyCFile

BS8.putStrLn $ mconcat [ "local : "
Expand Down Expand Up @@ -702,12 +713,12 @@ mainWithOptions Options {..} = do

BS.writeFile optSyCFile cab'
BS8.putStrLn $ mconcat [ "local : "
, pkgn, "-", pkgv, "-r", BS8.pack (show $ xrev')
, pkgn, "-", pkgv, "-r", BS8.pack (show xrev')
, " ('", BS8.pack optSyCFile, "')"
]


ListCabal (ListCOptions {..}) -> do
ListCabal (ListCOptions{ optLCPkgName, optNoAnn, optRevUrls }) -> do
let pkgn = optLCPkgName

vs <- runHConn (fetchVersions pkgn)
Expand All @@ -731,12 +742,20 @@ mainWithOptions Options {..} = do
BS8.putStrLn $ status <> pkgn <> "-" <> v
return ()

PushCabal (PushCOptions {..}) -> do
PushCabal (PushCOptions{ optPsCIncrRev, optPsCPublish, optPsCFiles }) -> do
(username,password) <- maybe (fail "missing Hackage credentials") return =<< getHackageCreds
putStrLn $ "Using Hackage credentials for username " ++ show username

forM_ optPsCFiles $ \fn -> do
(pkgn, pkgv, xrev0) <- pkgDescToPkgIdXrev <$> C.readGenericPackageDescription C.deafening fn
(pkgn, pkgv, xrev0) <- pkgDescToPkgIdXrev <$>
C.readGenericPackageDescription
C.deafening
#if MIN_VERSION_Cabal(3,14,0)
Nothing
(makeSymbolicPath fn)
#else
fn
#endif
let xrev = applyWhen optPsCIncrRev (+1) xrev0

putStrLn $ concat [ "Pushing ", show fn
Expand All @@ -754,7 +773,7 @@ mainWithOptions Options {..} = do
BS8.putStrLn (tidyHtml tmp)
putStrLn (replicate 80 '=')

PushCandidate (PushPCOptions {..}) -> do
PushCandidate (PushPCOptions{ optPPCFiles }) -> do
(username,password) <- maybe (fail "missing Hackage credentials") return =<< getHackageCreds
putStrLn $ "Using Hackage credentials for username " ++ show username

Expand All @@ -770,7 +789,7 @@ mainWithOptions Options {..} = do
putStrLn (replicate 80 '=')


CheckRevision (CheckROptions {..}) -> do
CheckRevision (CheckROptions{ optCRNew, optCROrig }) -> do
old <- BS.readFile optCROrig
new <- BS.readFile optCRNew

Expand Down
24 changes: 4 additions & 20 deletions stack-9.10.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,7 @@
resolver: nightly-2024-07-01
compiler: ghc-9.10.1
resolver: nightly-2025-05-28
compiler: ghc-9.10.2
compiler-check: match-exact

# Libraries shipped with GHC 9.10.1:
extra-deps:
- Cabal-3.12.0.0
- Cabal-syntax-3.12.0.0
- directory-1.3.8.3
- filepath-1.5.2.0
- process-1.6.19.0
- unix-2.8.5.1
# For Windows:
- Win32-2.14.0.0
- time-1.12.2

flags:
directory:
os-string: true
unix:
os-string: true
Win32:
os-string: true
HsOpenSSL:
use-pkg-config: true
6 changes: 5 additions & 1 deletion stack-9.6.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
resolver: lts-22.27
resolver: lts-22.44

flags:
HsOpenSSL:
use-pkg-config: true
6 changes: 5 additions & 1 deletion stack-9.8.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
resolver: nightly-2024-07-01
resolver: lts-23.24

flags:
HsOpenSSL:
use-pkg-config: true
Loading