Skip to content

Commit

Permalink
Merge pull request #73 from biocad/maksbotan/megaparsec-9.3
Browse files Browse the repository at this point in the history
Allow megaparsec >= 9.3.1
  • Loading branch information
maksbotan authored Dec 8, 2023
2 parents d28b905 + 0b604f3 commit 6717ad6
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 34 deletions.
40 changes: 30 additions & 10 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# This GitHub workflow config has been generated by a script via
#
# haskell-ci 'github' 'cobot-io.cabal'
# haskell-ci 'github' 'cabal.project'
#
# To regenerate the script (for example after adjusting tested-with) run
#
# haskell-ci regenerate
#
# For more information, see https://github.com/haskell-CI/haskell-ci
#
# version: 0.16.6
# version: 0.17.20231110
#
# REGENDATA ("0.16.6",["github","cobot-io.cabal"])
# REGENDATA ("0.17.20231110",["github","cabal.project"])
#
name: Haskell-CI
on:
Expand All @@ -32,11 +32,26 @@ jobs:
strategy:
matrix:
include:
- compiler: ghc-9.8.1
compilerKind: ghc
compilerVersion: 9.8.1
setup-method: ghcup
allow-failure: true
- compiler: ghc-9.6.3
compilerKind: ghc
compilerVersion: 9.6.3
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: true
allow-failure: false
- compiler: ghc-9.0.2
compilerKind: ghc
compilerVersion: 9.0.2
Expand All @@ -54,10 +69,10 @@ jobs:
apt-get update
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5
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"
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.1.0 || (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 }}
Expand All @@ -69,11 +84,13 @@ jobs:
echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV"
echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV"
HCDIR=/opt/$HCKIND/$HCVER
HC=$HOME/.ghcup/bin/$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=$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"
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"
Expand Down Expand Up @@ -168,6 +185,9 @@ jobs:
echo "package cobot-io" >> cabal.project
echo " ghc-options: -Werror=missing-methods" >> cabal.project
cat >> cabal.project <<EOF
allow-newer: hyraxAbif:text
allow-newer: hyraxAbif:bytestring
package cobot-io
ghc-options: -Wall -Werror -fkeep-going
EOF
Expand Down
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## [Unreleased]

## [0.1.5.3] - 2023-12-08
- Update tests and dependencies.

## [0.1.5.2] - 2023-11-09
- Add Ord for Fasta and related types.

Expand Down
2 changes: 1 addition & 1 deletion cabal.haskell-ci
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ distribution: focal

branches: master

allow-failures: >=9.2
allow-failures: >=9.8

local-ghc-options: -Wall -Werror -fkeep-going
3 changes: 3 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
packages: *.cabal

allow-newer: hyraxAbif:text, hyraxAbif:bytestring
21 changes: 9 additions & 12 deletions package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: cobot-io
version: 0.1.5.2
version: 0.1.5.3
github: "biocad/cobot-io"
license: BSD3
category: Bio
Expand All @@ -23,10 +23,9 @@ tested-with: |
GHC ==8.10.7
|| ==9.0.2
|| ==9.2.8
# hyraxAbif does not support text >= 1.3 yet
# || ==9.4.5
# || ==9.6.2
|| ==9.4.8
|| ==9.6.3
|| ==9.8.1
# Metadata used when publishing your package

Expand All @@ -40,11 +39,11 @@ dependencies:
- array >= 0.5 && < 0.6
- attoparsec >= 0.10 && < 0.15
- binary >= 0.8.3.0 && < 1.0
- bytestring >= 0.10.8.1 && < 0.12
- bytestring >= 0.10.8.1 && < 0.13
- cobot >= 0.1.1.7
- containers >= 0.5.7.1 && < 0.7
- data-msgpack >= 0.0.9 && < 0.1
- deepseq >= 1.4 && < 1.5
- deepseq >= 1.4 && < 1.6
- filepath
- http-conduit >= 2.3 && < 2.4
- hyraxAbif >= 0.2.3.27 && < 0.2.5.0
Expand All @@ -54,7 +53,7 @@ dependencies:
- mtl >= 2.2.1 && < 2.4
- parser-combinators >= 1.2.1
- split
- text >= 1.2.2.1 && < 2.1
- text >= 1.2.2.1 && < 2.2
- vector

library:
Expand Down Expand Up @@ -97,9 +96,7 @@ tests:
- cobot-io
- directory
- QuickCheck >= 2.9.2 && < 2.15
- hspec >= 2.4.1 && < 2.11
- hspec >= 2.4.1 && < 2.12
- neat-interpolation >= 0.3
- linear
# megaparsec-9.3 changed something in error messages
# so that our tests do not pass.
- megaparsec < 9.3
- megaparsec
8 changes: 7 additions & 1 deletion src/Bio/Uniprot/Parser.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE TupleSections #-}
{-# OPTIONS_GHC -fno-warn-unused-do-bind #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
Expand All @@ -9,8 +10,13 @@ module Bio.Uniprot.Parser where
import Prelude hiding (null)
import qualified Prelude as P (concat, init, last, null, tail)

import Bio.Uniprot.Type
#if MIN_VERSION_base(4, 18, 0)
import Control.Applicative ((<|>))
#else
import Control.Applicative (liftA2, (<|>))
#endif

import Bio.Uniprot.Type
import Control.Monad (unless)
import Data.Attoparsec.Text
import Data.Bifunctor (second)
Expand Down
27 changes: 17 additions & 10 deletions test/FASTASpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

module FASTASpec where

import Bio.FASTA (fastaP, fromFile, toFile)
import Bio.FASTA.Parser (parseOnly)
import Bio.FASTA.Type (Fasta, FastaItem (..))
import Bio.Sequence (bareSequence)
import Control.Monad.IO.Class (liftIO)
import Data.Text.IO (readFile)
import Prelude hiding (readFile, writeFile)
import System.Directory (removeFile)
import Test.Hspec
import Control.Monad.IO.Class (liftIO)
import Data.Bifunctor (first)
import qualified Data.Text as T
import Data.Text.IO (readFile)
import Prelude hiding (readFile, writeFile)
import System.Directory (removeFile)
import Test.Hspec

import Bio.FASTA (fastaP, fromFile, toFile)
import Bio.FASTA.Parser (parseOnly)
import Bio.FASTA.Type (Fasta, FastaItem (..))
import Bio.Sequence (bareSequence)

correctFasta1 :: Fasta Char
correctFasta1 = [ FastaItem "3HMX:A|PDBID|CHAIN|SEQUENCE" (bareSequence "IWELKKDVYVVELDWYPDAPGEMVVLTCDTPEEDGITWTLDQSSEVLGSGKTLTIQVKEFGDAGQYTCHKGGEVLSHSLL")
Expand Down Expand Up @@ -70,7 +73,7 @@ parseBadFile path cf =
it ("correctly parses bad fasta from file " <> path) $ do
res <- liftIO (readFile path)
let badRes = parseOnly fastaP res
badRes `shouldBe` cf
noSpaces badRes `shouldBe` noSpaces cf

writeFile :: FilePath -> Fasta Char -> Spec
writeFile path cf =
Expand All @@ -79,3 +82,7 @@ writeFile path cf =
fasta <- fromFile path
removeFile path
fasta `shouldBe` cf

-- | megaparsec >= 9.3 added more spaces to error messages, so that our old ones do not match.
noSpaces :: Either String a -> Either String a
noSpaces = first $ T.unpack . T.replace " " "" . T.pack

0 comments on commit 6717ad6

Please sign in to comment.