From b990e4ddc67b83b7bca8023985433667554e678a Mon Sep 17 00:00:00 2001 From: Oleg Grenrus Date: Tue, 4 Jun 2024 19:58:37 +0300 Subject: [PATCH] Support GHC-8.6.5...9.10.1 --- .github/workflows/haskell-ci.yml | 121 +++++++++++-------------------- .github/workflows/simple.yml | 8 +- CHANGELOG.md | 4 + lukko.cabal | 35 ++++----- src/Lukko/Internal/FillBytes.hs | 15 ---- src/Lukko/Internal/HandleToFD.hs | 21 ------ 6 files changed, 64 insertions(+), 140 deletions(-) diff --git a/.github/workflows/haskell-ci.yml b/.github/workflows/haskell-ci.yml index cb6b0cb..128b541 100644 --- a/.github/workflows/haskell-ci.yml +++ b/.github/workflows/haskell-ci.yml @@ -8,9 +8,9 @@ # # For more information, see https://github.com/haskell-CI/haskell-ci # -# version: 0.15.20230321 +# version: 0.19.20240514 # -# REGENDATA ("0.15.20230321",["github","cabal.project"]) +# REGENDATA ("0.19.20240514",["github","cabal.project"]) # name: Haskell-CI on: @@ -27,24 +27,34 @@ jobs: timeout-minutes: 60 container: - image: buildpack-deps:bionic + image: buildpack-deps:jammy continue-on-error: ${{ matrix.allow-failure }} strategy: matrix: include: - - compiler: ghc-9.6.1 + - compiler: ghc-9.10.1 compilerKind: ghc - compilerVersion: 9.6.1 + compilerVersion: 9.10.1 setup-method: ghcup allow-failure: false - - compiler: ghc-9.4.4 + - compiler: ghc-9.8.2 compilerKind: ghc - compilerVersion: 9.4.4 + compilerVersion: 9.8.2 setup-method: ghcup allow-failure: false - - compiler: ghc-9.2.7 + - compiler: ghc-9.6.5 compilerKind: ghc - compilerVersion: 9.2.7 + compilerVersion: 9.6.5 + setup-method: ghcup + allow-failure: false + - compiler: ghc-9.4.8 + compilerKind: ghc + compilerVersion: 9.4.8 + setup-method: ghcup + allow-failure: false + - compiler: ghc-9.2.8 + compilerKind: ghc + compilerVersion: 9.2.8 setup-method: ghcup allow-failure: false - compiler: ghc-9.0.2 @@ -60,42 +70,12 @@ jobs: - compiler: ghc-8.8.4 compilerKind: ghc compilerVersion: 8.8.4 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.6.5 compilerKind: ghc compilerVersion: 8.6.5 - setup-method: hvr-ppa - allow-failure: false - - compiler: ghc-8.4.4 - compilerKind: ghc - compilerVersion: 8.4.4 - setup-method: hvr-ppa - allow-failure: false - - compiler: ghc-8.2.2 - compilerKind: ghc - compilerVersion: 8.2.2 - setup-method: hvr-ppa - allow-failure: false - - compiler: ghc-8.0.2 - compilerKind: ghc - compilerVersion: 8.0.2 - setup-method: hvr-ppa - allow-failure: false - - compiler: ghc-7.10.3 - compilerKind: ghc - compilerVersion: 7.10.3 - setup-method: hvr-ppa - allow-failure: false - - compiler: ghc-7.8.4 - compilerKind: ghc - compilerVersion: 7.8.4 - setup-method: hvr-ppa - allow-failure: false - - compiler: ghc-7.6.3 - compilerKind: ghc - compilerVersion: 7.6.3 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false fail-fast: false steps: @@ -103,21 +83,11 @@ jobs: run: | apt-get update apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 - if [ "${{ matrix.setup-method }}" = ghcup ]; then - 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" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false) - "$HOME/.ghcup/bin/ghcup" install cabal 3.10.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false) - else - apt-add-repository -y 'ppa:hvr/ghc' - apt-get update - apt-get install -y "$HCNAME" - 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" install cabal 3.10.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false) - fi + 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" + chmod a+x "$HOME/.ghcup/bin/ghcup" + "$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false) + "$HOME/.ghcup/bin/ghcup" install cabal 3.10.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false) env: HCKIND: ${{ matrix.compilerKind }} HCNAME: ${{ matrix.compiler }} @@ -129,20 +99,13 @@ jobs: echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV" echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV" HCDIR=/opt/$HCKIND/$HCVER - if [ "${{ matrix.setup-method }}" = ghcup ]; then - HC=$HOME/.ghcup/bin/$HCKIND-$HCVER - echo "HC=$HC" >> "$GITHUB_ENV" - echo "HCPKG=$HOME/.ghcup/bin/$HCKIND-pkg-$HCVER" >> "$GITHUB_ENV" - echo "HADDOCK=$HOME/.ghcup/bin/haddock-$HCVER" >> "$GITHUB_ENV" - echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.1.0 -vnormal+nowrap" >> "$GITHUB_ENV" - else - HC=$HCDIR/bin/$HCKIND - echo "HC=$HC" >> "$GITHUB_ENV" - echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV" - echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV" - echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.1.0 -vnormal+nowrap" >> "$GITHUB_ENV" - fi - + 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.10.2.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" @@ -192,14 +155,14 @@ jobs: - name: install cabal-plan run: | mkdir -p $HOME/.cabal/bin - curl -sL https://github.com/haskell-hvr/cabal-plan/releases/download/v0.6.2.0/cabal-plan-0.6.2.0-x86_64-linux.xz > cabal-plan.xz - echo 'de73600b1836d3f55e32d80385acc055fd97f60eaa0ab68a755302685f5d81bc cabal-plan.xz' | sha256sum -c - + curl -sL https://github.com/haskell-hvr/cabal-plan/releases/download/v0.7.3.0/cabal-plan-0.7.3.0-x86_64-linux.xz > cabal-plan.xz + echo 'f62ccb2971567a5f638f2005ad3173dba14693a45154c1508645c52289714cb2 cabal-plan.xz' | sha256sum -c - xz -d < cabal-plan.xz > $HOME/.cabal/bin/cabal-plan rm -f cabal-plan.xz chmod a+x $HOME/.cabal/bin/cabal-plan cabal-plan --version - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: source - name: initial cabal.project for sdist @@ -223,12 +186,12 @@ jobs: touch cabal.project touch cabal.project.local echo "packages: ${PKGDIR_lukko}" >> cabal.project - if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package lukko" >> cabal.project ; fi - if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi + echo "package lukko" >> cabal.project + echo " ghc-options: -Werror=missing-methods" >> cabal.project cat >> cabal.project <> cabal.project.local + $HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: any.$_ installed\n" unless /^(lukko)$/; }' >> cabal.project.local cat cabal.project cat cabal.project.local - name: dump install plan @@ -236,7 +199,7 @@ jobs: $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all cabal-plan - name: restore cache - uses: actions/cache/restore@v3 + uses: actions/cache/restore@v4 with: key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }} path: ~/.cabal/store @@ -270,10 +233,12 @@ jobs: rm -f cabal.project.local - name: constraint set no-ofd run: | + $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --constraint='lukko -ofd-locking' all --dry-run + cabal-plan topo | sort $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --constraint='lukko -ofd-locking' --dependencies-only -j2 all $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --constraint='lukko -ofd-locking' all - name: save cache - uses: actions/cache/save@v3 + uses: actions/cache/save@v4 if: always() with: key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }} diff --git a/.github/workflows/simple.yml b/.github/workflows/simple.yml index a0f8dae..514301d 100644 --- a/.github/workflows/simple.yml +++ b/.github/workflows/simple.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: os: [macos-latest, windows-latest] - ghc: ['8.10','9.0','9.2','9.4.1'] + ghc: ['9.2','9.4','9.6','9.8','9.10.1'] fail-fast: false timeout-minutes: 60 @@ -25,17 +25,17 @@ jobs: git config --global core.eol lf - name: Checkout - uses: actions/checkout@v3.0.2 + uses: actions/checkout@v4 - name: Set up Haskell id: setup-haskell - uses: haskell/actions/setup@v2 + uses: haskell-actions/setup@v2 with: ghc-version: ${{ matrix.ghc }} cabal-version: '3.10.1.0' - name: Cache - uses: actions/cache@v2.1.3 + uses: actions/cache@v4 with: path: ${{ steps.setup-haskell.outputs.cabal-store }} key: ${{ runner.os }}-${{ matrix.ghc }}-${{ github.sha }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 6982505..3347dfe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.1.2 + +* Support GHC-8.6.5...9.10.1 + # 0.1.1.3 * Use `CApiFFI` to call varargs C functions. diff --git a/lukko.cabal b/lukko.cabal index b100545..772c9a3 100644 --- a/lukko.cabal +++ b/lukko.cabal @@ -1,7 +1,6 @@ cabal-version: 2.2 name: lukko -version: 0.1.1.3 -x-revision: 5 +version: 0.1.2 synopsis: File locking category: System, Concurrency description: @@ -50,20 +49,15 @@ license-files: build-type: Simple extra-source-files: CHANGELOG.md tested-with: - GHC ==7.6.3 - || ==7.8.4 - || ==7.10.3 - || ==8.0.2 - || ==8.2.2 - || ==8.4.4 - || ==8.6.5 + GHC ==8.6.5 || ==8.8.4 || ==8.10.7 || ==9.0.2 || ==9.2.8 - || ==9.4.7 - || ==9.6.3 - || ==9.8.1 + || ==9.4.8 + || ==9.6.5 + || ==9.8.2 + || ==9.10.1 source-repository head type: git @@ -78,8 +72,8 @@ flag ofd-locking library default-language: Haskell2010 hs-source-dirs: src - build-depends: base >=4.5 && <4.20 - build-tool-depends: hsc2hs:hsc2hs >=0.67 && <0.69 + build-depends: base >=4.12.0.0 && <4.21 + build-tool-depends: hsc2hs:hsc2hs >=0.68.5 && <0.69 -- Main library module exposed-modules: @@ -127,17 +121,14 @@ test-suite test-thread build-depends: , async ^>=2.2.2 , base - , filepath ^>=1.3.0.0 || ^>=1.4.0.0 + , filepath ^>=1.4.2.1 || ^>=1.5.2.0 , lukko - , singleton-bool ^>=0.1.5 - , tasty >=1.4.0.1 && <1.5 || ^>=1.5 - , tasty-expected-failure ^>=0.11.1.2 || ^>=0.12.2 + , singleton-bool ^>=0.1.8 + , tasty ^>=1.5 + , tasty-expected-failure ^>=0.12.3 , tasty-hunit ^>=0.10.0.2 , temporary ^>=1.3 - if !impl(ghc >=7.8) - build-depends: tagged ^>=0.8.5 - if os(windows) cpp-options: -DHAS_WINDOWS_LOCK @@ -156,7 +147,7 @@ test-suite test-process ghc-options: -threaded build-depends: , base - , bytestring >=0.9.2.1 && <0.13 + , bytestring >=0.10.8.2 && <0.13 , lukko if os(windows) diff --git a/src/Lukko/Internal/FillBytes.hs b/src/Lukko/Internal/FillBytes.hs index cf8e79d..a6c1104 100644 --- a/src/Lukko/Internal/FillBytes.hs +++ b/src/Lukko/Internal/FillBytes.hs @@ -3,19 +3,4 @@ {-# LANGUAGE Trustworthy #-} module Lukko.Internal.FillBytes (fillBytes) where -#if MIN_VERSION_base(4,8,0) import Foreign.Marshal.Utils (fillBytes) -#else -import Data.Word (Word8) -import Foreign.C.Types (CInt (..), CSize (..)) -import Foreign.Ptr (Ptr (..)) -#endif - -#if !MIN_VERSION_base(4,8,0) -fillBytes :: Ptr a -> Word8 -> Int -> IO () -fillBytes dest char size = do - _ <- memset dest (fromIntegral char) (fromIntegral size) - return () - -foreign import ccall unsafe "string.h" memset :: Ptr a -> CInt -> CSize -> IO (Ptr a) -#endif diff --git a/src/Lukko/Internal/HandleToFD.hs b/src/Lukko/Internal/HandleToFD.hs index 5ffee4c..c6747cf 100644 --- a/src/Lukko/Internal/HandleToFD.hs +++ b/src/Lukko/Internal/HandleToFD.hs @@ -5,28 +5,7 @@ module Lukko.Internal.HandleToFD (ghcHandleToFd) where import qualified GHC.IO.FD as GHC (FD (..)) import System.IO (Handle) -#if MIN_VERSION_base(4,10,0) import qualified GHC.IO.Handle.FD as GHC (handleToFd) -#else -import Control.Concurrent.MVar (readMVar) -import Data.Typeable (cast) -import GHC.IO.Exception -import GHC.IO.Handle.Internals -import GHC.IO.Handle.Types -#endif ghcHandleToFd :: Handle -> IO GHC.FD -#if MIN_VERSION_base(4,10,0) ghcHandleToFd = GHC.handleToFd -#else -ghcHandleToFd h = case h of - FileHandle _ mv -> do - Handle__{haDevice = dev} <- readMVar mv - case cast dev of - Just fd -> return fd - Nothing -> throwErr "not a file descriptor" - DuplexHandle{} -> throwErr "not a file handle" - where - throwErr msg = ioException $ IOError (Just h) - InappropriateType "handleToFd" msg Nothing Nothing -#endif